Skip to content

Commit

Permalink
Upgrade to .net 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aimenux committed Mar 6, 2024
1 parent d1ef848 commit 098ff53
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 25 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Using pipeline behaviors to implement cross-cutting concerns
In this repo, i m using [pipeline behaviors](https://github.com/jbogard/MediatR/wiki/Behaviors) to implement cross-cutting concerns (validation, logging, etc).

>
**`Tools`** : net 7.0, web api, mediatr, unit-testing, integration-testing
**`Tools`** : net 8.0, web api, mediatr, unit-testing, integration-testing
2 changes: 1 addition & 1 deletion src/Application/Filters/ApiExceptionFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private static void HandleUnhandledException(ExceptionContext context)
var exception = context.Exception;
var details = new ProblemDetails
{
Type = "https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.1",
Type = "https://tools.ietf.org/html/rfc7231#section-6.6.1",
Title = "Internal Server Error.",
Detail = exception.Message
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

namespace PipelineBehaviorsDemo.Application.UseCases.GetWeatherByCity;

public sealed record GetWeatherByCityQuery(string city) : IRequest<GetWeatherByCityQueryResponse>;
public sealed record GetWeatherByCityQuery(string City) : IRequest<GetWeatherByCityQueryResponse>;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public GetWeatherByCityQueryHandler(IWeatherProvider weatherProvider)

public async Task<GetWeatherByCityQueryResponse> Handle(GetWeatherByCityQuery request, CancellationToken cancellationToken)
{
var city = new City(request.city.ToUpper());
var city = new City(request.City.ToUpper());
if (!CityBusinessRules.IsSupportedCity(city))
{
throw NotFoundException.CityIsNotFound(city);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class GetWeatherByCityQueryValidator : AbstractValidator<GetWeatherByCity
{
public GetWeatherByCityQueryValidator()
{
RuleFor(x => x.city)
RuleFor(x => x.City)
.NotEmpty()
.MinimumLength(3)
.MaximumLength(100)
Expand Down
8 changes: 4 additions & 4 deletions src/PipelineBehaviorsDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentValidation" Version="11.8.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.8.0" />
<PackageReference Include="MediatR" Version="12.1.1" />
<PackageReference Include="FluentValidation" Version="11.9.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.0" />
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.13" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.16" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace PipelineBehaviorsDemo.Presentation.Controllers.V1.GetWeatherByCity;

public class GetWeatherByCityApiResponse
public sealed record GetWeatherByCityApiResponse
{
public string City { get; init; } = default!;
public DateOnly Date { get; init; }
Expand Down
5 changes: 3 additions & 2 deletions src/Presentation/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ public static IServiceCollection AddPresentation(this IServiceCollection service

private static IServiceCollection AddApiVersioning(this IServiceCollection services)
{
const string name = "x-api-version";
const string name = "X-Api-Version";
services.AddApiVersioning(config =>
{
config.ReportApiVersions = true;
config.AssumeDefaultVersionWhenUnspecified = true;
config.DefaultApiVersion = new ApiVersion(1, 0);
config.ApiVersionReader = ApiVersionReader.Combine(new UrlSegmentApiVersionReader(),
config.ApiVersionReader = ApiVersionReader.Combine(
new UrlSegmentApiVersionReader(),
new HeaderApiVersionReader(name),
new MediaTypeApiVersionReader(name));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

namespace PipelineBehaviorsDemo.Tests.IntegrationTests;

public class WebApiTests
public class IntegrationTests
{
[Theory]
[InlineData("api/v1/weathers/rome")]
[InlineData("api/v1/weathers/carthage")]
public async Task Should_Get_Weather_By_City_Returns_Ok(string route)
{
// arrange
var fixture = new WebApiTestFixture();
var fixture = new IntegrationWebApplicationFactory();
var client = fixture.CreateClient();

// act
Expand All @@ -29,7 +29,7 @@ public async Task Should_Get_Weather_By_City_Returns_Ok(string route)
public async Task Should_Get_Weather_By_City_Returns_BadRequest(string route)
{
// arrange
var fixture = new WebApiTestFixture();
var fixture = new IntegrationWebApplicationFactory();
var client = fixture.CreateClient();

// act
Expand All @@ -47,7 +47,7 @@ public async Task Should_Get_Weather_By_City_Returns_BadRequest(string route)
public async Task Should_Get_Weather_By_City_Returns_NotFound(string route)
{
// arrange
var fixture = new WebApiTestFixture();
var fixture = new IntegrationWebApplicationFactory();
var client = fixture.CreateClient();

// act
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PipelineBehaviorsDemo.Tests.IntegrationTests;

internal class WebApiTestFixture : WebApplicationFactory<Program>
internal class IntegrationWebApplicationFactory : WebApplicationFactory<Program>
{
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
Expand Down
10 changes: 5 additions & 5 deletions test/PipelineBehaviorsDemo.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.13" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.16" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector" Version="6.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down

0 comments on commit 098ff53

Please sign in to comment.