public void TestChangeMenuCategory() { SalesOrderLinqBroker target = new SalesOrderLinqBroker(); // TODO: Initialize to an appropriate value //IMenu menu = Context.Menus.Where(m => m.MenuID == 5).FirstOrDefault(); // TODO: Initialize to an appropriate value IMenu menu = target.GetMenuById(5); menu.MenuCategoryList.Clear(); MenuCategory mc = new MenuCategory(); mc.MenuCategoryID = 2; MenuCategory mc2 = new MenuCategory(); mc2.MenuCategoryID = 10; //MenuCategory mc3 = new MenuCategory(); //mc3.MenuCategoryID = 5; //MenuCategory mc4 = new MenuCategory(); //mc4.MenuCategoryID = 7; //MenuCategory mc5 = new MenuCategory(); //mc5.MenuCategoryID = 6; menu.MenuCategoryList.Add(mc); menu.MenuCategoryList.Add(mc2); //menu.MenuCategoryList.Add(mc3); //menu.MenuCategoryList.Add(mc4); //menu.MenuCategoryList.Add(mc5); target.SaveMenu(menu, "unit test"); IList<IMenuCategory> actual = menu.MenuCategoryList.OrderBy(o => o.MenuCategoryID).ToList(); IList<IMenuCategory> expected = Context.MenuCategories.Cast<IMenuCategory>().OrderBy(o => o.MenuCategoryID).ToList(); expected = expected.Where(o => o.MenuCategoryID == 2 || o.MenuCategoryID == 10 //|| o.MenuCategoryID == 5 //|| o.MenuCategoryID == 7 //|| o.MenuCategoryID == 6 ).ToList(); Assert.AreEqual(expected.Count, actual.Count); IEnumerator<IMenuCategory> e1 = actual.GetEnumerator(); IEnumerator<IMenuCategory> e2 = expected.GetEnumerator(); while (e1.MoveNext() && e2.MoveNext()) { //Assert.AreEqual(e1.Current, e2.Current); Assert.AreEqual(e1.Current.MenuCategoryID, e2.Current.MenuCategoryID); Assert.AreEqual(e1.Current.MenuCategoryName, e2.Current.MenuCategoryName); Assert.AreEqual(e1.Current.MenuCategoryDescription, e2.Current.MenuCategoryDescription); Assert.AreEqual(e1.Current.MenuCategoryOrder, e2.Current.MenuCategoryOrder); Assert.AreEqual(e1.Current.IsDeleted, e2.Current.IsDeleted); Assert.AreEqual(e1.Current.RowGuid, e2.Current.RowGuid); } }
partial void UpdateMenuCategory(MenuCategory instance);
partial void DeleteMenuCategory(MenuCategory instance);
partial void InsertMenuCategory(MenuCategory instance);