public void Arrange() { _repo = new MenuItemRepository(); _newItem = new MenuItem(5, "Hard Taco Meal", "2 Hard Tacos", new List <string> { "tortilla", "meat", " cheese" }, 3.45); _repo.AddMenuItems(_newItem); // adding the menuItem newItem to the repository so the repository can preform the methods }
public void AddItemToMenu_ShouldReturnCorrect() { bool newItemAdded = _repo.AddMenuItems(_newItem); Assert.IsTrue(newItemAdded); }
public void AddNewItem() { Console.Clear(); MenuItem newItem = new MenuItem(); newItem.Ingredients = new List <string>(); // not rec Console.WriteLine("Please Enter the Number you wish to assign to the new menu item"); //newItem.MealNumber = (int.TryParse(Console.ReadLine(), out int result) ? result : 6) ; bool numberNotEntered = true; while (numberNotEntered) { if (int.TryParse(Console.ReadLine(), out int mealNumber)) // (true, false) { newItem.MealNumber = mealNumber; // .parse is quicker, tryparse converts to boolean; try check is away of catching an exception without blowing up. numberNotEntered = false; } else { Console.WriteLine("Please enter a valid number."); } } Console.WriteLine("Please enter the name of the menu item"); newItem.MealName = Console.ReadLine(); Console.WriteLine("Please enter a brief description of the meal"); newItem.Description = Console.ReadLine(); bool continueToAddIngredients = true; while (continueToAddIngredients) { Console.WriteLine("Would you like to add a new ingredient \n" + "Yes or no"); string answer = Console.ReadLine(); switch (answer.ToLower()) { case "yes": Console.WriteLine("Please enter a list of ingredients for the menu item"); string ingredientToadd = Console.ReadLine(); newItem.Ingredients.Add(ingredientToadd); break; case "no": continueToAddIngredients = false; break; default: Console.WriteLine("Press any key to continue"); break; } } Console.WriteLine("Please enter the cost of the new menu item"); newItem.Cost = Convert.ToDouble(Console.ReadLine()); _menuRepo.AddMenuItems(newItem); ; }