public void AddMenuItem_ItemWasAdded(int testnum) { MenuItem newItem = new MenuItem(); newItem.MealName = "chicken"; MenuItem newItemOne = new MenuItem(); newItemOne.MealName = "chicken"; MenuItem newItemTwo = new MenuItem(); newItemTwo.MealName = "chicken"; MenuItem newItemThree = new MenuItem(); newItemThree.MealName = "chicken"; _repo.AddMenuItem(newItem); _repo.AddMenuItem(newItemOne); _repo.AddMenuItem(newItemTwo); _repo.AddMenuItem(newItemThree); List <MenuItem> templist = _repo.ListAllMenuItems(); int expected = testnum; int actual = templist.Count; Assert.AreEqual(expected, actual); }
public void Arrange() { _list1 = new List <string>() { "chicken", "butter", "cheese" }; _list2 = new List <string>() { "pork", "bbq", "onions" }; _list3 = new List <string>() { "beef", "buns", "lettuce" }; _item1 = new MenuItem(1, "Butter Chicken", "It is buttery chicken", _list1, 7.85m); _item2 = new MenuItem(2, "BBQ Pork", "It is bbq pork", _list2, 10.25m); _item3 = new MenuItem(3, "Hamburger", "It's a hamburger", _list3, 6.75m); _repo = new MenuItemRepo(); _repo.AddMenuItem(_item1); _repo.AddMenuItem(_item2); _repo.AddMenuItem(_item3); }
public void TestAddMethod() { List <string> newIngredients = new List <string>() { "mac", "cheese", "butter" }; MenuItem newMenuItem = new MenuItem(4, "mac and cheese", "it is cheesy noodles", newIngredients, 10.55m); MenuItem falseMenuItem = new MenuItem(_item1); Assert.IsTrue(_repo.AddMenuItem(newMenuItem)); Assert.IsFalse(_repo.AddMenuItem(falseMenuItem)); List <MenuItem> addList = new List <MenuItem>(_repo.GetMenuList()); bool hasMenuItem = false; foreach (MenuItem item in addList) { if (item == newMenuItem) { hasMenuItem = true; break; } } Assert.IsTrue(hasMenuItem); }
public void AddNewItem() { Console.Clear(); bool keepRunning = true; while (keepRunning) { bool isValid = false; while (!isValid) { Console.WriteLine("Please enter name of menu item: "); string itemName = Console.ReadLine().ToLower(); if (_menuRepo.IsInMenu(itemName)) { Console.WriteLine("This name already exists in the menu."); } else { isValid = true; bool isValidMenuNum = false; while (!isValidMenuNum) { Console.WriteLine("Please enter item number"); int itemNum; bool isInt = GetNumberInput(out itemNum); if (isInt) { bool isAlreadyAssigned = _menuRepo.IsInMenu(itemNum); if (isAlreadyAssigned) { Console.WriteLine("Number already Assigned. Please choose a different number"); } else { isValidMenuNum = true; decimal price; bool isValidMenuPrice = false; while (!isValidMenuPrice) { Console.WriteLine("Please enter a price."); bool isDec = GetNumberInput(out price); if (isDec) { isValidMenuPrice = true; char[] separator = { ',' }; Console.WriteLine("Please enter a description for the menu item"); string description = Console.ReadLine(); Console.WriteLine("Please enter ingredients seperated by commas"); string ingredients = Console.ReadLine().ToLower().Trim(); string[] ingredientsArray = ingredients.Split(separator); List <string> ingredientsList = new List <string>(ingredientsArray); MenuItem newItem = new MenuItem(itemNum, itemName, description, ingredientsList, price); _menuRepo.AddMenuItem(newItem); keepRunning = false; } else { keepRunning = false; } } } } } } } } }