public void NotFailWithNoItemsNotificationNoCreditCard()
        {
            var paymentProcessor = new FakePaymentProcessor();
            var reservationService = new FakeReservationService();
            var notificationService = new FakeNotificationService();
            var cart = new Cart() { CustomerEmail = "*****@*****.**" };
            var paymentDetails = new PaymentDetails() { PaymentMethod = PaymentMethod.CreditCard };
            var order = new OnlineOrder(cart,
                                        paymentDetails,
                                        paymentProcessor,
                                        reservationService,
                                        notificationService);

            order.Checkout();

            // if I got here, I guess it worked...
        }
        public void SendTotalAmountToCreditCardProcessor()
        {
            var paymentProcessor = new FakePaymentProcessor();
            var reservationService = new FakeReservationService();
            var notificationService = new FakeNotificationService();
            var cart = new Cart {TotalAmount = 5.05m};
            var paymentDetails = new PaymentDetails()
            { PaymentMethod = PaymentMethod.CreditCard };
            var order = new OnlineOrder(cart,
                                        paymentDetails,
                                        paymentProcessor,
                                        reservationService,
                                        notificationService);

            order.Checkout();

            Assert.IsTrue(paymentProcessor.WasCalled);
            Assert.AreEqual(cart.TotalAmount, paymentProcessor.AmountPassed);
        }
        public void NotifyCustomerOrderCreated(Cart cart)
        {
            string customerEmail = cart.CustomerEmail;
            if (!String.IsNullOrEmpty(customerEmail))
            {
                using (var message = new MailMessage("*****@*****.**", customerEmail))
                using (var client = new SmtpClient("localhost"))
                {
                    message.Subject = "Your order placed on " + DateTime.Now;
                    message.Body = "Your order details: \n " + cart;

                    try
                    {
                        client.Send(message);
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("Problem sending notification email", ex);
                        throw;
                    }
                }
            }
        }
示例#4
0
 protected Order(Cart cart)
 {
     _cart = cart;
 }