示例#1
0
                public void Should_set_order_state_to_inventory_reservation_failed()
                {
                    var subject = new OrderProcessor(InventoryService.Object, PaymentService.Object, NotificationService.Object);

                    subject.Checkout(Order);
                    Assert.That(Order.State, Is.EqualTo(OrderState.InventoryReservationFailed));
                }
示例#2
0
            public void Should_reserve_items_in_the_inventory()
            {
                var subject = new OrderProcessor(InventoryService.Object, PaymentService.Object, NotificationService.Object);

                subject.Checkout(Order);
                InventoryService.Verify(s => s.ReserveItems(Order.Cart.Items), Times.Once);
            }
示例#3
0
                    public void Reserved_items_should_be_shipped_to_user()
                    {
                        var subject = new OrderProcessor(InventoryService.Object, PaymentService.Object, NotificationService.Object);

                        subject.Checkout(Order);
                        InventoryService.Verify(s => s.HandoutItemsToDelivery(Order.Cart.Items), Times.Once);
                    }
示例#4
0
                    public void Checking_out_successfully_should_create_a_confirmation_to_the_user()
                    {
                        var subject = new OrderProcessor(InventoryService.Object, PaymentService.Object, NotificationService.Object);

                        subject.Checkout(Order);
                        NotificationService.Verify(s => s.NotifyCustomerOrderCreated(Order.Cart), Times.Once);
                    }
示例#5
0
                public void Should_throw_OrderFailedException()
                {
                    var subject = new OrderProcessor(InventoryService.Object, PaymentService.Object, NotificationService.Object);

                    Assert.That(() => subject.Checkout(Order), Throws.Exception.TypeOf <OrderFailedException>()
                                .And.InnerException.TypeOf <ItemReservationFailedException>()
                                .And.InnerException.Property("Items"));
                }
示例#6
0
            public void Checking_out_an_order_not_in_awaiting_process_state_throws_an_InvalidOperationException(OrderState orderState)
            {
                var subject = new OrderProcessor(InventoryService.Object, PaymentService.Object, NotificationService.Object);
                var alreadyProcessedOrder = new Order(OrderTestUtils.GetSimpleShoppingCart(), OrderTestUtils.GetSimplePaymentDetails())
                {
                    State = orderState
                };

                subject.Checkout(alreadyProcessedOrder);
            }
示例#7
0
            public void An_empty_shopping_cart_should_return_immediately()
            {
                var subject           = new OrderProcessor(InventoryService.Object, PaymentService.Object, NotificationService.Object);
                var emptyShoppingCart = new ShoppingCart(new Mock <IPriceCalculator>().Object)
                {
                    CurrentCustomer = null
                };
                var emptyOrder = new Order(emptyShoppingCart, new PaymentDetails());

                subject.Checkout(emptyOrder);
                InventoryService.Verify(s => s.ReserveItems(It.IsAny <IEnumerable <OrderItem> >()), Times.Never);
            }
示例#8
0
 public void The_user_should_not_be_charged()
 {
     try
     {
         var subject = new OrderProcessor(InventoryService.Object, PaymentService.Object, NotificationService.Object);
         subject.Checkout(Order);
     }
     catch { }
     finally
     {
         PaymentService.Verify(s => s.ProcessPayment(It.IsAny <PaymentDetails>(), It.IsAny <decimal>()),
                               Times.Never);
     }
 }
示例#9
0
 public void Should_put_back_reserved_items_to_the_inventory()
 {
     try
     {
         var subject = new OrderProcessor(InventoryService.Object, PaymentService.Object, NotificationService.Object);
         subject.Checkout(Order);
     }
     catch (Exception)
     {
     }
     finally
     {
         InventoryService.Verify(s => s.CancelReservation(Order.Cart.Items), Times.Once);
     }
 }
示例#10
0
 public void Should_call_charge_with_the_carts_total_value()
 {
     try
     {
         var subject = new OrderProcessor(InventoryService.Object, PaymentService.Object, NotificationService.Object);
         subject.Checkout(Order);
     }
     catch
     {
     }
     finally
     {
         PaymentService.Verify(s => s.ProcessPayment(Order.PaymentDetails, Order.Cart.GetTotalCost()), Times.Once);
     }
 }
示例#11
0
                public void The_item_reservation_exception_should_contain_the_items_that_could_not_be_reserved()
                {
                    var subject = new OrderProcessor(InventoryService.Object, PaymentService.Object, NotificationService.Object);

                    Assert.That(() => subject.Checkout(Order), Throws.InnerException.Property("Items").EqualTo(Order.Cart.Items));
                }
示例#12
0
                    public void Checking_out_should_not_throw()
                    {
                        var subject = new OrderProcessor(InventoryService.Object, PaymentService.Object, NotificationService.Object);

                        Assert.DoesNotThrow(() => subject.Checkout(Order));
                    }