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 WhenProductIsSelectedMachineDisplaysProductPriceThenStandardDisplay()
        {
            vendingService.SelectProduct(Item.Coke);
            Assert.That(vendingService.GetDisplay(), Is.EqualTo("PRICE £0.25"));

            Assert.That(vendingService.GetDisplay(), Is.EqualTo("INSERT COIN"));
        }
        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" }));
        }
Пример #4
0
 public void WhenSelectedProductIsOutOfStockThenDisplaySoldOut()
 {
     vendingService.SelectProduct(Item.Soda);
     Assert.That(vendingService.GetDisplay(), Is.EqualTo("SOLD OUT"));
 }