public void ShipApprovedOrder() { var initialOrder = new Order(); initialOrder.Id = 1; initialOrder.Status = OrderStatus.APPROVED; _orderRepository.AddOrder(initialOrder); OrderShipmentRequest request = new OrderShipmentRequest(); request.OrderId = 1; _orderShipment.Handle(request); _orderRepository.getLastSavedOrder().Status.Should().Be(OrderStatus.SHIPPED); _inMemShipmentService.getLastShippedOrder().Should().Be(initialOrder); }
public void SellMultipleItems() { // Setup var handler = new OrderCreation(_orderRepository, _productCatalog); var sellItemsRequest = new SellItemsRequest { Items = new List <SellItemRequest> { new SellItemRequest { ProductName = "salad", Quantity = 2 }, new SellItemRequest { ProductName = "tomato", Quantity = 3 }, } }; // Exercise handler.Handle(sellItemsRequest); // Verify var actual = _orderRepository.getLastSavedOrder(); actual.Total.Should().Be(23.20M); actual.Tax.Should().Be(2.13M); actual.Currency.Should().Be("EUR"); actual.Items.Count.Should().Be(2); actual.Items.Should().HaveCount(2); actual.Items.First().Product.Name.Should().Be("salad"); actual.Items.First().Product.Price.Should().Be(3.56M); actual.Items.First().Quantity.Should().Be(2); actual.Items.First().TaxedAmount.Should().Be(7.84M); actual.Items.First().Tax.Should().Be(0.72M); actual.Items.Last().Product.Name.Should().Be("tomato"); actual.Items.Last().Product.Price.Should().Be(4.65M); actual.Items.Last().Quantity.Should().Be(3); actual.Items.Last().TaxedAmount.Should().Be(15.36M); actual.Items.Last().Tax.Should().Be(1.41M); }
public void ApprovedExistingOrder() { var initialOrder = new Order(); initialOrder.Status = OrderStatus.CREATED; initialOrder.Id = 1; _orderRepository.AddOrder(initialOrder); var request = new OrderApprovalRequest(); request.OrderId = 1; request.Approved = true; _orderApproval.Handle(request); var savedOrder = _orderRepository.getLastSavedOrder(); savedOrder.Status.Should().Be(OrderStatus.APPROVED); }