Exemple #1
0
        public void SendTotalAmountToCreditCardProcessor()
        {
            var paymentProcessor    = new FakePaymentProcessor();
            var reservationService  = new FakeReservationService();
            var notificationService = new FakeNotificationService();

            _cart.Add(new OrderItem()
            {
                Quantity = 5, Sku = "B4GO_APPLE"
            });
            _cart.Add(new OrderItem()
            {
                Quantity = 6, Sku = "SPECIAL_CANDYBAR"
            });
            var paymentDetails = new PaymentDetails()
            {
                PaymentMethod = PaymentMethod.CreditCard
            };
            var order = new LosselyCoupled.OnlineOrder(_cart,
                                                       paymentDetails,
                                                       paymentProcessor,
                                                       reservationService,
                                                       notificationService);

            order.Checkout();

            Assert.IsTrue(paymentProcessor.WasCalled);
            Assert.AreEqual(_cart.TotalAmount(), paymentProcessor.AmountPassed);
        }
Exemple #2
0
        public void NotFailWithNoItemsNotificationNoCreditCard()
        {
            var paymentProcessor    = new FakePaymentProcessor();
            var reservationService  = new FakeReservationService();
            var notificationService = new NotificationService();
            var cart = new Refactored.Cart()
            {
                CustomerEmail = "*****@*****.**"
            };
            var paymentDetails = new PaymentDetails()
            {
                PaymentMethod = PaymentMethod.CreditCard
            };
            var order = new LosselyCoupled.OnlineOrder(cart,
                                                       paymentDetails,
                                                       paymentProcessor,
                                                       reservationService,
                                                       notificationService);

            order.Checkout();

            // if I got here, I guess it worked...
        }