Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/chapter-1-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 9.0.x
dotnet-version: 10.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand All @@ -43,7 +43,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 9.0.x
dotnet-version: 10.0.x
- name: Restore dependencies
run: dotnet restore
- name: Test
Expand Down
50 changes: 25 additions & 25 deletions Chapter-1-initial-architecture/Src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
<Project>

<PropertyGroup>
<AssemblyName>EvolutionaryArchitecture.$(MSBuildProjectName)</AssemblyName>
<RootNamespace>$(AssemblyName)</RootNamespace>
<TargetFramework>net9.0</TargetFramework>
<AnalysisLevel>latest</AnalysisLevel>
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<InternalsVisibleTo Include="DynamicProxyGenAssembly2"/>
</ItemGroup>

<ItemGroup>
<PackageReference
Include="SonarAnalyzer.CSharp"
Version="9.7.0.75501"
PrivateAssets="all"
Condition="$(MSBuildProjectExtension) == '.csproj'"
/>
</ItemGroup>
<PropertyGroup>
<AssemblyName>EvolutionaryArchitecture.$(MSBuildProjectName)</AssemblyName>
<RootNamespace>$(AssemblyName)</RootNamespace>
<TargetFramework>net10.0</TargetFramework>
<AnalysisLevel>latest</AnalysisLevel>
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />
</ItemGroup>

<ItemGroup>
<PackageReference
Include="SonarAnalyzer.CSharp"
Version="9.7.0.75501"
PrivateAssets="all"
Condition="$(MSBuildProjectExtension) == '.csproj'"
/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<Sdk Name="Aspire.AppHost.Sdk" Version="9.0.0"/>
<Sdk Name="Aspire.AppHost.Sdk" Version="13.0.2"/>

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -10,8 +10,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.0.0"/>
<PackageReference Include="Aspire.Hosting.PostgreSQL" Version="9.0.0"/>
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.0.2"/>
<PackageReference Include="Aspire.Hosting.PostgreSQL" Version="13.0.2"/>
<PackageReference Update="SonarAnalyzer.CSharp" Version="10.15.0.120848" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,26 @@

<PropertyGroup>
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);S3604;xUnit1050</NoWarn>
<NoWarn>$(NoWarn);S3604;xUnit1045;</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bogus" Version="35.6.1" />
<PackageReference Include="Microsoft.Extensions.TimeProvider.Testing" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.TimeProvider.Testing" Version="10.0.0" />
<PackageReference Include="NSubstitute" Version="5.3.0" />
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="Verify.XunitV3" Version="31.7.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Testcontainers" Version="4.0.0" />
<PackageReference Include="Testcontainers.PostgreSql" Version="4.0.0" />
<PackageReference Include="xunit.v3" Version="3.2.0" />
<PackageReference Include="xunit.analyzers" Version="1.26.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Update="SonarAnalyzer.CSharp" Version="10.15.0.120848" />
<PackageReference Include="Verify.XunitV3" Version="31.7.0" />
<PackageReference Include="xunit.v3" Version="3.2.0" />
<PackageReference Include="xunit.v3.extensibility.core" Version="3.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Global using directives

global using System.Collections;
global using System.Net;
global using Xunit;
global using Microsoft.AspNetCore.Mvc.Testing;
global using Bogus;
global using JetBrains.Annotations;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
namespace EvolutionaryArchitecture.Fitnet.IntegrationTests.Reports.GenerateNewPassesPerMonthReport.TestData;

