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); } }
public void TestCreateNewMenu() { SalesOrderLinqBroker target = new SalesOrderLinqBroker(); // TODO: Initialize to an appropriate value IMenuCategory cat = target.CreateMenuCategoryInstance(); IMenuType type = target.CreateMenuTypeInstance(); IMenu menu = target.CreateMenuInstance(); cat.MenuCategoryName = "Alam"; cat.MenuCategoryDescription = "Nature rules"; target.SaveMenuCategory(cat, "unit test"); type.MenuTypeName = "21"; type.MenuTypeDescription = "rumah"; target.SaveMenuType(type, "unit test"); menu.BasePrice = 200; menu.Price = 900; menu.MenuName = "matahari terbenanm"; menu.MenuCode = "MTB"; menu.MenuDescription = "description"; menu.MenuCategoryList.Add(cat); menu.MenuType = type; //menu.IsActive = true; //menu.IsDeleted = false; bool actual = target.SaveMenu(menu, "unit test"); Assert.AreEqual(actual, true); }
public void SaveMenuTest() { 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); var price = new Random().Next(10000); menu.BasePrice = price; bool expected = true; // TODO: Initialize to an appropriate value bool actual; actual = target.SaveMenu(menu, "unit test"); Assert.AreEqual(expected, actual); Assert.AreEqual(menu.BasePrice, price); //Assert.Inconclusive("Verify the correctness of this test method."); }