private static AtmClient Refill(int initQty) { var cash = Banknotes.Select(b => (b, initQty)).ToArray(); var atm = new AtmClient().Refill(cash); return(atm); }
public void CanWithdrawAll(int initQty) { if (Acceptable(initQty)) { AtmClient atm = Refill(initQty); atm.Withdraw(atm.AvailableAmount()).AvailableAmount().Should().Be(0); } }
public void CanRefill(int initQty) { if (Acceptable(initQty)) { AtmClient atm = Refill(initQty); // Amount should be valid after refill atm.AvailableAmount().Should().Be(Total(initQty)); // Banknotes should match what has been refilled atm.AvailableBanknotes().OrderBy(b => b).Should().Equal(Banknotes.OrderBy(b => b)); } }
public void CanWithdraw(int initQty, int withdrawQty) { if (Acceptable(initQty) && withdrawQty > 0 && withdrawQty < 20) { AtmClient atm = Refill(initQty); if (withdrawQty > initQty) { var initial = atm.AvailableAmount(); atm.Withdraw(Total(withdrawQty)).AvailableAmount().Should().Be(initial); } else { var initial = atm.AvailableAmount(); var withdrawn = Total(withdrawQty); atm.Withdraw(withdrawn).AvailableAmount().Should().Be(initial - withdrawn); } } }