Beispiel #1
0
        public void PaymentProvider_OnUpdateCardBalance_UpdatesCardBalance()
        {
            IPaymentProvider paymentProvider =
                new CashCardPaymentProvider(
                    new CashCard(new Account("HSBC", "Avinash Jethani", new Payment(1m, CurrencyEnum.GBP)),
                                 "12345"));
            var isValid            = paymentProvider.IsValidPin("12345");
            var updatesCardBalance = paymentProvider.UpdateCardBalance(new Payment(0.5m, CurrencyEnum.GBP));

            Assert.That(isValid, Is.EqualTo(true));
            Assert.That(updatesCardBalance, Is.EqualTo(true));
            Assert.That(paymentProvider.CardBalance, Is.EqualTo(new Payment(0.5m, CurrencyEnum.GBP)));
        }
Beispiel #2
0
        public void SimpleVendingMachine_OnMultipleCashCardsLinkedtoSingleAccount_UpdatesAccountSuccessfully()
        {
            var account   = new Account("HSBC", "Avinash Jethani", new Payment(1000m, CurrencyEnum.GBP));
            var cashCard1 = new CashCard(account, "12345");
            var cashCard2 = new CashCard(account, "67890");
            IPaymentProvider paymentProvider1 = new CashCardPaymentProvider(cashCard1);
            IPaymentProvider paymentProvider2 = new CashCardPaymentProvider(cashCard2);

            SimpleVendingMachine machine = new SimpleVendingMachine();

            machine.SelectItem(ItemType.SoftDrink);
            machine.Vend(paymentProvider1, "12345");

            machine.SelectItem(ItemType.SoftDrink);
            machine.Vend(paymentProvider2, "67890");

            Assert.That(cashCard1.CurrentBalance, Is.EqualTo(new Payment(999m, CurrencyEnum.GBP)));
            Assert.That(cashCard2.CurrentBalance, Is.EqualTo(new Payment(999m, CurrencyEnum.GBP)));
            Assert.That(account.CurrentBalance, Is.EqualTo(new Payment(999m, CurrencyEnum.GBP)));
        }