public void CantVendIfLessThan50pOnTheCard(decimal cardBalance, bool canVend) { var cashCard = new CashCard(cardBalance); DebitResult debitResult; cashCard.TryDebit(0.00M, out debitResult); Assert.AreEqual(canVend, debitResult.IsDebited, "We were " + (canVend ? "NOT " : string.Empty) + "able to vend with a balance of " + cardBalance); }
public void CashCardBalanceIsDecrementedOnDebit(decimal amountToDebit, decimal expectedBalance) { const decimal InitialBalance = 100; var cashCard = new CashCard(InitialBalance); DebitResult debitResult; using (var transaction = cashCard.TryDebit(amountToDebit, out debitResult)) { if (debitResult.IsDebited) { transaction.Commit(); } } Assert.AreEqual(expectedBalance, cashCard.Balance, string.Format("Debit £{0} from £{1} should result in a balance of £{2}.", amountToDebit, InitialBalance, expectedBalance)); }