public void UnknownProduct() { SellItemsRequest request = new SellItemsRequest(); request.SetRequests(new List <SellItemRequest>()); SellItemRequest unknownProductRequest = new SellItemRequest(); unknownProductRequest.SetProductName("unknown product"); request.GetRequests().Add(unknownProductRequest); Action act = () => useCase.Run(request); act.Should().Throw <UnknownProductException>(); }
public void maximumNumberOfFoodItemsExceededWithSingleQuantity() { SellItemsRequest tooManyFoodItemsRequest = new SellItemsRequest(); tooManyFoodItemsRequest.SetRequests(new List <SellItemRequest>()); for (int i = 0; i <= 100; i++) { SellItemRequest foodItemRequest = new SellItemRequest(); foodItemRequest.SetProductName("salad"); foodItemRequest.SetQuantity(1); tooManyFoodItemsRequest.GetRequests().Add(foodItemRequest); } Action act = () => useCase.Run(tooManyFoodItemsRequest); act.Should().Throw <MaximumNumberOfFoodItemsExceeded>(); }
public void MaximumNumberOfFoodItemsExceededWithMultipleQuantity() { SellItemsRequest tooManyFoodItemsRequest = new SellItemsRequest(); tooManyFoodItemsRequest.SetRequests(new List <SellItemRequest>()); SellItemRequest foodItemRequest = new SellItemRequest(); foodItemRequest.SetProductName("salad"); foodItemRequest.SetQuantity(30); tooManyFoodItemsRequest.GetRequests().Add(foodItemRequest); foodItemRequest = new SellItemRequest(); foodItemRequest.SetProductName("tomato"); foodItemRequest.SetQuantity(71); tooManyFoodItemsRequest.GetRequests().Add(foodItemRequest); Action act = () => useCase.Run(tooManyFoodItemsRequest); act.Should().Throw <MaximumNumberOfFoodItemsExceeded>(); }
public void SellMultipleItems() { SellItemRequest saladRequest = new SellItemRequest(); saladRequest.SetProductName("salad"); saladRequest.SetQuantity(2); SellItemRequest tomatoRequest = new SellItemRequest(); tomatoRequest.SetProductName("tomato"); tomatoRequest.SetQuantity(3); SellItemsRequest request = new SellItemsRequest(); request.SetRequests(new List <SellItemRequest>() { saladRequest, tomatoRequest }); useCase.Run(request); Order insertedOrder = orderRepository.GetSavedOrder(); insertedOrder.GetStatus().Should().Be(OrderStatus.Created); insertedOrder.GetTotal().Should().Be((decimal)23.20); insertedOrder.GetTax().Should().Be((decimal)2.13); insertedOrder.GetCurrency().Should().Be("EUR"); insertedOrder.GetItems().Should().HaveCount(2); insertedOrder.GetItems()[0].GetProduct().GetName().Should().Be("salad"); insertedOrder.GetItems()[0].GetProduct().GetPrice().Should().Be((decimal)3.56); insertedOrder.GetItems()[0].getQuantity().Should().Be(2); insertedOrder.GetItems()[0].GetTaxedAmount().Should().Be((decimal)7.84); insertedOrder.GetItems()[0].GetTax().Should().Be((decimal)0.72); insertedOrder.GetItems()[1].GetProduct().GetName().Should().Be("tomato"); insertedOrder.GetItems()[1].GetProduct().GetPrice().Should().Be((decimal)4.65); insertedOrder.GetItems()[1].getQuantity().Should().Be(3); insertedOrder.GetItems()[1].GetTaxedAmount().Should().Be((decimal)15.36); insertedOrder.GetItems()[1].GetTax().Should().Be((decimal)1.41); }