diff --git a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/GlobalUsings.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/GlobalUsings.cs index 37ac7ade9..2fbd09b57 100644 --- a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/GlobalUsings.cs +++ b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/GlobalUsings.cs @@ -2,7 +2,6 @@ global using Grpc.Core.Interceptors; global using Grpc.Core; global using GrpcBasket; -global using GrpcOrdering; global using HealthChecks.UI.Client; global using Microsoft.AspNetCore.Authentication.JwtBearer; global using Microsoft.AspNetCore.Authentication; @@ -38,4 +37,4 @@ global using System.Text.Json; global using System.Threading.Tasks; global using System.Threading; global using System; -global using Microsoft.IdentityModel.Tokens; \ No newline at end of file +global using Microsoft.IdentityModel.Tokens; diff --git a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/OrderingService.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/OrderingService.cs index 2a7de50a7..6d46a706f 100644 --- a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/OrderingService.cs +++ b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Services/OrderingService.cs @@ -2,10 +2,10 @@ public class OrderingService : IOrderingService { - private readonly OrderingGrpc.OrderingGrpcClient _orderingGrpcClient; + private readonly GrpcOrdering.OrderingGrpc.OrderingGrpcClient _orderingGrpcClient; private readonly ILogger _logger; - public OrderingService(OrderingGrpc.OrderingGrpcClient orderingGrpcClient, ILogger logger) + public OrderingService(GrpcOrdering.OrderingGrpc.OrderingGrpcClient orderingGrpcClient, ILogger logger) { _orderingGrpcClient = orderingGrpcClient; _logger = logger; @@ -48,14 +48,14 @@ public class OrderingService : IOrderingService return data; } - private CreateOrderDraftCommand MapToOrderDraftCommand(BasketData basketData) + private GrpcOrdering.CreateOrderDraftCommand MapToOrderDraftCommand(BasketData basketData) { - var command = new CreateOrderDraftCommand + var command = new GrpcOrdering.CreateOrderDraftCommand { BuyerId = basketData.BuyerId, }; - basketData.Items.ForEach(i => command.Items.Add(new BasketItem + basketData.Items.ForEach(i => command.Items.Add(new GrpcOrdering.BasketItem { Id = i.Id, OldUnitPrice = (double)i.OldUnitPrice, diff --git a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Startup.cs b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Startup.cs index a7b5335c5..55b25cd62 100644 --- a/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Startup.cs +++ b/src/ApiGateways/Mobile.Bff.Shopping/aggregator/Startup.cs @@ -198,7 +198,7 @@ public static class ServiceCollectionExtensions services.AddScoped(); - services.AddGrpcClient((services, options) => + services.AddGrpcClient((services, options) => { var orderingApi = services.GetRequiredService>().Value.GrpcOrdering; options.Address = new Uri(orderingApi); diff --git a/src/ApiGateways/Web.Bff.Shopping/aggregator/GlobalUsings.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/GlobalUsings.cs index 75525a2a5..9aff586f4 100644 --- a/src/ApiGateways/Web.Bff.Shopping/aggregator/GlobalUsings.cs +++ b/src/ApiGateways/Web.Bff.Shopping/aggregator/GlobalUsings.cs @@ -2,7 +2,6 @@ global using Grpc.Core.Interceptors; global using Grpc.Core; global using GrpcBasket; -global using GrpcOrdering; global using HealthChecks.UI.Client; global using Microsoft.AspNetCore.Authentication; global using Microsoft.AspNetCore.Authorization; @@ -38,4 +37,4 @@ global using System.Threading.Tasks; global using System.Threading; global using System; global using Microsoft.IdentityModel.Tokens; -global using Serilog.Context; \ No newline at end of file +global using Serilog.Context; diff --git a/src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs index b589ec3cc..dc792b866 100644 --- a/src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs +++ b/src/ApiGateways/Web.Bff.Shopping/aggregator/Program.cs @@ -1,5 +1,4 @@ -var appName = "Web.Shopping.HttpAggregator"; -var builder = WebApplication.CreateBuilder(args); +var builder = WebApplication.CreateBuilder(args); builder.Host.UseSerilog(CreateSerilogLogger(builder.Configuration)); builder.Services.AddHealthChecks() @@ -197,7 +196,7 @@ public static class ServiceCollectionExtensions services.AddScoped(); - services.AddGrpcClient((services, options) => + services.AddGrpcClient((services, options) => { var orderingApi = services.GetRequiredService>().Value.GrpcOrdering; options.Address = new Uri(orderingApi); diff --git a/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/OrderingService.cs b/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/OrderingService.cs index afa86b31b..c9398179f 100644 --- a/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/OrderingService.cs +++ b/src/ApiGateways/Web.Bff.Shopping/aggregator/Services/OrderingService.cs @@ -2,10 +2,10 @@ public class OrderingService : IOrderingService { - private readonly OrderingGrpc.OrderingGrpcClient _orderingGrpcClient; + private readonly GrpcOrdering.OrderingGrpc.OrderingGrpcClient _orderingGrpcClient; private readonly ILogger _logger; - public OrderingService(OrderingGrpc.OrderingGrpcClient orderingGrpcClient, ILogger logger) + public OrderingService(GrpcOrdering.OrderingGrpc.OrderingGrpcClient orderingGrpcClient, ILogger logger) { _orderingGrpcClient = orderingGrpcClient; _logger = logger; @@ -48,14 +48,14 @@ public class OrderingService : IOrderingService return data; } - private CreateOrderDraftCommand MapToOrderDraftCommand(BasketData basketData) + private GrpcOrdering.CreateOrderDraftCommand MapToOrderDraftCommand(BasketData basketData) { - var command = new CreateOrderDraftCommand + var command = new GrpcOrdering.CreateOrderDraftCommand { BuyerId = basketData.BuyerId, }; - basketData.Items.ForEach(i => command.Items.Add(new BasketItem + basketData.Items.ForEach(i => command.Items.Add(new GrpcOrdering.BasketItem { Id = i.Id, OldUnitPrice = (double)i.OldUnitPrice, diff --git a/src/Services/Catalog/Catalog.API/Catalog.API.csproj b/src/Services/Catalog/Catalog.API/Catalog.API.csproj index 60d6addfd..7d778716b 100644 --- a/src/Services/Catalog/Catalog.API/Catalog.API.csproj +++ b/src/Services/Catalog/Catalog.API/Catalog.API.csproj @@ -14,7 +14,7 @@ - Always + PreserveNewest PreserveNewest @@ -25,10 +25,8 @@ PreserveNewest - - - - + + PreserveNewest diff --git a/src/Services/Ordering/Ordering.API/Application/Behaviors/TransactionBehaviour.cs b/src/Services/Ordering/Ordering.API/Application/Behaviors/TransactionBehavior.cs similarity index 87% rename from src/Services/Ordering/Ordering.API/Application/Behaviors/TransactionBehaviour.cs rename to src/Services/Ordering/Ordering.API/Application/Behaviors/TransactionBehavior.cs index e9deb1cf7..6974c3cf9 100644 --- a/src/Services/Ordering/Ordering.API/Application/Behaviors/TransactionBehaviour.cs +++ b/src/Services/Ordering/Ordering.API/Application/Behaviors/TransactionBehavior.cs @@ -2,15 +2,15 @@ using Microsoft.Extensions.Logging; -public class TransactionBehaviour : IPipelineBehavior where TRequest : IRequest +public class TransactionBehavior : IPipelineBehavior where TRequest : IRequest { - private readonly ILogger> _logger; + private readonly ILogger> _logger; private readonly OrderingContext _dbContext; private readonly IOrderingIntegrationEventService _orderingIntegrationEventService; - public TransactionBehaviour(OrderingContext dbContext, + public TransactionBehavior(OrderingContext dbContext, IOrderingIntegrationEventService orderingIntegrationEventService, - ILogger> logger) + ILogger> logger) { _dbContext = dbContext ?? throw new ArgumentException(nameof(OrderingContext)); _orderingIntegrationEventService = orderingIntegrationEventService ?? throw new ArgumentException(nameof(orderingIntegrationEventService)); diff --git a/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommand.cs b/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommand.cs index fb16306ee..6ff6bc40f 100644 --- a/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommand.cs +++ b/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderCommand.cs @@ -10,6 +10,7 @@ // https://docs.microsoft.com/dotnet/csharp/programming-guide/classes-and-structs/how-to-implement-a-lightweight-class-with-auto-implemented-properties using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Models; +using Microsoft.eShopOnContainers.Services.Ordering.API.Extensions; [DataContract] public class CreateOrderCommand @@ -80,21 +81,5 @@ public class CreateOrderCommand CardSecurityNumber = cardSecurityNumber; CardTypeId = cardTypeId; } - - - public record OrderItemDTO - { - public int ProductId { get; init; } - - public string ProductName { get; init; } - - public decimal UnitPrice { get; init; } - - public decimal Discount { get; init; } - - public int Units { get; init; } - - public string PictureUrl { get; init; } - } } diff --git a/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderDraftCommand.cs b/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderDraftCommand.cs index 4866212d9..caa6fb285 100644 --- a/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderDraftCommand.cs +++ b/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderDraftCommand.cs @@ -3,7 +3,6 @@ using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Models; public class CreateOrderDraftCommand : IRequest { - public string BuyerId { get; private set; } public IEnumerable Items { get; private set; } diff --git a/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderDraftCommandHandler.cs b/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderDraftCommandHandler.cs index be3860d5c..aaf982c29 100644 --- a/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderDraftCommandHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/Commands/CreateOrderDraftCommandHandler.cs @@ -1,6 +1,6 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands; -using static Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands.CreateOrderCommand; +using Microsoft.eShopOnContainers.Services.Ordering.API.Extensions; using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate; // Regular CommandHandler @@ -42,5 +42,19 @@ public record OrderDraftDTO Total = order.GetTotal() }; } +} + +public record OrderItemDTO +{ + public int ProductId { get; init; } + + public string ProductName { get; init; } -} \ No newline at end of file + public decimal UnitPrice { get; init; } + + public decimal Discount { get; init; } + + public int Units { get; init; } + + public string PictureUrl { get; init; } +} diff --git a/src/Services/Ordering/Ordering.API/Application/Commands/IdentifiedCommandHandler.cs b/src/Services/Ordering/Ordering.API/Application/Commands/IdentifiedCommandHandler.cs index 38c8a356d..43f6c8dcc 100644 --- a/src/Services/Ordering/Ordering.API/Application/Commands/IdentifiedCommandHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/Commands/IdentifiedCommandHandler.cs @@ -6,7 +6,7 @@ /// /// Type of the command handler that performs the operation if request is not duplicated /// Return value of the inner command handler -public class IdentifiedCommandHandler : IRequestHandler, R> +public abstract class IdentifiedCommandHandler : IRequestHandler, R> where T : IRequest { private readonly IMediator _mediator; @@ -18,19 +18,17 @@ public class IdentifiedCommandHandler : IRequestHandler> logger) { + ArgumentNullException.ThrowIfNull(logger); _mediator = mediator; _requestManager = requestManager; - _logger = logger ?? throw new System.ArgumentNullException(nameof(logger)); + _logger = logger; } /// /// Creates the result value to return if a previous request was found /// /// - protected virtual R CreateResultForDuplicateRequest() - { - return default(R); - } + protected abstract R CreateResultForDuplicateRequest(); /// /// This method handles the command. It just ensures that no other request exists with the same ID, and if this is the case diff --git a/src/Services/Ordering/Ordering.API/Application/Commands/SetStockConfirmedOrderStatusCommandHandler.cs b/src/Services/Ordering/Ordering.API/Application/Commands/SetStockConfirmedOrderStatusCommandHandler.cs index df87db63c..371e1540d 100644 --- a/src/Services/Ordering/Ordering.API/Application/Commands/SetStockConfirmedOrderStatusCommandHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/Commands/SetStockConfirmedOrderStatusCommandHandler.cs @@ -34,9 +34,9 @@ public class SetStockConfirmedOrderStatusCommandHandler : IRequestHandler +public class SetStockConfirmedOrderStatusIdentifiedCommandHandler : IdentifiedCommandHandler { - public SetStockConfirmedOrderStatusIdenfifiedCommandHandler( + public SetStockConfirmedOrderStatusIdentifiedCommandHandler( IMediator mediator, IRequestManager requestManager, ILogger> logger) diff --git a/src/Services/Ordering/Ordering.API/Application/Commands/SetStockRejectedOrderStatusCommandHandler.cs b/src/Services/Ordering/Ordering.API/Application/Commands/SetStockRejectedOrderStatusCommandHandler.cs index fcef729e6..59247db0d 100644 --- a/src/Services/Ordering/Ordering.API/Application/Commands/SetStockRejectedOrderStatusCommandHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/Commands/SetStockRejectedOrderStatusCommandHandler.cs @@ -35,9 +35,9 @@ public class SetStockRejectedOrderStatusCommandHandler : IRequestHandler +public class SetStockRejectedOrderStatusIdentifiedCommandHandler : IdentifiedCommandHandler { - public SetStockRejectedOrderStatusIdenfifiedCommandHandler( + public SetStockRejectedOrderStatusIdentifiedCommandHandler( IMediator mediator, IRequestManager requestManager, ILogger> logger) diff --git a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderCancelled/OrderCancelledDomainEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderCancelledDomainEventHandler.cs similarity index 97% rename from src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderCancelled/OrderCancelledDomainEventHandler.cs rename to src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderCancelledDomainEventHandler.cs index dd954c2ff..e53a233d9 100644 --- a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderCancelled/OrderCancelledDomainEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderCancelledDomainEventHandler.cs @@ -1,4 +1,4 @@ -namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers.OrderCancelled; +namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers; public class OrderCancelledDomainEventHandler : INotificationHandler diff --git a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderShipped/OrderShippedDomainEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderShippedDomainEventHandler.cs similarity index 97% rename from src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderShipped/OrderShippedDomainEventHandler.cs rename to src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderShippedDomainEventHandler.cs index 445c7e04f..aba9d8923 100644 --- a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderShipped/OrderShippedDomainEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderShippedDomainEventHandler.cs @@ -1,4 +1,4 @@ -namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers.OrderShipped; +namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers; public class OrderShippedDomainEventHandler : INotificationHandler diff --git a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderGracePeriodConfirmed/OrderStatusChangedToAwaitingValidationDomainEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStatusChangedToAwaitingValidationDomainEventHandler.cs similarity index 97% rename from src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderGracePeriodConfirmed/OrderStatusChangedToAwaitingValidationDomainEventHandler.cs rename to src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStatusChangedToAwaitingValidationDomainEventHandler.cs index 56ae38bba..e280d06c3 100644 --- a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderGracePeriodConfirmed/OrderStatusChangedToAwaitingValidationDomainEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStatusChangedToAwaitingValidationDomainEventHandler.cs @@ -1,4 +1,4 @@ -namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers.OrderGracePeriodConfirmed; +namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers; public class OrderStatusChangedToAwaitingValidationDomainEventHandler : INotificationHandler diff --git a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderPaid/OrderStatusChangedToPaidDomainEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStatusChangedToPaidDomainEventHandler.cs similarity index 90% rename from src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderPaid/OrderStatusChangedToPaidDomainEventHandler.cs rename to src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStatusChangedToPaidDomainEventHandler.cs index 2f2cf8e38..e5cc83a75 100644 --- a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderPaid/OrderStatusChangedToPaidDomainEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStatusChangedToPaidDomainEventHandler.cs @@ -1,4 +1,4 @@ -namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers.OrderPaid; +namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers; public class OrderStatusChangedToPaidDomainEventHandler : INotificationHandler @@ -10,10 +10,10 @@ public class OrderStatusChangedToPaidDomainEventHandler public OrderStatusChangedToPaidDomainEventHandler( - IOrderRepository orderRepository, ILoggerFactory logger, + IOrderRepository orderRepository, + ILoggerFactory logger, IBuyerRepository buyerRepository, - IOrderingIntegrationEventService orderingIntegrationEventService - ) + IOrderingIntegrationEventService orderingIntegrationEventService) { _orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); @@ -24,7 +24,7 @@ public class OrderStatusChangedToPaidDomainEventHandler public async Task Handle(OrderStatusChangedToPaidDomainEvent orderStatusChangedToPaidDomainEvent, CancellationToken cancellationToken) { _logger.CreateLogger() - .LogTrace("Order with Id: {OrderId} has been successfully updated to status {Status} ({Id})", + .LogInformation("Order with Id: {OrderId} has been successfully updated to status {Status} ({Id})", orderStatusChangedToPaidDomainEvent.OrderId, nameof(OrderStatus.Paid), OrderStatus.Paid.Id); var order = await _orderRepository.GetAsync(orderStatusChangedToPaidDomainEvent.OrderId); diff --git a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStockConfirmed/OrderStatusChangedToStockConfirmedDomainEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStatusChangedToStockConfirmedDomainEventHandler.cs similarity index 97% rename from src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStockConfirmed/OrderStatusChangedToStockConfirmedDomainEventHandler.cs rename to src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStatusChangedToStockConfirmedDomainEventHandler.cs index 142b6449d..00548c802 100644 --- a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStockConfirmed/OrderStatusChangedToStockConfirmedDomainEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStatusChangedToStockConfirmedDomainEventHandler.cs @@ -1,4 +1,4 @@ -namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers.OrderStockConfirmed; +namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers; public class OrderStatusChangedToStockConfirmedDomainEventHandler : INotificationHandler diff --git a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStartedEvent/SendEmailToCustomerWhenOrderStartedDomainEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/SendEmailToCustomerWhenOrderStartedDomainEventHandler.cs similarity index 88% rename from src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStartedEvent/SendEmailToCustomerWhenOrderStartedDomainEventHandler.cs rename to src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/SendEmailToCustomerWhenOrderStartedDomainEventHandler.cs index 720b656d6..7350c16cd 100644 --- a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStartedEvent/SendEmailToCustomerWhenOrderStartedDomainEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/SendEmailToCustomerWhenOrderStartedDomainEventHandler.cs @@ -1,4 +1,4 @@ -namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers.OrderStartedEvent; +namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers; public class SendEmailToCustomerWhenOrderStartedDomainEventHandler //: IAsyncNotificationHandler diff --git a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/BuyerAndPaymentMethodVerified/UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler.cs similarity index 96% rename from src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/BuyerAndPaymentMethodVerified/UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler.cs rename to src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler.cs index 919a78a45..5202bf50f 100644 --- a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/BuyerAndPaymentMethodVerified/UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler.cs @@ -1,4 +1,4 @@ -namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers.BuyerAndPaymentMethodVerified; +namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers; public class UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler : INotificationHandler diff --git a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStartedEvent/ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler.cs similarity index 92% rename from src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStartedEvent/ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler.cs rename to src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler.cs index da5037259..9940c5114 100644 --- a/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/OrderStartedEvent/ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/DomainEventHandlers/ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler.cs @@ -1,4 +1,4 @@ -namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers.OrderStartedEvent; +namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers; public class ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler : INotificationHandler @@ -22,9 +22,9 @@ public class ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler public async Task Handle(OrderStartedDomainEvent orderStartedEvent, CancellationToken cancellationToken) { - var cardTypeId = (orderStartedEvent.CardTypeId != 0) ? orderStartedEvent.CardTypeId : 1; + var cardTypeId = orderStartedEvent.CardTypeId != 0 ? orderStartedEvent.CardTypeId : 1; var buyer = await _buyerRepository.FindAsync(orderStartedEvent.UserId); - bool buyerOriginallyExisted = (buyer == null) ? false : true; + var buyerOriginallyExisted = buyer == null ? false : true; if (!buyerOriginallyExisted) { diff --git a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockConfirmedIntegrationEventHandler.cs b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockConfirmedIntegrationEventHandler.cs index 0c9557a5b..e5ed967a9 100644 --- a/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockConfirmedIntegrationEventHandler.cs +++ b/src/Services/Ordering/Ordering.API/Application/IntegrationEvents/EventHandling/OrderStockConfirmedIntegrationEventHandler.cs @@ -1,4 +1,4 @@ -namespace Ordering.API.Application.IntegrationEvents.EventHandling; +namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.IntegrationEvents.EventHandling; public class OrderStockConfirmedIntegrationEventHandler : IIntegrationEventHandler diff --git a/src/Services/Ordering/Ordering.API/Extensions/BasketItemExtensions.cs b/src/Services/Ordering/Ordering.API/Extensions/BasketItemExtensions.cs index 0f6122a13..4bf4f7575 100644 --- a/src/Services/Ordering/Ordering.API/Extensions/BasketItemExtensions.cs +++ b/src/Services/Ordering/Ordering.API/Extensions/BasketItemExtensions.cs @@ -1,6 +1,7 @@ -namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Models; +namespace Microsoft.eShopOnContainers.Services.Ordering.API.Extensions; using System.Collections.Generic; +using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Models; using static Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands.CreateOrderCommand; public static class BasketItemExtensions diff --git a/src/Services/Ordering/Ordering.API/GlobalUsings.cs b/src/Services/Ordering/Ordering.API/GlobalUsings.cs index 67ab88d35..e1cca922a 100644 --- a/src/Services/Ordering/Ordering.API/GlobalUsings.cs +++ b/src/Services/Ordering/Ordering.API/GlobalUsings.cs @@ -32,16 +32,15 @@ global using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Se global using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF; global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Behaviors; global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands; -global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers.OrderStartedEvent; -global using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.AutofacModules; -global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.IntegrationEvents.Events; +global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.DomainEventHandlers; global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.IntegrationEvents; +global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.IntegrationEvents.Events; +global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.IntegrationEvents.EventHandling; global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Models; global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Queries; global using Microsoft.eShopOnContainers.Services.Ordering.API.Application.Validations; global using Microsoft.eShopOnContainers.Services.Ordering.API.Controllers; global using Microsoft.eShopOnContainers.Services.Ordering.API.Extensions; -global using GrpcOrdering; global using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.ActionResults; global using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Filters; global using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Services; diff --git a/src/Services/Ordering/Ordering.API/Grpc/OrderingService.cs b/src/Services/Ordering/Ordering.API/Grpc/OrderingService.cs index 969a09d46..28f1a183d 100644 --- a/src/Services/Ordering/Ordering.API/Grpc/OrderingService.cs +++ b/src/Services/Ordering/Ordering.API/Grpc/OrderingService.cs @@ -1,4 +1,9 @@ -namespace GrpcOrdering; +using GrpcOrdering; + +using OrderDraftDTO = GrpcOrdering.OrderDraftDTO; +using CreateOrderDraftCommand = GrpcOrdering.CreateOrderDraftCommand; +using BasketItem = GrpcOrdering.BasketItem; +using OrderItemDTO = GrpcOrdering.OrderItemDTO; public class OrderingService : OrderingGrpc.OrderingGrpcBase { @@ -25,7 +30,6 @@ public class OrderingService : OrderingGrpc.OrderingGrpcBase createOrderDraftCommand.BuyerId, this.MapBasketItems(createOrderDraftCommand.Items)); - var data = await _mediator.Send(command); if (data != null) diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/ApplicationModule.cs b/src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/ApplicationModule.cs index 1ab775042..451b2b7d8 100644 --- a/src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/ApplicationModule.cs +++ b/src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/ApplicationModule.cs @@ -15,24 +15,6 @@ public class ApplicationModule protected override void Load(ContainerBuilder builder) { - builder.Register(c => new OrderQueries(QueriesConnectionString)) - .As() - .InstancePerLifetimeScope(); - - builder.RegisterType() - .As() - .InstancePerLifetimeScope(); - - builder.RegisterType() - .As() - .InstancePerLifetimeScope(); - - builder.RegisterType() - .As() - .InstancePerLifetimeScope(); - - builder.RegisterAssemblyTypes(typeof(CreateOrderCommandHandler).GetTypeInfo().Assembly) - .AsClosedTypesOf(typeof(IIntegrationEventHandler<>)); } } diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/MediatorModule.cs b/src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/MediatorModule.cs index 5aa77e06c..c343d8290 100644 --- a/src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/MediatorModule.cs +++ b/src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/MediatorModule.cs @@ -4,26 +4,6 @@ public class MediatorModule : Autofac.Module { protected override void Load(ContainerBuilder builder) { - builder.RegisterAssemblyTypes(typeof(IMediator).GetTypeInfo().Assembly) - .AsImplementedInterfaces(); - - // Register all the Command classes (they implement IRequestHandler) in assembly holding the Commands - builder.RegisterAssemblyTypes(typeof(CreateOrderCommand).GetTypeInfo().Assembly) - .AsClosedTypesOf(typeof(IRequestHandler<,>)); - - // Register the DomainEventHandler classes (they implement INotificationHandler<>) in assembly holding the Domain Events - builder.RegisterAssemblyTypes(typeof(ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler).GetTypeInfo().Assembly) - .AsClosedTypesOf(typeof(INotificationHandler<>)); - - // Register the Command's Validators (Validators based on FluentValidation library) - builder - .RegisterAssemblyTypes(typeof(CreateOrderCommandValidator).GetTypeInfo().Assembly) - .Where(t => t.IsClosedTypeOf(typeof(IValidator<>))) - .AsImplementedInterfaces(); - - builder.RegisterGeneric(typeof(LoggingBehavior<,>)).As(typeof(IPipelineBehavior<,>)); - builder.RegisterGeneric(typeof(ValidatorBehavior<,>)).As(typeof(IPipelineBehavior<,>)); - builder.RegisterGeneric(typeof(TransactionBehaviour<,>)).As(typeof(IPipelineBehavior<,>)); } } diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/IntegrationEventMigrations/IntegrationEventLogContextDesignTimeFactory.cs b/src/Services/Ordering/Ordering.API/Infrastructure/IntegrationEventMigrations/IntegrationEventLogContextDesignTimeFactory.cs index 3195d9714..52fe8f27a 100644 --- a/src/Services/Ordering/Ordering.API/Infrastructure/IntegrationEventMigrations/IntegrationEventLogContextDesignTimeFactory.cs +++ b/src/Services/Ordering/Ordering.API/Infrastructure/IntegrationEventMigrations/IntegrationEventLogContextDesignTimeFactory.cs @@ -1,4 +1,4 @@ -namespace Catalog.API.Infrastructure.IntegrationEventMigrations +namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.IntegrationEventMigrations { public class IntegrationEventLogContextDesignTimeFactory : IDesignTimeDbContextFactory { diff --git a/src/Services/Ordering/Ordering.API/Ordering.API.csproj b/src/Services/Ordering/Ordering.API/Ordering.API.csproj index 573ce2665..991dd07be 100644 --- a/src/Services/Ordering/Ordering.API/Ordering.API.csproj +++ b/src/Services/Ordering/Ordering.API/Ordering.API.csproj @@ -6,7 +6,8 @@ $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; ..\..\..\..\docker-compose.dcproj false - true + true + Microsoft.eShopOnContainers.Services.Ordering.API diff --git a/src/Services/Ordering/Ordering.API/Program.cs b/src/Services/Ordering/Ordering.API/Program.cs index a1a00bb31..8e3e8aa50 100644 --- a/src/Services/Ordering/Ordering.API/Program.cs +++ b/src/Services/Ordering/Ordering.API/Program.cs @@ -1,15 +1,5 @@ -using Autofac.Core; -using Microsoft.Azure.Amqp.Framing; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; +var builder = WebApplication.CreateBuilder(args); -var appName = "Ordering.API"; -var builder = WebApplication.CreateBuilder(new WebApplicationOptions -{ - Args = args, - ApplicationName = typeof(Program).Assembly.FullName, - ContentRootPath = Directory.GetCurrentDirectory() -}); if (builder.Configuration.GetValue("UseVault", false)) { TokenCredential credential = new ClientSecretCredential( @@ -18,24 +8,22 @@ if (builder.Configuration.GetValue("UseVault", false)) builder.Configuration["Vault:ClientSecret"]); builder.Configuration.AddAzureKeyVault(new Uri($"https://{builder.Configuration["Vault:Name"]}.vault.azure.net/"), credential); } -builder.Configuration.SetBasePath(Directory.GetCurrentDirectory()); -builder.Configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); -builder.Configuration.AddEnvironmentVariables(); + builder.WebHost.ConfigureKestrel(options => { - var ports = GetDefinedPorts(builder.Configuration); - options.Listen(IPAddress.Any, ports.httpPort, listenOptions => + var httpPort = builder.Configuration.GetValue("PORT", 80); + options.Listen(IPAddress.Any, httpPort, listenOptions => { listenOptions.Protocols = HttpProtocols.Http1AndHttp2; }); - options.Listen(IPAddress.Any, ports.grpcPort, listenOptions => + var grpcPort = builder.Configuration.GetValue("GRPC_PORT", 5001); + options.Listen(IPAddress.Any, grpcPort, listenOptions => { listenOptions.Protocols = HttpProtocols.Http2; }); - }); -builder.WebHost.CaptureStartupErrors(false); + builder.Host.UseSerilog(CreateSerilogLogger(builder.Configuration)); builder.Services .AddGrpc(options => @@ -58,8 +46,81 @@ builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory()); // Register your own things directly with Autofac here. Don't // call builder.Populate(), that happens in AutofacServiceProviderFactory // for you. -builder.Host.ConfigureContainer(conbuilder => conbuilder.RegisterModule(new MediatorModule())); -builder.Host.ConfigureContainer(conbuilder => conbuilder.RegisterModule(new ApplicationModule(builder.Configuration["ConnectionString"]))); + +var services = builder.Services; + + services.AddMediatR(cfg => + { + cfg.RegisterServicesFromAssemblyContaining(typeof(Program)); + + cfg.AddOpenBehavior(typeof(LoggingBehavior<,>)); + cfg.AddOpenBehavior(typeof(ValidatorBehavior<,>)); + cfg.AddOpenBehavior(typeof(TransactionBehavior<,>)); + }); + +/* + // Register all the command handlers. + services.AddSingleton, CancelOrderCommandHandler>(); + services.AddSingleton, bool>, CancelOrderIdentifiedCommandHandler>(); + + services.AddSingleton, CreateOrderCommandHandler>(); + services.AddSingleton, bool>, CreateOrderIdentifiedCommandHandler>(); + + services.AddSingleton, CreateOrderDraftCommandHandler>(); + + services.AddSingleton, bool>, SetAwaitingValidationIdentifiedOrderStatusCommandHandler>(); + services.AddSingleton, SetAwaitingValidationOrderStatusCommandHandler>(); + + services.AddSingleton, bool>, SetPaidIdentifiedOrderStatusCommandHandler>(); + services.AddSingleton, SetPaidOrderStatusCommandHandler>(); + + services.AddSingleton, bool>, SetStockConfirmedOrderStatusIdentifiedCommandHandler>(); + services.AddSingleton, SetStockConfirmedOrderStatusCommandHandler>(); + + services.AddSingleton, bool>, SetStockRejectedOrderStatusIdentifiedCommandHandler>(); + services.AddSingleton, SetStockRejectedOrderStatusCommandHandler>(); + + services.AddSingleton, bool>, ShipOrderIdentifiedCommandHandler>(); + services.AddSingleton, ShipOrderCommandHandler>(); + + // Register the DomainEventHandler classes (they implement INotificationHandler<>) in assembly holding the Domain Events + services.AddSingleton, OrderCancelledDomainEventHandler>(); + services.AddSingleton, OrderShippedDomainEventHandler>(); + services.AddSingleton, OrderStatusChangedToAwaitingValidationDomainEventHandler>(); + services.AddSingleton, OrderStatusChangedToPaidDomainEventHandler>(); + services.AddSingleton, OrderStatusChangedToStockConfirmedDomainEventHandler>(); + services.AddSingleton, UpdateOrderWhenBuyerAndPaymentMethodVerifiedDomainEventHandler>(); + services.AddSingleton, ValidateOrAddBuyerAggregateWhenOrderStartedDomainEventHandler>(); +*/ + + // Register the command validators for the validator behavior (validators based on FluentValidation library) + services.AddSingleton, CancelOrderCommandValidator>(); + services.AddSingleton, CreateOrderCommandValidator>(); + services.AddSingleton>, IdentifiedCommandValidator>(); + services.AddSingleton, ShipOrderCommandValidator>(); + +/* + // Build the MediatR pipeline + services.AddSingleton(typeof(IPipelineBehavior<,>), typeof(LoggingBehavior<,>)); + services.AddSingleton(typeof(IPipelineBehavior<,>), typeof(ValidatorBehavior<,>)); + services.AddSingleton(typeof(IPipelineBehavior<,>), typeof(TransactionBehavior<,>)); +*/ + +var queriesConnectionString = builder.Configuration["ConnectionString"]; + +services.AddScoped(sp => new OrderQueries(queriesConnectionString)); +services.AddScoped(); +services.AddScoped(); +services.AddScoped(); + +// Add integration event handlers. +services.AddSingleton, GracePeriodConfirmedIntegrationEventHandler>(); +services.AddSingleton, OrderPaymentFailedIntegrationEventHandler>(); +services.AddSingleton, OrderPaymentSucceededIntegrationEventHandler>(); +services.AddSingleton, OrderStockConfirmedIntegrationEventHandler>(); +services.AddSingleton, OrderStockRejectedIntegrationEventHandler>(); +services.AddSingleton, UserCheckoutAcceptedIntegrationEventHandler>(); + var app = builder.Build(); if (app.Environment.IsDevelopment()) { @@ -166,18 +227,13 @@ Serilog.ILogger CreateSerilogLogger(IConfiguration configuration) .ReadFrom.Configuration(configuration) .CreateLogger(); } -(int httpPort, int grpcPort) GetDefinedPorts(IConfiguration config) -{ - var grpcPort = config.GetValue("GRPC_PORT", 5001); - var port = config.GetValue("PORT", 80); - return (port, grpcPort); -} + public partial class Program { - - public static string Namespace = typeof(Program).Assembly.GetName().Name; + private static string Namespace = typeof(Program).Assembly.GetName().Name; public static string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1); } + static class CustomExtensionsMethods { public static IServiceCollection AddApplicationInsights(this IServiceCollection services, IConfiguration configuration) @@ -393,11 +449,10 @@ static class CustomExtensionsMethods { var serviceBusPersisterConnection = sp.GetRequiredService(); var logger = sp.GetRequiredService>(); - var eventBusSubcriptionsManager = sp.GetRequiredService(); + var eventBusSubscriptionsManager = sp.GetRequiredService(); string subscriptionName = configuration["SubscriptionClientName"]; - return new EventBusServiceBus(serviceBusPersisterConnection, logger, - eventBusSubcriptionsManager, sp, subscriptionName); + return new EventBusServiceBus(serviceBusPersisterConnection, logger, eventBusSubscriptionsManager, sp, subscriptionName); }); } else @@ -407,15 +462,14 @@ static class CustomExtensionsMethods var subscriptionClientName = configuration["SubscriptionClientName"]; var rabbitMQPersistentConnection = sp.GetRequiredService(); var logger = sp.GetRequiredService>(); - var eventBusSubcriptionsManager = sp.GetRequiredService(); + var eventBusSubscriptionsManager = sp.GetRequiredService(); - var retryCount = 5; - if (!string.IsNullOrEmpty(configuration["EventBusRetryCount"])) + if (!int.TryParse(configuration["EventBusRetryCount"], out var retryCount)) { - retryCount = int.Parse(configuration["EventBusRetryCount"]); + retryCount = 5; } - return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, sp, eventBusSubcriptionsManager, subscriptionClientName, retryCount); + return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, sp, eventBusSubscriptionsManager, subscriptionClientName, retryCount); }); } diff --git a/src/Services/Ordering/Ordering.FunctionalTests/Ordering.FunctionalTests.csproj b/src/Services/Ordering/Ordering.FunctionalTests/Ordering.FunctionalTests.csproj index 662bfa1f0..89f8910a2 100644 --- a/src/Services/Ordering/Ordering.FunctionalTests/Ordering.FunctionalTests.csproj +++ b/src/Services/Ordering/Ordering.FunctionalTests/Ordering.FunctionalTests.csproj @@ -6,16 +6,6 @@ false - - - - - - - Always - - - diff --git a/src/Services/Ordering/Ordering.SignalrHub/Program.cs b/src/Services/Ordering/Ordering.SignalrHub/Program.cs index ffbb5b8dc..03288fe33 100644 --- a/src/Services/Ordering/Ordering.SignalrHub/Program.cs +++ b/src/Services/Ordering/Ordering.SignalrHub/Program.cs @@ -1,5 +1,4 @@ -var appName = "Ordering.SignalrHub"; -var builder = WebApplication.CreateBuilder(new WebApplicationOptions +var builder = WebApplication.CreateBuilder(new WebApplicationOptions { Args = args, ApplicationName = typeof(Program).Assembly.FullName, diff --git a/src/Services/Ordering/Ordering.UnitTests/Application/IdentifiedCommandHandlerTest.cs b/src/Services/Ordering/Ordering.UnitTests/Application/IdentifiedCommandHandlerTest.cs index 1b7d38864..37755202c 100644 --- a/src/Services/Ordering/Ordering.UnitTests/Application/IdentifiedCommandHandlerTest.cs +++ b/src/Services/Ordering/Ordering.UnitTests/Application/IdentifiedCommandHandlerTest.cs @@ -27,7 +27,7 @@ public class IdentifiedCommandHandlerTest .Returns(Task.FromResult(true)); //Act - var handler = new IdentifiedCommandHandler(_mediator.Object, _requestManager.Object, _loggerMock.Object); + var handler = new CreateOrderIdentifiedCommandHandler(_mediator.Object, _requestManager.Object, _loggerMock.Object); var cltToken = new System.Threading.CancellationToken(); var result = await handler.Handle(fakeOrderCmd, cltToken); @@ -50,7 +50,7 @@ public class IdentifiedCommandHandlerTest .Returns(Task.FromResult(true)); //Act - var handler = new IdentifiedCommandHandler(_mediator.Object, _requestManager.Object, _loggerMock.Object); + var handler = new CreateOrderIdentifiedCommandHandler(_mediator.Object, _requestManager.Object, _loggerMock.Object); var cltToken = new System.Threading.CancellationToken(); var result = await handler.Handle(fakeOrderCmd, cltToken); diff --git a/src/Services/Ordering/Ordering.UnitTests/Application/OrdersWebApiTest.cs b/src/Services/Ordering/Ordering.UnitTests/Application/OrdersWebApiTest.cs index cfa14a3ec..748701891 100644 --- a/src/Services/Ordering/Ordering.UnitTests/Application/OrdersWebApiTest.cs +++ b/src/Services/Ordering/Ordering.UnitTests/Application/OrdersWebApiTest.cs @@ -29,7 +29,7 @@ public class OrdersWebApiTest var actionResult = await orderController.CancelOrderAsync(new CancelOrderCommand(1), Guid.NewGuid().ToString()) as OkResult; //Assert - Assert.Equal(actionResult.StatusCode, (int)System.Net.HttpStatusCode.OK); + Assert.Equal((int)System.Net.HttpStatusCode.OK, actionResult.StatusCode); } @@ -45,7 +45,7 @@ public class OrdersWebApiTest var actionResult = await orderController.CancelOrderAsync(new CancelOrderCommand(1), String.Empty) as BadRequestResult; //Assert - Assert.Equal(actionResult.StatusCode, (int)System.Net.HttpStatusCode.BadRequest); + Assert.Equal((int)System.Net.HttpStatusCode.BadRequest, actionResult.StatusCode); } [Fact] @@ -60,7 +60,7 @@ public class OrdersWebApiTest var actionResult = await orderController.ShipOrderAsync(new ShipOrderCommand(1), Guid.NewGuid().ToString()) as OkResult; //Assert - Assert.Equal(actionResult.StatusCode, (int)System.Net.HttpStatusCode.OK); + Assert.Equal((int)System.Net.HttpStatusCode.OK, actionResult.StatusCode); } @@ -76,7 +76,7 @@ public class OrdersWebApiTest var actionResult = await orderController.ShipOrderAsync(new ShipOrderCommand(1), String.Empty) as BadRequestResult; //Assert - Assert.Equal(actionResult.StatusCode, (int)System.Net.HttpStatusCode.BadRequest); + Assert.Equal((int)System.Net.HttpStatusCode.BadRequest, actionResult.StatusCode); } [Fact] diff --git a/src/Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj b/src/Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj index 712a3ecfb..3825af1b5 100644 --- a/src/Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj +++ b/src/Tests/Services/Application.FunctionalTests/Application.FunctionalTests.csproj @@ -20,12 +20,6 @@ - - PreserveNewest - - - PreserveNewest - Always diff --git a/src/eShopOnContainers-ServicesAndWebApps.sln b/src/eShopOnContainers-ServicesAndWebApps.sln index ccb68566d..68f32a4bf 100644 --- a/src/eShopOnContainers-ServicesAndWebApps.sln +++ b/src/eShopOnContainers-ServicesAndWebApps.sln @@ -9,6 +9,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{932D8224-11F EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3AF739CD-81D8-428D-A08A-0A58372DEBF6}" ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig .env = .env Directory.Packages.props = Directory.Packages.props NuGet.config = NuGet.config