Skip to content

Commit fc219b4

Browse files
authored
Merge branch 'main' into copilot/implement-rabbitmq-in-aspire
2 parents 8ed0440 + 369936c commit fc219b4

31 files changed

Lines changed: 165 additions & 182 deletions

Chapter-1-initial-architecture/README.adoc

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,13 @@ to download it from the official Microsoft website.
197197

198198
=== Run locally
199199

200-
The Fitnet application requires Docker to run properly.
200+
The Fitnet application uses .NET Aspire for local development.
201201

202-
There are only 3 steps you need to start the application:
202+
To run the application locally, follow these steps:
203203

204-
1. Make sure that you are in `/Src` directory.
205-
2. Run `docker-compose build` to build the image of the application.
206-
3. Run `docker-compose up` to start the application. In the meantime it will also start Postgres inside container.
207-
208-
The application runs on port `:8080`. Please navigate to http://localhost:8080 in your browser or http://localhost:8080/swagger/index.html to explore the API.
209-
210-
That's it! You should now be able to run the application using either one of the above. :thumbsup:
204+
1. **Ensure Docker is running** on your machine.
205+
2. **Navigate to the solution root directory** in your terminal.
206+
3. **Run the AppHost project using the following command:**
211207

212208
=== How to run Integration Tests?
213209
To run the integration tests for the project located in the `Fitnet.IntegrationTests` project, you can use either the command:
Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
<Project>
22

3-
<PropertyGroup>
4-
<AssemblyName>EvolutionaryArchitecture.$(MSBuildProjectName)</AssemblyName>
5-
<RootNamespace>$(AssemblyName)</RootNamespace>
6-
<TargetFramework>net9.0</TargetFramework>
7-
<AnalysisLevel>latest</AnalysisLevel>
8-
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
9-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
10-
<ImplicitUsings>enable</ImplicitUsings>
11-
<Nullable>enable</Nullable>
12-
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
13-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
14-
</PropertyGroup>
15-
16-
<ItemGroup>
17-
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />
18-
</ItemGroup>
3+
<PropertyGroup>
4+
<AssemblyName>EvolutionaryArchitecture.$(MSBuildProjectName)</AssemblyName>
5+
<RootNamespace>$(AssemblyName)</RootNamespace>
6+
<TargetFramework>net9.0</TargetFramework>
7+
<AnalysisLevel>latest</AnalysisLevel>
8+
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
9+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
10+
<ImplicitUsings>enable</ImplicitUsings>
11+
<Nullable>enable</Nullable>
12+
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
13+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
14+
</PropertyGroup>
15+
16+
<ItemGroup>
17+
<InternalsVisibleTo Include="DynamicProxyGenAssembly2"/>
18+
</ItemGroup>
19+
20+
<ItemGroup>
21+
<PackageReference
22+
Include="SonarAnalyzer.CSharp"
23+
Version="9.7.0.75501"
24+
PrivateAssets="all"
25+
Condition="$(MSBuildProjectExtension) == '.csproj'"
26+
/>
27+
</ItemGroup>
1928

20-
<ItemGroup>
21-
<PackageReference
22-
Include="SonarAnalyzer.CSharp"
23-
Version="9.7.0.75501"
24-
PrivateAssets="all"
25-
Condition="$(MSBuildProjectExtension) == '.csproj'"
26-
/>
27-
</ItemGroup>
28-
2929
</Project>

