Пример #1
0
        public async Task When_Adding_Order_Then_Creates_ProductOrders_In_Service(IList <ProductOrder> productsOrders)
        {
            // Arrange
            ProductOrderQueryServiceMock.Setup(x => x.CreateAsync(It.IsAny <IList <ProductWithCharmsOrderDto> >()))
            .ReturnsAsync(productsOrders);

            // Act
            await Sut.Handle(Request, default);

            // Assert
            ProductOrderQueryServiceMock.Verify(s => s.CreateAsync(Request.Products), Times.Once);
        }
Пример #2
0
        public async Task When_Adding_Order_Then_Adds_With_Service(User user, IList <ProductOrder> productOrders, Shipment shipment, Payment payment, Address address)
        {
            // Arrange
            UserQueryServiceMock.Setup(x => x.GetRawByIdAsync(It.IsAny <Guid>())).ReturnsAsync(user);
            ProductOrderQueryServiceMock.Setup(x => x.CreateAsync(It.IsAny <IList <ProductWithCharmsOrderDto> >())).ReturnsAsync(productOrders);
            ShipmentQueryServiceMock.Setup(x => x.GetRawAsync(It.IsAny <Guid>())).ReturnsAsync(shipment);
            OrderDiscountQueryServiceMock.Setup(x => x.GetRawByCodeAsync(It.IsAny <string>())).ReturnsAsync(OrderDiscount);
            AddressQueryServiceMock.Setup(x => x.GetAsync(It.IsAny <NewAddressDto>(), It.IsAny <Guid?>(), It.IsAny <Guid>())).ReturnsAsync(address);

            // Act
            await Sut.Handle(Request, default);

            // Assert
            OrderCommandServiceMock.Verify(x => x.CreateOrderAsync(user, productOrders, shipment, payment, OrderDiscount, Request.Comment, address));
        }