public static void Main(string[] args) { InitializeApp(); string keyPressed = ""; while (keyPressed != "X") { keyPressed = Console.ReadKey().Key.ToString(); if (new string[] { "P", "N", "D", "Q", "L" }.Contains(keyPressed)) { InsertCoin(keyPressed); UpdateDisplay(); } if (_session.GetProducts().Select(x => x.SelectionCode).Contains(keyPressed)) { bool isValid = _session.TryPurchaseProduct(keyPressed); UpdateDisplay(); if (isValid) { InitializeApp(); } } } Console.WriteLine("Goodbye!"); }
public void VendingMachineHasThreeProductsAvailable() { var products = _VendingSession.GetProducts(); Assert.Equal(products.Count, 3); Assert.Equal(true, products.Any(x => x.Name == "Cola" && x.Price == 1.00m)); Assert.Equal(true, products.Any(x => x.Name == "Chips" && x.Price == 0.50m)); Assert.Equal(true, products.Any(x => x.Name == "Candy" && x.Price == 0.65m)); }