Chapter-1-initial-architecture/Src/Dockerfile

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<Sdk Name="Aspire.AppHost.Sdk" Version="9.0.0"/>
3+
4+
<PropertyGroup>
5+
<OutputType>Exe</OutputType>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<IsAspireHost>true</IsAspireHost>
9+
<UserSecretsId>b4ef32d8-9e82-4dd1-b9a7-bc43e2c564e9</UserSecretsId>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.0.0"/>
14+
<PackageReference Include="Aspire.Hosting.PostgreSQL" Version="9.0.0"/>
15+
<PackageReference Update="SonarAnalyzer.CSharp" Version="10.15.0.120848" />
16+
</ItemGroup>
17+
18+
<ItemGroup>
19+
<ProjectReference Include="..\Fitnet\Fitnet.csproj"/>
20+
</ItemGroup>
21+
22+
</Project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Projects;
2+
3+
var builder = DistributedApplication.CreateBuilder(args);
4+
var postgres = builder.AddPostgres("postgres")
5+
.WithImage("postgres", "15.15")
6+
.WithPgAdmin();
7+
8+
var fitnetDatabase = postgres.AddDatabase("fitnetsdb", "fitnet");
9+
builder.AddProject<Fitnet>("fitnet")
10+
.WithEnvironment("ASPNETCORE_ENVIRONMENT", "Development")
11+
.WithReference(fitnetDatabase, "Passes")
12+
.WithReference(fitnetDatabase, "Contracts")
13+
.WithReference(fitnetDatabase, "Reports")
14+
.WithReference(fitnetDatabase, "Offers")
15+
.WaitFor(postgres);
16+
17+
await builder.Build().RunAsync();
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"https": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
7+
"launchBrowser": true,
8+
"applicationUrl": "https://localhost:17105;http://localhost:15107",
9+
"environmentVariables": {
10+
"ASPNETCORE_ENVIRONMENT": "Development",
11+
"DOTNET_ENVIRONMENT": "Development",
12+
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21129",
13+
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22189"
14+
}
15+
}
16+
}
17+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning",
6+
"Aspire.Hosting.Dcp": "Warning"
7+
}
8+
}
9+
}

Chapter-1-initial-architecture/Src/Fitnet.ArchitectureTests/Fitnet.ArchitectureTests.csproj

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
<ItemGroup>
88
<PackageReference Include="NetArchTest.Rules" Version="1.3.2" />
99
<PackageReference Include="Shouldly" Version="4.3.0" />
10-
<PackageReference Include="xunit" Version="2.9.2" />
11-
<PackageReference Include="xunit.analyzers" Version="1.17.0">
10+
<PackageReference Include="xunit.v3" Version="3.2.0" />
11+
<PackageReference Include="xunit.analyzers" Version="1.26.0">
1212
<PrivateAssets>all</PrivateAssets>
1313
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1414
</PackageReference>
15-
<PackageReference Include="xunit.categories" Version="2.0.8" />
16-
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
15+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
1716
<PrivateAssets>all</PrivateAssets>
1817
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1918
</PackageReference>
@@ -22,7 +21,7 @@
2221
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2322
<PrivateAssets>all</PrivateAssets>
2423
</PackageReference>
25-
<PackageReference Update="SonarAnalyzer.CSharp" Version="10.14.0.120626" />
24+
<PackageReference Update="SonarAnalyzer.CSharp" Version="10.15.0.120848" />
2625
</ItemGroup>
2726

2827
<ItemGroup>

Chapter-1-initial-architecture/Src/Fitnet.IntegrationTests/Common/TestEngine/DatabaseContainer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public sealed class DatabaseContainer : IAsyncLifetime
1111
private PostgreSqlContainer? _container;
1212
internal string? ConnectionString;
1313

14-
public async Task InitializeAsync()
14+
public async ValueTask InitializeAsync()
1515
{
1616
_container = new PostgreSqlBuilder()
1717
.WithDatabase(Database)
@@ -24,5 +24,5 @@ public async Task InitializeAsync()
2424
ConnectionString = _container.GetConnectionString();
2525
}
2626

27-
public async Task DisposeAsync() => await _container!.StopAsync();
27+
public async ValueTask DisposeAsync() => await _container!.StopAsync();
2828
}

