public void InitializeTests() { // ????????? Is this running before each test ????????? CafeMenuRepository _cafeMenuRepo = new CafeMenuRepository(); List <MenuItem> allMenuItemsDeleted = _cafeMenuRepo.DeleteAllMenuItems(); // seed the repository with menu items with this constructor // public MenuItem(int mealNumber, string mealName, string mealDescription, string mealIngredients, decimal mealPrice) MenuItem seedMenuItem1 = new MenuItem(1, "Meal One", "The first meal on the menu", "One burger, One bun, One whiskey", 11.11m); MenuItem seedMenuItem2 = new MenuItem(2, "Meal Two", "The second meal on the menu", "Two burgers, Two buns, Two whiskeys", 22.22m); MenuItem seedMenuItem3 = new MenuItem(3, "Meal Three", "The third meal on the menu", "Three burgers, Three buns, Three whiskeys", 33.33m); MenuItem seedMenuItem4 = new MenuItem(4, "Meal Four", "The fourth meal on the menu", "Four burgers, Four buns, Four whiskeys", 44.44m); _cafeMenuRepo.AddItemToMenu(seedMenuItem1); _cafeMenuRepo.AddItemToMenu(seedMenuItem2); _cafeMenuRepo.AddItemToMenu(seedMenuItem3); _cafeMenuRepo.AddItemToMenu(seedMenuItem4); }
} // SeeAllMenuItems method private void DeleteTheMenu() { // DELETE ALL CONTENTS OF THE MENU LIST AND RETURN THE EMPTY LIST TO EMPTYLIST List <MenuItem> emptyList = _cafeMenuRepo.DeleteAllMenuItems(); // IF THE LIST IS EMPTY, THE DELETE WAS SUCCESSFUL if (emptyList.Count == 0) { Console.WriteLine("The menu has been cleared. All meals have been removed. \n" + "Press any key to continue..."); Console.ReadLine(); } else // THE DELETE FAILED { Console.WriteLine("There was a problem. /n" + "The menu wasn't cleared. All items have not been removed. \n" + "Press any key to continue..."); Console.ReadLine(); } } // DeleteTheMenu method
public void DeleteAllMenuItems_ShouldReturnEmptyList() { CafeMenuRepository _cafeMenuRepo = new CafeMenuRepository(); // Arrange // seed the repository with menu items with this constructor // public MenuItem(int mealNumber, string mealName, string mealDescription, string mealIngredients, decimal mealPrice) MenuItem seedMenuItem1 = new MenuItem(1, "Meal One", "The first meal on the menu", "One burger, One bun, One whiskey", 11.11m); MenuItem seedMenuItem2 = new MenuItem(2, "Meal Two", "The second meal on the menu", "Two burgers, Two buns, Two whiskeys", 22.22m); MenuItem seedMenuItem3 = new MenuItem(3, "Meal Three", "The third meal on the menu", "Three burgers, Three buns, Three whiskeys", 33.33m); MenuItem seedMenuItem4 = new MenuItem(4, "Meal Four", "The fourth meal on the menu", "Four burgers, Four buns, Four whiskeys", 44.44m); _cafeMenuRepo.AddItemToMenu(seedMenuItem1); _cafeMenuRepo.AddItemToMenu(seedMenuItem2); _cafeMenuRepo.AddItemToMenu(seedMenuItem3); _cafeMenuRepo.AddItemToMenu(seedMenuItem4); // Act List <MenuItem> allMenuItemsDeleted = _cafeMenuRepo.DeleteAllMenuItems(); // Assert Assert.AreEqual(allMenuItemsDeleted.Count, 0); }