Skip to content
Open
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
28 changes: 12 additions & 16 deletions Chapter-2-modules-separation/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -138,25 +138,21 @@ to download it from the official Microsoft website.

=== Run locally

The Fitnet application requires Docker to run properly.
The Fitnet application uses .NET Aspire for local development.

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

1. Make sure that you are in `/Src` directory.
2. Run `docker-compose build` to build the image of the application.
3. Run `docker-compose up` to start the application. In the meantime it will also start Postgres inside container.
1. **Ensure Docker is running** on your machine.
2. **Navigate to the solution root directory** in your terminal.
3. **Run the AppHost project using the following command:**

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.
=== How to run Integration Tests?
To run the integration tests for the project located in the `Fitnet.IntegrationTests` project, you can use either the command:

That's it! You should now be able to run the application using either one of the above. :thumbsup:
`dotnet test`

or the `IDE test explorer`.

These tests are written using `xUnit` and require `Docker` to be running as they use `test containers` package to run PostgresSQL in a Docker container during testing.

=== How to run Integration Tests?
To run the integration tests go to a module integration tests (`SelectedModule.IntegrationTests`) and run using either the command:
[source,shell]
----
dotnet test
----
or the `IDE test Explorer`.

These tests are written using `xUnit` and require `Docker` to be running as they use `test containers` package to run PostgresSQL in a Docker container during testing.
Therefore, make sure to have `Docker` running before executing the integration tests.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ο»Ώ#nullable disable

namespace EvolutionaryArchitecture.Fitnet.Contracts.Data.Database.Migrations;
using System;

using Microsoft.EntityFrameworkCore.Migrations;

[ExcludeFromCodeCoverage]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ο»Ώ#nullable disable

namespace EvolutionaryArchitecture.Fitnet.Contracts.Data.Database.Migrations;
using System;

using Microsoft.EntityFrameworkCore.Migrations;

[ExcludeFromCodeCoverage]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ο»Ώ#nullable disable

namespace EvolutionaryArchitecture.Fitnet.Contracts.Data.Database.Migrations;
using System;

using Microsoft.EntityFrameworkCore.Migrations;

[ExcludeFromCodeCoverage]
Expand Down
3 changes: 3 additions & 0 deletions Chapter-2-modules-separation/Src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup Label="Production">
<PackageVersion Include="Aspire.Hosting.AppHost" Version="9.0.0" />
<PackageVersion Include="Aspire.Hosting.PostgreSQL" Version="9.0.0" />
<PackageVersion Include="Dapper" Version="2.1.66" />
<PackageVersion Include="FluentValidation" Version="12.0.0" />
<PackageVersion Include="FluentValidation.DependencyInjectionExtensions" Version="12.0.0" />
<PackageVersion Include="JetBrains.Annotations" Version="2025.2.2" />
<PackageVersion Include="KubernetesClient" Version="17.0.14" />
<PackageVersion Include="MediatR" Version="12.5.0" />
<PackageVersion Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="9.0.9" />
Expand Down
21 changes: 0 additions & 21 deletions Chapter-2-modules-separation/Src/Dockerfile

This file was deleted.

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

<PropertyGroup>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
<UserSecretsId>a3ef42d8-8e72-4dd1-a8a7-cd43e2c575e8</UserSecretsId>
</PropertyGroup>

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

<ItemGroup>
<ProjectReference Include="..\Fitnet\Fitnet.csproj"/>
</ItemGroup>

</Project>
17 changes: 17 additions & 0 deletions Chapter-2-modules-separation/Src/Fitnet.AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Projects;

var builder = DistributedApplication.CreateBuilder(args);
var postgres = builder.AddPostgres("postgres")
.WithImage("postgres", "14.3")
.WithPgAdmin();

var fitnetDatabase = postgres.AddDatabase("fitnetsdb", "fitnet");
builder.AddProject<Fitnet>("fitnet")
.WithEnvironment("ASPNETCORE_ENVIRONMENT", "Development")
.WithReference(fitnetDatabase, "Modules__Passes__ConnectionStrings__Primary")
.WithReference(fitnetDatabase, "Modules__Contracts__ConnectionStrings__Primary")
.WithReference(fitnetDatabase, "Modules__Reports__ConnectionStrings__Primary")
.WithReference(fitnetDatabase, "Modules__Offers__ConnectionStrings__Primary")
.WaitFor(postgres);

await builder.Build().RunAsync();
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17106;http://localhost:15108",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21130",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22190"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}
1 change: 1 addition & 0 deletions Chapter-2-modules-separation/Src/Fitnet.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@
<Folder Name="/Reports/Tests/">
<Project Path="Reports\Tests\Fitnet.Reports.IntegrationTests\Fitnet.Reports.IntegrationTests.csproj" Type="Classic C#" />
</Folder>
<Project Path="Fitnet.AppHost/Fitnet.AppHost.csproj" />
<Project Path="Fitnet\Fitnet.csproj" Type="Classic C#" />
</Solution>
25 changes: 0 additions & 25 deletions Chapter-2-modules-separation/Src/Fitnet/.dockerignore

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ο»Ώ#nullable disable

namespace SuperSimpleArchitecture.Fitnet.Migrations.OffersPersistenceMigrations;
using System;

using System.Diagnostics.CodeAnalysis;
using Microsoft.EntityFrameworkCore.Migrations;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ο»Ώ#nullable disable

namespace EvolutionaryArchitecture.Fitnet.Passes.DataAccess.Database;
using System;

using Microsoft.EntityFrameworkCore.Migrations;

[ExcludeFromCodeCoverage]
Expand Down
30 changes: 0 additions & 30 deletions Chapter-2-modules-separation/Src/docker-compose.yml

This file was deleted.