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); }
public void ChargeCard(PaymentDetails paymentDetails, Refactored.Cart cart) { using (var paymentGateway = new PaymentGateway()) { try { paymentGateway.Credentials = "account credentials"; paymentGateway.CardNumber = paymentDetails.CreditCardNumber; paymentGateway.ExpiresMonth = paymentDetails.ExpiresMonth; paymentGateway.ExpiresYear = paymentDetails.ExpiresYear; paymentGateway.NameOnCard = paymentDetails.CardholderName; paymentGateway.AmountToCharge = cart.TotalAmount(); paymentGateway.Charge(); } catch (AvsMismatchException ex) { throw new OrderException("The card gateway rejected the card based on the address provided.", ex); } catch (Exception ex) { throw new OrderException("There was a problem with your card.", ex); } } }
public void ZeroWhenEmpty() { Assert.AreEqual(0, _cart.TotalAmount()); }