public void GetAllDishes_ReturnsOrder_DishQuantityList() { Dish newDish = new Dish("Cesar Salad"); newDish.Save(); int dishId = newDish.GetId(); Dish newDish2 = new Dish("Eggs and bacon"); newDish2.Save(); int dishId2 = newDish2.GetId(); TableOrder newTableOrder = new TableOrder("4", new DateTime(2019, 3, 12)); newTableOrder.Save(); newTableOrder.AddDish(dishId, 2); newTableOrder.AddDish(dishId2, 1); List <DishQuantity> testList = new List <DishQuantity> { new DishQuantity(newDish, 2), new DishQuantity(newDish2, 1) }; List <DishQuantity> result = newTableOrder.GetAllDishes(); Console.WriteLine("{0} {1}", testList.Count, result.Count); Console.WriteLine("{0} {1}", testList[0].GetQuantity(), result[0].GetQuantity()); Console.WriteLine("{0} {1}", testList[1].GetQuantity(), result[1].GetQuantity()); CollectionAssert.AreEquivalent(testList, result); //Assert.AreEqual(testList.Count, result.Count); //Assert.AreEqual(2, result[0].GetQuantity()); }
public ActionResult Create(int tableOrderId, int dishId, int newDishQuantity) { TableOrder foundOrder = TableOrder.Find(tableOrderId); foundOrder.AddDish(dishId, newDishQuantity); return(RedirectToAction("Show")); }
public void GetNumberOfDishEntries_ReturnsDishQuantityfromToJointTable_Dish() { string name = "Eggs and Bacon"; string tableNumber = "4"; DateTime orderDate = new DateTime(2019, 3, 12); Dish newDish = new Dish(name); newDish.Save(); int dishId = newDish.GetId(); TableOrder newTableOrder = new TableOrder(tableNumber, orderDate); newTableOrder.Save(); newTableOrder.AddDish(dishId, 2); int countDishEntries = 2; int result = newTableOrder.GetDishQuantity(dishId); Assert.AreEqual(countDishEntries, result); }
public void UpdateDish_UpdatesDishQuantityInJointTable_Dish() { string name = "Eggs and Bacon"; string tableNumber = "4"; DateTime orderDate = new DateTime(2019, 3, 12); Dish newDish = new Dish(name); newDish.Save(); int dishId = newDish.GetId(); TableOrder newTableOrder = new TableOrder(tableNumber, orderDate); newTableOrder.Save(); newTableOrder.AddDish(dishId, 2); newTableOrder.UpdateDish(dishId, 3); List <DishQuantity> testList = new List <DishQuantity> { new DishQuantity(newDish, 3) }; List <DishQuantity> result = newTableOrder.GetAllDishes(); CollectionAssert.AreEqual(testList, result); }