public void OutOfStock(int productId)
        {
            products.Where(product => product.Id == productId).First().Stock = 0;
            var system = new VendingSystem(products, bankedCoins);

            system.PurchaseProduct(productId);
            Assert.Equal("SOLD OUT", system.Display);
        }
        public void PurchaseProduct(int productId)
        {
            var system = new VendingSystem(products, bankedCoins);

            system.TotalValue = 1.00m;

            system.PurchaseProduct(productId);
            Assert.Equal("THANK YOU", system.Display);
        }
        public void NotEnoughMoneyToPurchase(int productId, decimal initialMoney, string expectedDisplay)
        {
            var system = new VendingSystem(products, bankedCoins);

            system.TotalValue = initialMoney;

            system.PurchaseProduct(productId);
            Assert.Equal(expectedDisplay, system.Display);
        }
        public void ReturnsChange(decimal purchasePrice, decimal expectedChange)
        {
            var system = new VendingSystem(products, bankedCoins);

            system.TotalValue = 1.5m;

            var change = system.MakeChange(purchasePrice);

            Assert.Equal(expectedChange, change);
        }
        public void DispensesChangeNickelsAndDimes(decimal change, int expectedNumberOfDimes, int expectedNumberOfNickels)
        {
            var system = new VendingSystem(products, bankedCoins);

            system.CalculateChangeInCoins(change);
            var nickels = system.CoinsToDispense.Where(coins => coins.Key == CoinType.Nickel).FirstOrDefault();
            var dimes   = system.CoinsToDispense.Where(coins => coins.Key == CoinType.Dime).FirstOrDefault();

            Assert.Equal(expectedNumberOfNickels, nickels.Value);
            Assert.Equal(expectedNumberOfDimes, dimes.Value);
        }
        public void InsertCoinUpdatesCoinListAndValueAndDisplay(decimal coinWeight, decimal coinSize, CoinType expectedCoinType, decimal expectedValue)
        {
            var coin = new Coin(coinWeight, coinSize);

            var system = new VendingSystem(products, bankedCoins);

            system.InsertCoin(coin);

            Assert.True(system.InsertedCoins.Select(coin => coin.CoinType).First() == expectedCoinType);
            Assert.True(system.InsertedCoins.Select(coin => coin.Value).First() == expectedValue);
            Assert.Equal("$" + expectedValue.ToString("0.00"), system.Display);
        }
        public void InitiatesWithNoChangeNoNickelsOneDime()
        {
            bankedCoins = new List <Coin>
            {
                new Coin(2.268m, 17.91m)
            };

            var system = new VendingSystem(products, bankedCoins);

            Assert.Equal(products, system.Products);
            Assert.Equal("EXACT CHANGE ONLY", system.Display);
            Assert.True(system.NoChange);
        }
        public void InitiatesWithNoChangeTwoNickelsNoDimes()
        {
            bankedCoins = new List <Coin>
            {
                new Coin(5.000m, 21.21m),
                new Coin(5.000m, 21.21m),
            };

            var system = new VendingSystem(products, bankedCoins);

            Assert.Equal(products, system.Products);
            Assert.Equal("EXACT CHANGE ONLY", system.Display);
            Assert.True(system.NoChange);
        }
        public void ReturnsNoChange(decimal purchasePrice, decimal expectedChange)
        {
            bankedCoins = new List <Coin>
            {
                new Coin(5.000m, 21.21m),
                new Coin(5.000m, 21.21m),
            };

            var system = new VendingSystem(products, bankedCoins);

            system.TotalValue = 1.5m;

            var change = system.MakeChange(purchasePrice);

            Assert.Equal(expectedChange, change);
        }
        public void InitiatesWithChange()
        {
            var system = new VendingSystem(products, bankedCoins);

            Assert.False(system.NoChange);
        }
        public void Initiates()
        {
            var system = new VendingSystem(products, bankedCoins);

            Assert.Equal(products, system.Products);
        }
        public void StartsWithNoTotalValue()
        {
            var system = new VendingSystem(products, bankedCoins);

            Assert.Equal(0.00m, system.TotalValue);
        }
        public void StartsWithNoCoins()
        {
            var system = new VendingSystem(products, bankedCoins);

            Assert.Empty(system.InsertedCoins);
        }
        public void StartsWithInsertCoinDisplay()
        {
            var system = new VendingSystem(products, bankedCoins);

            Assert.Equal("INSERT COIN", system.Display);
        }