internal sealed class ReportTestCases : IEnumerable<object[]>
internal sealed class ReportTestCases : TheoryData<List<PassRegistrationDateRange>>
{
internal static DateTimeOffset FakeNowDate = new(2021, 1, 1, 0, 0, 0, TimeSpan.Zero);

public IEnumerator<object[]> GetEnumerator()
{
yield return
[
new List<PassRegistrationDateRange>
{
new(new DateTimeOffset(FakeNowDate.Year, 1, 3, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 1, 10 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 1, 5, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 1, 20 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 2, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 2, 28 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 3, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 3, 31 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 4, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 4, 30 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 5, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 5, 31 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 6, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 6, 30 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 7, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 7, 31 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 8, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 8, 31 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 9, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 9, 30 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 10, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 10, 31 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 11, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 11, 30 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 12, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 12, 31 ,1, 1, 1,1, TimeSpan.Zero))
}
];
}

IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
public ReportTestCases() => Add(new List<PassRegistrationDateRange>
{
new(new DateTimeOffset(FakeNowDate.Year, 1, 3, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 1, 10 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 1, 5, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 1, 20 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 2, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 2, 28 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 3, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 3, 31 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 4, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 4, 30 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 5, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 5, 31 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 6, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 6, 30 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 7, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 7, 31 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 8, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 8, 31 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 9, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 9, 30 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 10, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 10, 31 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 11, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 11, 30 ,1, 1, 1,1, TimeSpan.Zero)),
new(new DateTimeOffset(FakeNowDate.Year, 12, 1, 1, 1,1, TimeSpan.Zero), new DateTimeOffset(FakeNowDate.Year, 12, 31 ,1, 1, 1,1, TimeSpan.Zero))
});
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace EvolutionaryArchitecture.Fitnet.UnitTests.BusinessRulesEngine;

using EvolutionaryArchitecture.Fitnet.Common.BusinessRulesEngine;
using Common.BusinessRulesEngine;

internal sealed class FakeBusinessRule : IBusinessRule
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@ namespace EvolutionaryArchitecture.Fitnet.UnitTests.Contracts.PrepareContract.Re

using EvolutionaryArchitecture.Fitnet.Contracts.PrepareContract;

internal sealed class InvalidPrepareContractRequestTestCases : IEnumerable<object[]>
internal sealed class InvalidPrepareContractRequestTestCases : TheoryData<PrepareContractRequest, string>
{
private readonly Faker _faker = new();
private readonly DateTimeOffset _fakeNow = new Faker().Date.RecentOffset();

public IEnumerator<object[]> GetEnumerator()
public InvalidPrepareContractRequestTestCases()
{
var validContractParameters = PrepareContractParameters.GetValid();

yield return new object[] { new PrepareContractRequest(Guid.Empty, validContractParameters.MinAge, validContractParameters.MaxHeight, _fakeNow), nameof(PrepareContractRequest.CustomerId) };
yield return new object[] { new PrepareContractRequest(Guid.NewGuid(), default, validContractParameters.MaxHeight, _fakeNow), nameof(PrepareContractRequest.CustomerAge) };
yield return new object[] { new PrepareContractRequest(Guid.NewGuid(), _faker.Random.Number(-100, -1), validContractParameters.MaxHeight, _fakeNow), nameof(PrepareContractRequest.CustomerAge) };
yield return new object[] { new PrepareContractRequest(Guid.NewGuid(), validContractParameters.MinAge, default, _fakeNow), nameof(PrepareContractRequest.CustomerHeight) };
yield return new object[] { new PrepareContractRequest(Guid.NewGuid(), validContractParameters.MinAge, _faker.Random.Number(-100, -1), _fakeNow), nameof(PrepareContractRequest.CustomerHeight) };
yield return new object[] { new PrepareContractRequest(Guid.NewGuid(), validContractParameters.MinAge, validContractParameters.MaxHeight, default), nameof(PrepareContractRequest.PreparedAt) };
yield return new object[] { new PrepareContractRequest(Guid.NewGuid(), validContractParameters.MinAge, validContractParameters.MaxHeight, default), nameof(PrepareContractRequest.PreparedAt) };
Add(new PrepareContractRequest(Guid.Empty, validContractParameters.MinAge, validContractParameters.MaxHeight, _fakeNow), nameof(PrepareContractRequest.CustomerId));
Add(new PrepareContractRequest(Guid.NewGuid(), default, validContractParameters.MaxHeight, _fakeNow), nameof(PrepareContractRequest.CustomerAge));
Add(new PrepareContractRequest(Guid.NewGuid(), _faker.Random.Number(-100, -1), validContractParameters.MaxHeight, _fakeNow), nameof(PrepareContractRequest.CustomerAge));
Add(new PrepareContractRequest(Guid.NewGuid(), validContractParameters.MinAge, default, _fakeNow), nameof(PrepareContractRequest.CustomerHeight));
Add(new PrepareContractRequest(Guid.NewGuid(), validContractParameters.MinAge, _faker.Random.Number(-100, -1), _fakeNow), nameof(PrepareContractRequest.CustomerHeight));
Add(new PrepareContractRequest(Guid.NewGuid(), validContractParameters.MinAge, validContractParameters.MaxHeight, default), nameof(PrepareContractRequest.PreparedAt));
Add(new PrepareContractRequest(Guid.NewGuid(), validContractParameters.MinAge, validContractParameters.MaxHeight, default), nameof(PrepareContractRequest.PreparedAt));
}

IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

<PropertyGroup>
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);xUnit1050</NoWarn>
<NoWarn>$(NoWarn);xUnit1050;xUnit1044;</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bogus" Version="35.6.1" />
<PackageReference Include="NSubstitute" Version="5.3.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Global using directives

global using System.Collections;
global using Bogus;
global using Microsoft.AspNetCore.Http;
global using NSubstitute;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
ο»Ώnamespace EvolutionaryArchitecture.Fitnet.Common.Documentation;

using Microsoft.OpenApi.Models;

internal static class ApiDocumentationExtensions
{
internal static void UseApiDocumentation(this IEndpointRouteBuilder app) =>
app.MapGet("/", () => Results.Redirect("/swagger"))
.WithOpenApi(operation => new OpenApiOperation(operation)
{
Summary = "Documentation for the API",
Description = "This endpoint is used to redirect to the documentation for the API.",
})
.WithSummary("Documentation for the API")
.WithDescription("This endpoint is used to redirect to the documentation for the API.")
.Produces(StatusCodes.Status200OK)
.WithTags("Documentation");
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ namespace EvolutionaryArchitecture.Fitnet.Contracts.PrepareContract;
using Data;
using Data.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Models;

internal static class PrepareContractEndpoint
{
Expand All @@ -28,12 +27,8 @@ internal static void MapPrepareContract(this IEndpointRouteBuilder app) =>
return Results.Created($"/{ContractsApiPaths.Prepare}/{contract.Id}", contract.Id);
})
.ValidateRequest<PrepareContractRequest>()
.WithOpenApi(operation => new OpenApiOperation(operation)
{
Summary = "Triggers preparation of a new contract for new or existing customer",
Description =
"This endpoint is used to prepare a new contract for new and existing customers."
})
.WithSummary("Triggers preparation of a new contract for new or existing customer")
.WithDescription("This endpoint is used to prepare a new contract for new and existing customers.")
.Produces<string>(StatusCodes.Status201Created)
.Produces(StatusCodes.Status409Conflict)
.Produces(StatusCodes.Status500InternalServerError);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ internal static void MapSignContract(this IEndpointRouteBuilder app) => app.MapP
return Results.NoContent();
})
.ValidateRequest<SignContractRequest>()
.WithOpenApi(operation => new(operation)
{
Summary = "Signs prepared contract",
Description = "This endpoint is used to sign prepared contract by customer."
})
.WithSummary("Signs prepared contract")
.WithDescription("This endpoint is used to sign prepared contract by customer.")
.Produces(StatusCodes.Status204NoContent)
.Produces(StatusCodes.Status404NotFound)
.Produces(StatusCodes.Status409Conflict)
Expand Down
9 changes: 5 additions & 4 deletions Chapter-1-initial-architecture/Src/Fitnet/Fitnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.0.0" />
<PackageReference Include="JetBrains.Annotations" Version="2025.2.2" />
<PackageReference Include="MediatR" Version="12.5.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.9" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.4" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.1" />
<PackageReference Include="Microsoft.OpenApi" Version="2.3.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.0.1" />
<PackageReference Update="SonarAnalyzer.CSharp" Version="10.15.0.120848" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ internal static void MapGetAllPasses(this IEndpointRouteBuilder app) =>

return Results.Ok(response);
})
.WithOpenApi(operation => new(operation)
{
Summary = "Returns all passes that exist in the system",
Description =
"This endpoint is used to retrieve all existing passes.",
})
.WithSummary("Returns all passes that exist in the system")
.WithDescription("This endpoint is used to retrieve all existing passes.")
.Produces<GetAllPassesResponse>()
.Produces(StatusCodes.Status500InternalServerError);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@ await eventBus.PublishAsync(

return Results.NoContent();
})
.WithOpenApi(operation => new(operation)
{
Summary = "Marks pass which expired",
Description =
"This endpoint is used to mark expired pass. Based on that it is possible to offer new contract to customer.",
})
.WithSummary("Marks pass which expired")
.WithDescription("This endpoint is used to mark expired pass. Based on that it is possible to offer new contract to customer.")
.Produces(StatusCodes.Status204NoContent)
.Produces(StatusCodes.Status404NotFound)
.Produces(StatusCodes.Status500InternalServerError);
Expand Down
Loading