diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 742b808f..f399ead8 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -31,7 +31,7 @@ "rollForward": false }, "dotnet-ef": { - "version": "8.0.7", + "version": "8.0.8", "commands": [ "dotnet-ef" ], diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index fe5c24d6..1fd0712b 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -15,46 +15,49 @@ template: | $CHANGES **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION categories: - - title: ๐Ÿš€ Features - labels: - - feature - - title: โ™ป๏ธ Enhancement - labels: - - enhancement - - refactor - - title: ๐Ÿ› Bug Fixes - labels: - - fix - - bug - - title: ๐Ÿ‘ท CI - labels: - - ci - - title: โš ๏ธ Breaking Changes - labels: - - breaking-changes - - title: โ›”๏ธ Deprecated - labels: - - deprecated - - title: ๐Ÿ—‘ Removed - labels: - - removed - - title: ๐Ÿ” Security - labels: - - security - - title: ๐Ÿ“„ Documentation - labels: - - docs - - documentation - - title: ๐Ÿงฉ Dependency Updates - labels: - - deps - - dependencies - - title: ๐Ÿงฐ Maintenance - label: 'chore' - - title: ๐Ÿงบ Miscellaneous #Everything except ABAP - label: misc - - title: ๐Ÿšฉ Other changes -## putting no labels pr to `Other Changes` category with no label - https://github.com/release-drafter/release-drafter/issues/139#issuecomment-480473934 +- title: ๐Ÿš€ Features + labels: + - feature +- title: โ™ป๏ธ Enhancement + labels: + - enhancement + - refactor +- title: ๐Ÿ› Bug Fixes + labels: + - fix + - bug +- title: ๐Ÿ‘ท CI + labels: + - ci +- title: ๐Ÿงช Test + labels: + - test +- title: โš ๏ธ Breaking Changes + labels: + - breaking-changes +- title: โ›”๏ธ Deprecated + labels: + - deprecated +- title: ๐Ÿ—‘ Removed + labels: + - removed +- title: ๐Ÿ” Security + labels: + - security +- title: ๐Ÿ“„ Documentation + labels: + - docs + - documentation +- title: ๐Ÿงฉ Dependency Updates + labels: + - deps + - dependencies +- title: ๐Ÿงฐ Maintenance + label: 'chore' +- title: ๐Ÿงบ Miscellaneous #Everything except ABAP + label: misc +- title: ๐Ÿšฉ Other changes + ## putting no labels pr to `Other Changes` category with no label - https://github.com/release-drafter/release-drafter/issues/139#issuecomment-480473934 # https://www.trywilco.com/post/wilco-ci-cd-github-heroku @@ -64,52 +67,62 @@ categories: # Using regex for defining rules - https://regexr.com/ # https://stackoverflow.com/questions/58899999/regexp-to-match-conventional-commit-syntax autolabeler: - - label: 'chore' - branch: - - '(chore)(\([a-z ]+\))?\/.' - title: - - '^(chore)(\([a-z ]+\))?: .' - - label: 'bug' - branch: - - '(fix)(\([a-z ]+\))?\/.' - title: - - '^(fix)(\([a-z ]+\))?: .' - - label: 'feature' - branch: - - '(feat)(\([a-z ]+\))?\/.' - title: - - '^(feat)(\([a-z ]+\))?: .' - - label: 'ci/cd' - branch: - - '(ci)(\([a-z ]+\))?\/.' - title: - - '^(ci)(\([a-z ]+\))?: .' - - label: 'minor' - branch: - - '(feat)(\([a-z ]+\))?\/.' - title: - - '^(feat)(\([a-z ]+\))?: .' - - label: 'patch' - branch: - - '(fix)(\([a-z ]+\))?\/.' - - '(ci)(\([a-z ]+\))?\/.' - title: - - '^(fix)(\([a-z ]+\))?: .' - - '^(ci)(\([a-z ]+\))?: .' +- label: 'chore' + branch: + - '(chore)(\([a-z ]+\))?\/.' + title: + - '^(chore)(\([a-z ]+\))?: .' +- label: 'bug' + branch: + - '(fix)(\([a-z ]+\))?\/.' + title: + - '^(fix)(\([a-z ]+\))?: .' +- label: 'refactor' + branch: + - '(refactor)(\([a-z ]+\))?\/.' + title: + - '^(refactor)(\([a-z ]+\))?: .' +- label: 'test' + branch: + - '(test)(\([a-z ]+\))?\/.' + title: + - '^(test)(\([a-z ]+\))?: .' +- label: 'feature' + branch: + - '(feat)(\([a-z ]+\))?\/.' + title: + - '^(feat)(\([a-z ]+\))?: .' +- label: 'ci/cd' + branch: + - '(ci)(\([a-z ]+\))?\/.' + title: + - '^(ci)(\([a-z ]+\))?: .' +- label: 'minor' + branch: + - '(feat)(\([a-z ]+\))?\/.' + title: + - '^(feat)(\([a-z ]+\))?: .' +- label: 'patch' + branch: + - '(fix)(\([a-z ]+\))?\/.' + - '(ci)(\([a-z ]+\))?\/.' + title: + - '^(fix)(\([a-z ]+\))?: .' + - '^(ci)(\([a-z ]+\))?: .' change-template: '- $TITLE @$AUTHOR (#$NUMBER)' change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. version-resolver: major: labels: - - breaking-changes + - breaking-changes minor: labels: - - minor + - minor patch: labels: - - patch + - patch default: patch exclude-labels: - - skip-changelog +- skip-changelog diff --git a/package.json b/package.json index c4ab8112..fbc12334 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "food-delivery-microservices", "scripts": { "prepare": "husky && dotnet tool restore", - "install-dev-cert-bash": "curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v vs2019 -l ~/vsdbg" + "install-dev-cert-bash": "curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v vs2019 -l ~/vsdbg", + "upgrade-packages": "dotnet outdated food-delivery-microservices.sln" }, "repository": { "type": "git", diff --git a/src/BuildingBlocks/BuildingBlocks.Core/Exception/Types/InvalidAddressException.cs b/src/BuildingBlocks/BuildingBlocks.Core/Exception/Types/InvalidAddressException.cs deleted file mode 100644 index efd020ba..00000000 --- a/src/BuildingBlocks/BuildingBlocks.Core/Exception/Types/InvalidAddressException.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace BuildingBlocks.Core.Exception.Types; - -public class InvalidAddressException(string address) : BadRequestException($"Address: '{address}' is invalid.") -{ - public string Address { get; } = address; -} diff --git a/src/BuildingBlocks/BuildingBlocks.Core/Exception/Types/InvalidAmountException.cs b/src/BuildingBlocks/BuildingBlocks.Core/Exception/Types/InvalidAmountException.cs deleted file mode 100644 index dbd81a9a..00000000 --- a/src/BuildingBlocks/BuildingBlocks.Core/Exception/Types/InvalidAmountException.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace BuildingBlocks.Core.Exception.Types; - -public class InvalidAmountException(decimal amount) : BadRequestException($"Amount: '{amount}' is invalid.") -{ - public decimal Amount { get; } = amount; -} diff --git a/src/BuildingBlocks/BuildingBlocks.Core/Exception/Types/InvalidCurrencyException.cs b/src/BuildingBlocks/BuildingBlocks.Core/Exception/Types/InvalidCurrencyException.cs deleted file mode 100644 index 738846ad..00000000 --- a/src/BuildingBlocks/BuildingBlocks.Core/Exception/Types/InvalidCurrencyException.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace BuildingBlocks.Core.Exception.Types; - -public class InvalidCurrencyException(string currency) : BadRequestException($"Currency: '{currency}' is invalid.") -{ - public string Currency { get; } = currency; -} diff --git a/src/BuildingBlocks/BuildingBlocks.Core/Exception/Types/InvalidDateException.cs b/src/BuildingBlocks/BuildingBlocks.Core/Exception/Types/InvalidDateException.cs deleted file mode 100644 index 78f1df37..00000000 --- a/src/BuildingBlocks/BuildingBlocks.Core/Exception/Types/InvalidDateException.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace BuildingBlocks.Core.Exception.Types; - -public class InvalidDateException(DateTime date) : BadRequestException($"Date: '{date}' is invalid.") -{ - public DateTime Date { get; } = date; -} diff --git a/src/BuildingBlocks/BuildingBlocks.Core/Exception/Types/InvalidEmailException.cs b/src/BuildingBlocks/BuildingBlocks.Core/Exception/Types/InvalidEmailException.cs deleted file mode 100644 index 47663160..00000000 --- a/src/BuildingBlocks/BuildingBlocks.Core/Exception/Types/InvalidEmailException.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace BuildingBlocks.Core.Exception.Types; - -public class InvalidEmailException(string email) : BadRequestException($"Email: '{email}' is invalid.") -{ - public string Email { get; } = email; -} diff --git a/src/BuildingBlocks/BuildingBlocks.Core/Exception/Types/InvalidPhoneNumberException.cs b/src/BuildingBlocks/BuildingBlocks.Core/Exception/Types/InvalidPhoneNumberException.cs deleted file mode 100644 index 589e4446..00000000 --- a/src/BuildingBlocks/BuildingBlocks.Core/Exception/Types/InvalidPhoneNumberException.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace BuildingBlocks.Core.Exception.Types; - -public class InvalidPhoneNumberException(string phoneNumber) - : BadRequestException($"PhoneNumber: '{phoneNumber}' is invalid.") -{ - public string PhoneNumber { get; } = phoneNumber; -} diff --git a/src/BuildingBlocks/BuildingBlocks.Core/Web/Extensions/HostEnvironmentExtensions.cs b/src/BuildingBlocks/BuildingBlocks.Core/Web/Extensions/HostEnvironmentExtensions.cs index 342d36ae..bcdb93ad 100644 --- a/src/BuildingBlocks/BuildingBlocks.Core/Web/Extensions/HostEnvironmentExtensions.cs +++ b/src/BuildingBlocks/BuildingBlocks.Core/Web/Extensions/HostEnvironmentExtensions.cs @@ -4,9 +4,9 @@ namespace BuildingBlocks.Core.Web.Extensions; public static class HostEnvironmentExtensions { - public static bool IsTest(this IHostEnvironment env) => env.IsEnvironment("Test"); + public static bool IsTest(this IHostEnvironment env) => env.IsEnvironment(Environments.Test); - public static bool IsDependencyTest(this IHostEnvironment env) => env.IsEnvironment("DependencyTest"); + public static bool IsDependencyTest(this IHostEnvironment env) => env.IsEnvironment(Environments.DependencyTest); - public static bool IsDocker(this IHostEnvironment env) => env.IsEnvironment("Docker"); + public static bool IsDocker(this IHostEnvironment env) => env.IsEnvironment(Environments.Docker); } diff --git a/src/BuildingBlocks/BuildingBlocks.HealthCheck/BuildingBlocks.HealthCheck.csproj b/src/BuildingBlocks/BuildingBlocks.HealthCheck/BuildingBlocks.HealthCheck.csproj index 588a94a2..d7f502cf 100644 --- a/src/BuildingBlocks/BuildingBlocks.HealthCheck/BuildingBlocks.HealthCheck.csproj +++ b/src/BuildingBlocks/BuildingBlocks.HealthCheck/BuildingBlocks.HealthCheck.csproj @@ -31,13 +31,16 @@ + + + + - - - + + diff --git a/src/BuildingBlocks/BuildingBlocks.HealthCheck/DependencyInjectionExtensions.cs b/src/BuildingBlocks/BuildingBlocks.HealthCheck/DependencyInjectionExtensions.cs index e0ed7c91..a1271970 100644 --- a/src/BuildingBlocks/BuildingBlocks.HealthCheck/DependencyInjectionExtensions.cs +++ b/src/BuildingBlocks/BuildingBlocks.HealthCheck/DependencyInjectionExtensions.cs @@ -19,6 +19,8 @@ namespace BuildingBlocks.HealthCheck; // https://github.com/prometheus-net/prometheus-net public static class DependencyInjectionExtensions { + private static readonly string[] _defaultTags = ["live", "ready",]; + public static WebApplicationBuilder AddCustomHealthCheck( this WebApplicationBuilder builder, Action? healthChecksBuilder = null, @@ -38,10 +40,24 @@ public static WebApplicationBuilder AddCustomHealthCheck( var healCheckBuilder = builder .Services.AddHealthChecks() - .AddDiskStorageHealthCheck(_ => { }, tags: new[] { "live", "ready" }) - .AddPingHealthCheck(_ => { }, tags: new[] { "live", "ready" }) - .AddPrivateMemoryHealthCheck(512 * 1024 * 1024, tags: new[] { "live", "ready" }) - .AddDnsResolveHealthCheck(_ => { }, tags: new[] { "live", "ready" }) + .AddDiskStorageHealthCheck(_ => { }, tags: _defaultTags) + .AddPingHealthCheck(_ => { }, tags: _defaultTags) + .AddPrivateMemoryHealthCheck(512 * 1024 * 1024, tags: _defaultTags) + .AddDnsResolveHealthCheck(_ => { }, tags: _defaultTags) + .AddResourceUtilizationHealthCheck(o => + { + o.CpuThresholds = new ResourceUsageThresholds + { + DegradedUtilizationPercentage = 80, + UnhealthyUtilizationPercentage = 90, + }; + o.MemoryThresholds = new ResourceUsageThresholds + { + DegradedUtilizationPercentage = 80, + UnhealthyUtilizationPercentage = 90, + }; + o.SamplingWindow = TimeSpan.FromSeconds(5); + }) .ForwardToPrometheus(); healthChecksBuilder?.Invoke(healCheckBuilder); diff --git a/src/BuildingBlocks/BuildingBlocks.Integration.MassTransit/DependencyInjectionExtensions.cs b/src/BuildingBlocks/BuildingBlocks.Integration.MassTransit/DependencyInjectionExtensions.cs index e3c49b61..228edf01 100644 --- a/src/BuildingBlocks/BuildingBlocks.Integration.MassTransit/DependencyInjectionExtensions.cs +++ b/src/BuildingBlocks/BuildingBlocks.Integration.MassTransit/DependencyInjectionExtensions.cs @@ -9,6 +9,7 @@ using BuildingBlocks.Core.Messaging; using BuildingBlocks.Core.Reflection; using BuildingBlocks.Core.Reflection.Extensions; +using BuildingBlocks.Core.Web.Extensions; using Humanizer; using MassTransit; using Microsoft.AspNetCore.Builder; @@ -49,7 +50,7 @@ params Assembly[] scanAssemblies ? scanAssemblies : ReflectionUtilities.GetReferencedAssemblies(Assembly.GetCallingAssembly()).ToArray(); - if (!builder.Environment.IsEnvironment("test")) + if (!builder.Environment.IsTest()) { builder.Services.AddMassTransit(ConfiguratorAction); } diff --git a/src/BuildingBlocks/BuildingBlocks.Persistence.EfCore.Postgres/DbContextDesignFactoryBase.cs b/src/BuildingBlocks/BuildingBlocks.Persistence.EfCore.Postgres/DbContextDesignFactoryBase.cs index b449cae6..5c5332a1 100644 --- a/src/BuildingBlocks/BuildingBlocks.Persistence.EfCore.Postgres/DbContextDesignFactoryBase.cs +++ b/src/BuildingBlocks/BuildingBlocks.Persistence.EfCore.Postgres/DbContextDesignFactoryBase.cs @@ -1,4 +1,5 @@ using BuildingBlocks.Core.Persistence.EfCore; +using BuildingBlocks.Core.Web; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; @@ -14,7 +15,7 @@ public TDbContext CreateDbContext(string[] args) { Console.WriteLine($"BaseDirectory: {AppContext.BaseDirectory}"); - var environmentName = env ?? Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "test"; + var environmentName = env ?? Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? Environments.Test; var builder = new ConfigurationBuilder() .SetBasePath(AppContext.BaseDirectory ?? "") diff --git a/src/BuildingBlocks/BuildingBlocks.Validation/Extensions/ValidatorExtensions.cs b/src/BuildingBlocks/BuildingBlocks.Validation/Extensions/ValidatorExtensions.cs index ecc3b0ac..a31a4d53 100644 --- a/src/BuildingBlocks/BuildingBlocks.Validation/Extensions/ValidatorExtensions.cs +++ b/src/BuildingBlocks/BuildingBlocks.Validation/Extensions/ValidatorExtensions.cs @@ -20,7 +20,12 @@ public static async Task HandleValidationAsync( { var validationResult = await validator.ValidateAsync(request, cancellationToken).ConfigureAwait(false); if (!validationResult.IsValid) - throw new ValidationException(validationResult.ToValidationResultModel().Message); + { + throw new ValidationException( + validationResult.ToValidationResultModel().Errors?.FirstOrDefault()?.Message + ?? validationResult.ToValidationResultModel().Message + ); + } return request; } @@ -29,7 +34,12 @@ public static TRequest HandleValidation(this IValidator vali { var validationResult = validator.Validate(request); if (!validationResult.IsValid) - throw new ValidationException(validationResult.ToValidationResultModel().Message); + { + throw new ValidationException( + validationResult.ToValidationResultModel().Errors?.FirstOrDefault()?.Message + ?? validationResult.ToValidationResultModel().Message + ); + } return request; } diff --git a/src/BuildingBlocks/BuildingBlocks.Web/Problem/DependencyInjectionExtensions.cs b/src/BuildingBlocks/BuildingBlocks.Web/Problem/DependencyInjectionExtensions.cs index 374b71c6..5c45de6a 100644 --- a/src/BuildingBlocks/BuildingBlocks.Web/Problem/DependencyInjectionExtensions.cs +++ b/src/BuildingBlocks/BuildingBlocks.Web/Problem/DependencyInjectionExtensions.cs @@ -1,7 +1,5 @@ using System.Reflection; using BuildingBlocks.Abstractions.Web.Problem; -using BuildingBlocks.Core.Extensions.ServiceCollection; -using BuildingBlocks.Core.Reflection; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection.Extensions; using Scrutor; @@ -17,10 +15,7 @@ public static IServiceCollection AddCustomProblemDetails( params Assembly[] scanAssemblies ) { - var assemblies = - scanAssemblies.Length != 0 - ? scanAssemblies - : ReflectionUtilities.GetReferencedAssemblies(Assembly.GetCallingAssembly()).Distinct().ToArray(); + var assemblies = scanAssemblies.Length != 0 ? scanAssemblies : [Assembly.GetCallingAssembly()]; services.AddProblemDetails(configure); services.Replace(ServiceDescriptor.Singleton()); diff --git a/src/BuildingBlocks/BuildingBlocks.Web/Problem/ProblemDetailsService.cs b/src/BuildingBlocks/BuildingBlocks.Web/Problem/ProblemDetailsService.cs index 801a6c78..df1692c0 100644 --- a/src/BuildingBlocks/BuildingBlocks.Web/Problem/ProblemDetailsService.cs +++ b/src/BuildingBlocks/BuildingBlocks.Web/Problem/ProblemDetailsService.cs @@ -1,4 +1,5 @@ using BuildingBlocks.Abstractions.Web.Problem; +using Humanizer; using Microsoft.AspNetCore.Diagnostics; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -59,23 +60,37 @@ private void CreateProblemDetailFromException( IExceptionHandlerFeature exceptionFeature ) { - if (problemDetailMappers is { }) + if (problemDetailMappers is { } && problemDetailMappers.Any()) { foreach (var problemDetailMapper in problemDetailMappers) { - var mappedStatusCode = problemDetailMapper.GetMappedStatusCodes(exceptionFeature.Error); - if (mappedStatusCode > 0) - { - PopulateNewProblemDetail( - context.ProblemDetails, - context.HttpContext, - mappedStatusCode, - exceptionFeature.Error - ); - context.HttpContext.Response.StatusCode = mappedStatusCode; - } + MapProblemDetail(context, exceptionFeature, problemDetailMapper); } } + else + { + var defaultMapper = new DefaultProblemDetailMapper(); + MapProblemDetail(context, exceptionFeature, defaultMapper); + } + } + + private static void MapProblemDetail( + ProblemDetailsContext context, + IExceptionHandlerFeature exceptionFeature, + IProblemDetailMapper problemDetailMapper + ) + { + var mappedStatusCode = problemDetailMapper.GetMappedStatusCodes(exceptionFeature.Error); + if (mappedStatusCode > 0) + { + PopulateNewProblemDetail( + context.ProblemDetails, + context.HttpContext, + mappedStatusCode, + exceptionFeature.Error + ); + context.HttpContext.Response.StatusCode = mappedStatusCode; + } } private static void PopulateNewProblemDetail( @@ -86,7 +101,7 @@ Exception exception ) { // We should override ToString method in the exception for showing correct title. - existingProblemDetails.Title = exception.ToString(); + existingProblemDetails.Title = exception.GetType().Name.Humanize(LetterCasing.Title); existingProblemDetails.Detail = exception.Message; existingProblemDetails.Status = statusCode; existingProblemDetails.Instance = $"{httpContext.Request.Method} {httpContext.Request.Path}"; diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 67428ca6..073732c5 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -40,8 +40,6 @@ - - @@ -80,15 +78,18 @@ + + + - - - - - - - + + + + + + + diff --git a/src/Services/Customers/FoodDelivery.Services.Customers/Customers/Features/CreatingCustomer/v1/CreateCustomerEndpoint.cs b/src/Services/Customers/FoodDelivery.Services.Customers/Customers/Features/CreatingCustomer/v1/CreateCustomerEndpoint.cs index 57911213..6f9e3d9b 100644 --- a/src/Services/Customers/FoodDelivery.Services.Customers/Customers/Features/CreatingCustomer/v1/CreateCustomerEndpoint.cs +++ b/src/Services/Customers/FoodDelivery.Services.Customers/Customers/Features/CreatingCustomer/v1/CreateCustomerEndpoint.cs @@ -2,6 +2,7 @@ using BuildingBlocks.Abstractions.Web.MinimalApi; using BuildingBlocks.Web.Minimal.Extensions; using BuildingBlocks.Web.Problem.HttpResults; +using FoodDelivery.Services.Customers.Customers.Features.GettingCustomerByCustomerId.v1; using Humanizer; using Microsoft.AspNetCore.Http.HttpResults; @@ -36,7 +37,7 @@ public RouteHandlerBuilder MapEndpoint(IEndpointRouteBuilder builder) public async Task< Results, UnAuthorizedHttpProblemResult, ValidationProblem> - > HandleAsync(CreateCustomerRequestParameters requestParameters) + > HandleAsync([AsParameters] CreateCustomerRequestParameters requestParameters) { var (request, context, commandBus, cancellationToken) = requestParameters; @@ -48,8 +49,8 @@ public async Task< // https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis/openapi?view=aspnetcore-7.0#multiple-response-types return TypedResults.CreatedAtRoute( new CreateCustomerResponse(result.CustomerId), - nameof(GettingCustomerById), - new { id = result.CustomerId } + nameof(GetCustomerByCustomerId), + new { customerId = result.CustomerId } ); } } diff --git a/src/Services/Customers/FoodDelivery.Services.Customers/Customers/Features/UpdatingCustomer/v1/UpdateCustomerEndpoint.cs b/src/Services/Customers/FoodDelivery.Services.Customers/Customers/Features/UpdatingCustomer/v1/UpdateCustomerEndpoint.cs index 8784e64e..b5f9e386 100644 --- a/src/Services/Customers/FoodDelivery.Services.Customers/Customers/Features/UpdatingCustomer/v1/UpdateCustomerEndpoint.cs +++ b/src/Services/Customers/FoodDelivery.Services.Customers/Customers/Features/UpdatingCustomer/v1/UpdateCustomerEndpoint.cs @@ -26,7 +26,7 @@ public RouteHandlerBuilder MapEndpoint(IEndpointRouteBuilder builder) // .ProducesProblem("UnAuthorized request.", StatusCodes.Status401Unauthorized) } - public async Task HandleAsync(UpdateCustomerRequestParameters requestParameters) + public async Task HandleAsync([AsParameters] UpdateCustomerRequestParameters requestParameters) { var (request, id, context, commandBus, cancellationToken) = requestParameters; diff --git a/tests/Services/Customers/FoodDelivery.Services.Customers.EndToEndTests/Customers/Features/CreatingCustomer/v1/CreateCustomerTests.cs b/tests/Services/Customers/FoodDelivery.Services.Customers.EndToEndTests/Customers/Features/CreatingCustomer/v1/CreateCustomerTests.cs index 7591f9e1..a665e80a 100644 --- a/tests/Services/Customers/FoodDelivery.Services.Customers.EndToEndTests/Customers/Features/CreatingCustomer/v1/CreateCustomerTests.cs +++ b/tests/Services/Customers/FoodDelivery.Services.Customers.EndToEndTests/Customers/Features/CreatingCustomer/v1/CreateCustomerTests.cs @@ -6,6 +6,7 @@ using FoodDelivery.Services.Customers.Shared.Data; using FoodDelivery.Services.Customers.TestShared.Fakes.Customers.Entities; using FoodDelivery.Services.Customers.TestShared.Fakes.Customers.Requests; +using Humanizer; using Microsoft.AspNetCore.Mvc; using Tests.Shared.Extensions; using Tests.Shared.Fixtures; @@ -84,7 +85,7 @@ public async Task must_returns_conflict_status_code_when_customer_already_exists new { Detail = $"Customer with email '{fakeCustomer.Email.Value}' already exists.", - Title = nameof(CustomerAlreadyExistsException), + Title = nameof(CustomerAlreadyExistsException).Humanize(LetterCasing.Title), } ) .And.Be409Conflict(); @@ -106,7 +107,11 @@ public async Task must_returns_bad_request_status_code_when_email_is_invalid() response .Should() .ContainsProblemDetail( - new ProblemDetails { Detail = "Email address is invalid.", Title = nameof(ValidationException), } + new ProblemDetails + { + Detail = "Email address is invalid.", + Title = nameof(ValidationException).Humanize(LetterCasing.Title), + } ) .And.Be400BadRequest(); } diff --git a/tests/Services/Customers/FoodDelivery.Services.Customers.IntegrationTests/IntegrationTestConfigurations.cs b/tests/Services/Customers/FoodDelivery.Services.Customers.IntegrationTests/IntegrationTestConfigurations.cs index 1bda68b3..182c2d7f 100644 --- a/tests/Services/Customers/FoodDelivery.Services.Customers.IntegrationTests/IntegrationTestConfigurations.cs +++ b/tests/Services/Customers/FoodDelivery.Services.Customers.IntegrationTests/IntegrationTestConfigurations.cs @@ -1,5 +1,5 @@ +using BuildingBlocks.Core.Web; using Tests.Shared; -using Tests.Shared.Fixtures; namespace FoodDelivery.Services.Customers.IntegrationTests; @@ -7,6 +7,6 @@ public class IntegrationTestConfigurations : TestConfigurations { public IntegrationTestConfigurations() { - this["ASPNETCORE_ENVIRONMENT"] = "test"; + this["ASPNETCORE_ENVIRONMENT"] = Environments.Test; } }