public void CreateAndStockVendingMachine() { var vm = new VendingService(); vm.AddStock(Item.Pepsi); vm.AddStock(Item.Soda); vm.AddStock(Item.Coke); this.vendingService = vm; }
public void WhenSelectedProductIsNotOutOfStockAndSufficientValueInsertedThenProductIsDispensedAndRemovedFromStock() { vendingService.AddStock(Item.Soda); vendingService.AcceptCoin("quarter"); vendingService.AcceptCoin("quarter"); vendingService.SelectProduct(Item.Soda); Assert.That(vendingService.GetDisplay(), Is.EqualTo("THANK YOU")); vendingService.SelectProduct(Item.Soda); Assert.That(vendingService.GetDisplay(), Is.EqualTo("SOLD OUT")); }
public void CustomerIsAbleToSelectProductAndReceiveChange() { var vendingService = new VendingService(); vendingService.AddStock(Item.Pepsi); vendingService.AcceptCoin("quarter"); vendingService.AcceptCoin("penny"); vendingService.AcceptCoin("quarter"); vendingService.AcceptCoin("dime"); vendingService.AcceptCoin("dime"); Assert.That(vendingService.GetDisplay(), Is.EqualTo("£0.71")); vendingService.SelectProduct(Item.Pepsi); Assert.That(vendingService.GetDisplay(), Is.EqualTo("THANK YOU")); Assert.That(vendingService.GetDisplay(), Is.EqualTo("INSERT COIN")); var change = vendingService.EmptyCoinReturn(); foreach (var coin in change) { vendingService.AcceptCoin(coin); } Assert.That(vendingService.GetDisplay(), Is.EqualTo("£0.36")); vendingService.SelectProduct(Item.Pepsi); Assert.That(vendingService.GetDisplay(), Is.EqualTo("SOLD OUT")); Assert.That(vendingService.GetDisplay(), Is.EqualTo("£0.36")); }
public void CustomerIsAbleToReturnCoinsAfterSelectingSoldOutProduct() { var vendingService = new VendingService(); vendingService.AddStock(Item.Pepsi); vendingService.AcceptCoin("quarter"); vendingService.AcceptCoin("quarter"); vendingService.AcceptCoin("quarter"); vendingService.AcceptCoin("quarter"); Assert.That(vendingService.GetDisplay(), Is.EqualTo("£1.00")); vendingService.SelectProduct(Item.Coke); Assert.That(vendingService.GetDisplay(), Is.EqualTo("SOLD OUT")); Assert.That(vendingService.GetDisplay(), Is.EqualTo("£1.00")); vendingService.ReturnCoins(); Assert.That(vendingService.EmptyCoinReturn(), Is.EquivalentTo(new[] { "quarter", "quarter", "quarter", "quarter" })); }