/// <summary> /// /// </summary> public VendingMachine() { string currentDirectory = Environment.CurrentDirectory; string navigateToEtc = Path.Combine(currentDirectory, @"..\..\..\etc\"); string fullPath = Path.Combine(navigateToEtc, "vendingmachine.csv"); using (StreamReader sr = new StreamReader(fullPath)) { while (!sr.EndOfStream) { string line = sr.ReadLine(); string[] lineArray = line.Split('|'); if (lineArray[3] == "Chip") { Inventory[lineArray[0]] = new Chip(lineArray[1], decimal.Parse(lineArray[2])); } if (lineArray[3] == "Candy") { Inventory[lineArray[0]] = new Candy(lineArray[1], decimal.Parse(lineArray[2])); } if (lineArray[3] == "Drink") { Inventory[lineArray[0]] = new Drink(lineArray[1], decimal.Parse(lineArray[2])); } if (lineArray[3] == "Gum") { Inventory[lineArray[0]] = new Gum(lineArray[1], decimal.Parse(lineArray[2])); } } } Report = new Report(Inventory); }
public void MakeSoundTests() { Chip testChip = new Chip("test", 10.00M); Candy testCandy = new Candy("test", 10.00M); Drink testDrink = new Drink("test", 10.00M); Gum testGum = new Gum("test", 10.00M); Assert.AreEqual("Crunch Crunch, Yum!", testChip.Sound); Assert.AreEqual("Munch Munch, Yum!", testCandy.Sound); Assert.AreEqual("Glug Glug, Yum!", testDrink.Sound); Assert.AreEqual("Chew Chew, Yum", testGum.Sound); }