static void Main(string[] args) { var withdrawalStrategy = new LargestBillsOnly(); var inventory = new AtmInventory(); inventory.ResetInventory(AtmInventory.DefaultInventory()); var atm = new AtmMachine(withdrawalStrategy, inventory); var commandFactory = new CommandFactory(); var done = false; do { var input = Console.ReadLine(); var command = commandFactory.CreateCommand(input); if (command.IsExit) { done = true; } else { command.Execute(atm); } } while (done != true); }
public void GivenEmptyInventoryWhenRestockedThenBalanceIsExpected() { // Arrange var sut = new AtmInventory(); var expectedInventory = CashTransaction.Start(); expectedInventory.Add(UnitedStatesTender.FiveDollar, 10); expectedInventory.Add(UnitedStatesTender.OneDollar, 10); // Act sut.ResetInventory(expectedInventory); // Assert var actual = sut.MachineBalance(); Assert.Equal <int>(60, actual.TotalAmount); Assert.Equal <int>(10, actual.BillCount(UnitedStatesTender.FiveDollar)); Assert.Equal <int>(10, actual.BillCount(UnitedStatesTender.OneDollar)); }
public void GivenStockedInventoryWhenRequestingInventoryByBillsThenOnlyBillsThatAreReuestedAreReturned() { // Arrange var sut = new AtmInventory(); var expectedInventory = CashTransaction.Start(); expectedInventory.Add(UnitedStatesTender.TenDollar, 1000); expectedInventory.Add(UnitedStatesTender.FiveDollar, 100); expectedInventory.Add(UnitedStatesTender.OneDollar, 10); sut.ResetInventory(expectedInventory); var billsToGet = new List <UnitedStatesTender>(); billsToGet.Add(UnitedStatesTender.OneDollar); billsToGet.Add(UnitedStatesTender.TenDollar); // Act var actual = sut.InventoryByBills(billsToGet); // Assert Assert.Equal <int>(1000, actual.BillCount(UnitedStatesTender.TenDollar)); Assert.Equal <int>(0, actual.BillCount(UnitedStatesTender.FiveDollar)); Assert.Equal <int>(10, actual.BillCount(UnitedStatesTender.OneDollar)); }
public override void Execute(IAtmMachine atm) { atm.Restock(AtmInventory.DefaultInventory()); DisplayBalance(atm.MachineBalance()); }