Skip to content

Commit

Permalink
added Successful and Failed, github action
Browse files Browse the repository at this point in the history
  • Loading branch information
md-redwan-hossain committed Jun 13, 2024
1 parent 6132936 commit e78ac93
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 13 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: DotNet 8

on:
push:
branches: ["main", "develop"]
pull_request:
branches: ["main", "develop"]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup DotNet 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- name: Restore dependencies
run: dotnet restore "SharpOutcome.sln"
- name: Build
run: dotnet build "SharpOutcome.sln" --configuration Release --no-restore
9 changes: 9 additions & 0 deletions SharpOutcome.Tests/BookServiceTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace SharpOutcome.Tests;

public class BookServiceTests
{
[Fact]
public void Test1()
{
}
}
31 changes: 31 additions & 0 deletions SharpOutcome.Tests/SharpOutcome.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="xunit" Version="2.8.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<Using Include="Xunit"/>
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions SharpOutcome.sln
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpOutcome", "src\SharpOu
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpOutcome.HttpApiExample", "src\SharpOutcome.HttpApiExample\SharpOutcome.HttpApiExample.csproj", "{06FF4BB3-AC61-406D-A6FC-6F540350AF28}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpOutcome.Tests", "SharpOutcome.Tests\SharpOutcome.Tests.csproj", "{DA38D86D-9F4B-4FF3-8DF0-924642BACC2D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -18,5 +20,9 @@ Global
{06FF4BB3-AC61-406D-A6FC-6F540350AF28}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06FF4BB3-AC61-406D-A6FC-6F540350AF28}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06FF4BB3-AC61-406D-A6FC-6F540350AF28}.Release|Any CPU.Build.0 = Release|Any CPU
{DA38D86D-9F4B-4FF3-8DF0-924642BACC2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA38D86D-9F4B-4FF3-8DF0-924642BACC2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA38D86D-9F4B-4FF3-8DF0-924642BACC2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA38D86D-9F4B-4FF3-8DF0-924642BACC2D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
8 changes: 2 additions & 6 deletions src/SharpOutcome.HttpApiExample/Controllers/BookController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ namespace SharpOutcome.HttpApiExample.Controllers;
public sealed class BookController : ControllerBase
{
private readonly IBookService _bookService;

public BookController(IBookService bookService)
{
_bookService = bookService;
}
public BookController(IBookService bookService) => _bookService = bookService;

[HttpGet]
public async Task<IActionResult> GetBook()
Expand All @@ -29,7 +25,7 @@ public async Task<IActionResult> GetBook(int id)
{
var result = await _bookService.GetOneAsync(id);

return result.Match<IActionResult>(
return result.Match(
entity => ControllerContext.MakeResponse(StatusCodes.Status200OK, entity),
err => ControllerContext.MakeResponse(err)
);
Expand Down
1 change: 0 additions & 1 deletion src/SharpOutcome.HttpApiExample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

builder.Services.AddDbContext<BookDbContext>(opts => opts.UseSqlite(connectionString));


builder.Services.AddControllers(opts =>
{
opts.Conventions.Add(new RouteTokenTransformerConvention(new SlugifyParameterTransformer()));
Expand Down
6 changes: 6 additions & 0 deletions src/SharpOutcome/Helpers/Failed.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace SharpOutcome.Helpers;

/// <summary>
/// Represents a generalized bad outcome.
/// </summary>
public readonly record struct Failed;
6 changes: 6 additions & 0 deletions src/SharpOutcome/Helpers/Successful.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace SharpOutcome.Helpers;

/// <summary>
/// Represents a generalized good outcome.
/// </summary>
public readonly record struct Successful;
7 changes: 1 addition & 6 deletions src/SharpOutcome/SharpOutcome.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<Version>0.0.8</Version>
<Version>0.0.9</Version>
<Title>SharpOutcome</Title>
<Authors>Md. Redwan Hossain</Authors>
<Copyright>Copyright (c) Md. Redwan Hossain</Copyright>
Expand Down Expand Up @@ -35,11 +35,6 @@
<PackagePath>.</PackagePath>
</None>
</ItemGroup>


<ItemGroup>
<Folder Include="Helpers\" />
</ItemGroup>


</Project>

0 comments on commit e78ac93

Please sign in to comment.