Chapter-1-initial-architecture/Src/Fitnet.IntegrationTests/Contracts/PrepareContract/PrepareContractTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ internal async Task Given_valid_contract_preparation_request_When_preparing_new_
3737
var customerId = Guid.NewGuid();
3838
var requestParameters = PrepareContractRequestParameters.GetValid();
3939
var prepareContractResponse = await PrepareCorrectContract(requestParameters, customerId);
40-
var preparedContractId = await prepareContractResponse.Content.ReadFromJsonAsync<Guid>();
40+
var preparedContractId = await prepareContractResponse.Content.ReadFromJsonAsync<Guid>(TestContext.Current.CancellationToken);
4141
var signContractRequestParameters = SignContractRequestParameters.GetValid(preparedContractId);
4242
var signContractRequest = new SignContractRequest(signContractRequestParameters.SignedAt);
4343
var signContractResponse =
44-
await _applicationHttpClient.PatchAsJsonAsync(signContractRequestParameters.Url, signContractRequest);
44+
await _applicationHttpClient.PatchAsJsonAsync(signContractRequestParameters.Url, signContractRequest, TestContext.Current.CancellationToken);
4545
signContractResponse.StatusCode.ShouldBe(HttpStatusCode.NoContent);
4646

4747
// Act
@@ -62,12 +62,12 @@ internal async Task Given_contract_preparation_request_with_invalid_age_Then_sho
6262

6363
// Act
6464
using var prepareContractResponse =
65-
await _applicationHttpClient.PostAsJsonAsync(ContractsApiPaths.Prepare, prepareContractRequest);
65+
await _applicationHttpClient.PostAsJsonAsync(ContractsApiPaths.Prepare, prepareContractRequest, TestContext.Current.CancellationToken);
6666

6767
// Assert
6868
prepareContractResponse.StatusCode.ShouldBe(HttpStatusCode.Conflict);
6969

70-
var responseMessage = await prepareContractResponse.Content.ReadFromJsonAsync<ProblemDetails>();
70+
var responseMessage = await prepareContractResponse.Content.ReadFromJsonAsync<ProblemDetails>(TestContext.Current.CancellationToken);
7171
responseMessage?.Status.ShouldBe((int)HttpStatusCode.Conflict);
7272
responseMessage?.Title.ShouldBe("Contract can not be prepared for a person who is not adult");
7373
}
@@ -83,12 +83,12 @@ internal async Task Given_contract_preparation_request_with_invalid_height_Then_
8383

8484
// Act
8585
using var prepareContractResponse =
86-
await _applicationHttpClient.PostAsJsonAsync(ContractsApiPaths.Prepare, prepareContractRequest);
86+
await _applicationHttpClient.PostAsJsonAsync(ContractsApiPaths.Prepare, prepareContractRequest, TestContext.Current.CancellationToken);
8787

8888
// Assert
8989
prepareContractResponse.StatusCode.ShouldBe(HttpStatusCode.Conflict);
9090

91-
var responseMessage = await prepareContractResponse.Content.ReadFromJsonAsync<ProblemDetails>();
91+
var responseMessage = await prepareContractResponse.Content.ReadFromJsonAsync<ProblemDetails>(TestContext.Current.CancellationToken);
9292
responseMessage?.Status.ShouldBe((int)HttpStatusCode.Conflict);
9393
responseMessage?.Title.ShouldBe("Customer height must fit maximum limit for gym instruments");
9494
}
@@ -107,7 +107,7 @@ internal async Task
107107

108108
// Assert
109109
prepareContractResponse.StatusCode.ShouldBe(HttpStatusCode.Conflict);
110-
var responseMessage = await prepareContractResponse.Content.ReadFromJsonAsync<ProblemDetails>();
110+
var responseMessage = await prepareContractResponse.Content.ReadFromJsonAsync<ProblemDetails>(TestContext.Current.CancellationToken);
111111
responseMessage?.Status.ShouldBe((int)HttpStatusCode.Conflict);
112112
responseMessage?.Title.ShouldBe("Previous contract must be signed by the customer");
113113
}
@@ -123,9 +123,9 @@ private async Task<HttpResponseMessage> PrepareCorrectContract(PrepareContractRe
123123
return prepareContractResponse;
124124
}
125125

126-
public Task InitializeAsync() => Task.CompletedTask;
126+
public ValueTask InitializeAsync() => ValueTask.CompletedTask;
127127

128-
public async Task DisposeAsync()
128+
public async ValueTask DisposeAsync()
129129
{
130130
_applicationHttpClient.Dispose();
131131
await applicationInMemoryFactory.DisposeAsync();

0 commit comments

Comments
 (0)