public async Task Ordering_with_credit_card_payment_through_PaymentGateway([Frozen] PaymentGateway paymentGateway, TestableHomeController sut, RestaurantDbContext setupDb) { // Given await setupDb.EnsureSeededAsync(); var orderItem = setupDb.MenuItems.First(); // When var result = sut.Order(new OrderBuilder(orderItem).WithCreditCard().Build()); // Then paymentGateway.Received().Pay(Arg.Any <CreditCard>(), Arg.Any <int>(), Arg.Any <decimal>()); }
public async Task Ordering_one_item_takes_correct_payment_amount([Frozen] PaymentGateway paymentGateway, TestableHomeController sut, RestaurantDbContext context) { // Given await context.EnsureSeededAsync(); var orderItem = context.MenuItems.First(); // When var result = sut.Order(new OrderBuilder(orderItem).Build()); // Then paymentGateway.Received().Pay(Arg.Any <PaymentProvider>(), Arg.Any <int>(), orderItem.Price); }
public async Task Ordering_multiple_items_takes_correct_payment_amount([Frozen] PaymentGateway paymentGateway, TestableHomeController sut, RestaurantDbContext context) { // Given await context.EnsureSeededAsync(); var orderItems = context.MenuItems.Take(3).ToList(); var totalPrice = orderItems.Aggregate(0m, (sum, item) => sum + item.Price); // When var result = sut.Order(new OrderBuilder(orderItems).Build()); // Then paymentGateway.Received().Pay(Arg.Any <PaymentProvider>(), Arg.Any <int>(), totalPrice); }
public async Task Ordering_successfully_shows_item_ordered_in_view(TestableHomeController sut, RestaurantDbContext setupDb) { // Given await setupDb.EnsureSeededAsync(); var orderItem = setupDb.MenuItems.First(); // When var result = sut.Order(new OrderBuilder(orderItem).Build()); // Then result .Should().BeAssignableTo <ViewResult>() .Which.Model.Should().BeAssignableTo <OrderCommandResult>() .Which.Ordered.Should().BeEquivalentTo(orderItem); }