public virtual void Test_CreateLeafMenuItems_ShouldCreatePanelWithLeafMenu() { //---------------Set up test pack------------------- HabaneroMenu habaneroMenu = new HabaneroMenu("Main"); string subMenuName = TestUtil.GetRandomString(); HabaneroMenu submenu = habaneroMenu.AddSubMenu(subMenuName); string menuItemName1 = TestUtil.GetRandomString(); submenu.AddMenuItem(menuItemName1); submenu.AddMenuItem(TestUtil.GetRandomString()); CollapsibleMenuBuilderVWG menuBuilder = (CollapsibleMenuBuilderVWG)CreateMenuBuilder(); IMenuItem menuItem = new CollapsibleSubMenuItemVWG(GetControlFactory(), "Some Sub Menu"); //---------------Assert Precondition---------------- Assert.AreEqual(0, menuItem.MenuItems.Count); ICollapsiblePanel menuItemAsControl = (ICollapsiblePanel)menuItem; Assert.AreEqual(1, menuItemAsControl.Controls.Count); Assert.AreEqual(2, submenu.MenuItems.Count); //---------------Execute Test ---------------------- menuBuilder.CreateLeafMenuItems(submenu, menuItem); //---------------Test Result ----------------------- Assert.AreEqual(2, menuItem.MenuItems.Count); Assert.AreEqual(2, menuItemAsControl.Controls.Count); IControlHabanero contentControl = menuItemAsControl.ContentControl; Assert.AreEqual(2, contentControl.Controls.Count); //Peter - 04/03/2010 - removed the assert below - the line that sets the Top is not working in this test, but the menu works in practice. //IControlHabanero firstControl = contentControl.Controls[0]; //IControlHabanero secondControl = contentControl.Controls[1]; //Assert.GreaterOrEqual(secondControl.Top, firstControl.Top + firstControl.Height); }
public virtual void Test_CreateSubMenuItems_ShouldCreatePanelWithLeafMenu() { //---------------Set up test pack------------------- HabaneroMenu habaneroMenu = new HabaneroMenu("Main"); string subMenuName = TestUtil.GetRandomString(); habaneroMenu.AddSubMenu(subMenuName); habaneroMenu.AddSubMenu("SecondSubMenu"); CollapsibleMenuBuilderVWG menuBuilder = (CollapsibleMenuBuilderVWG)CreateMenuBuilder(); IMenuItem menuItem = new CollapsibleSubMenuItemVWG(GetControlFactory(), "Some Sub Menu"); //---------------Assert Precondition---------------- Assert.AreEqual(0, menuItem.MenuItems.Count); ICollapsiblePanel menuItemAsControl = (ICollapsiblePanel)menuItem; Assert.AreEqual(1, menuItemAsControl.Controls.Count); Assert.AreEqual(2, habaneroMenu.Submenus.Count); //---------------Execute Test ---------------------- menuBuilder.BuildSubMenu(habaneroMenu, menuItem.MenuItems); //---------------Test Result ----------------------- Assert.AreEqual(2, menuItem.MenuItems.Count); Assert.AreEqual(1, menuItemAsControl.Controls.Count); }