public void Test_AddLeafMenuItem_ShouldIncreaseMinSizeOfCollapsiblePanel() { //---------------Set up test pack------------------- string name = TestUtil.GetRandomString(); HabaneroMenu.Item ownerItem = new HabaneroMenu.Item(null, name); CollapsibleSubMenuItemWin subMenuItem = new CollapsibleSubMenuItemWin(GetControlFactory(), ownerItem); CollapsibleMenuItemCollectionWin collapsibleMenuItemCollection = new CollapsibleMenuItemCollectionWin (subMenuItem); HabaneroMenu.Item item = new HabaneroMenu.Item(null, name); CollapsibleMenuItemWin menuLeafItem = new CollapsibleMenuItemWin(GetControlFactory(), item); //---------------Assert Precondition---------------- Assert.AreSame(subMenuItem, collapsibleMenuItemCollection.OwnerMenuItem); Assert.IsInstanceOf(typeof(CollapsibleMenuItemWin), menuLeafItem); Assert.AreEqual(subMenuItem.CollapseButton.Height, subMenuItem.MinimumSize.Height); //---------------Execute Test ---------------------- collapsibleMenuItemCollection.Add(menuLeafItem); //---------------Test Result ----------------------- int expectedHeight = subMenuItem.CollapseButton.Height + menuLeafItem.Height; Assert.AreEqual(expectedHeight, subMenuItem.Height); Assert.AreEqual (expectedHeight, subMenuItem.ExpandedHeight, "this will be zero untill the first time this is collapsed"); }
public void Test_AddLeafMenuItem_ShouldAddButtonToCollapsiblePanel() { //---------------Set up test pack------------------- string name = TestUtil.GetRandomString(); HabaneroMenu.Item ownerItem = new HabaneroMenu.Item(null, name); CollapsibleSubMenuItemWin subMenuItem = new CollapsibleSubMenuItemWin(GetControlFactory(), ownerItem); CollapsibleMenuItemCollectionWin collapsibleMenuItemCollection = new CollapsibleMenuItemCollectionWin (subMenuItem); HabaneroMenu.Item item = new HabaneroMenu.Item(null, name); CollapsibleMenuItemWin menuLeafItem = new CollapsibleMenuItemWin(GetControlFactory(), item); //---------------Assert Precondition---------------- Assert.AreSame(subMenuItem, collapsibleMenuItemCollection.OwnerMenuItem); Assert.IsInstanceOf(typeof(CollapsibleMenuItemWin), menuLeafItem); Assert.AreEqual(1, subMenuItem.Controls.Count, "CollapsiblePanel always has header button"); Assert.AreEqual(0, collapsibleMenuItemCollection.Count); //---------------Execute Test ---------------------- collapsibleMenuItemCollection.Add(menuLeafItem); //---------------Test Result ----------------------- Assert.AreEqual(1, collapsibleMenuItemCollection.Count); Assert.AreEqual(2, subMenuItem.Controls.Count, "Should have additional button control"); IControlHabanero contentControl = subMenuItem.ContentControl; Assert.IsInstanceOf(typeof(IPanel), contentControl); Assert.AreEqual(1, contentControl.Controls.Count); Assert.IsInstanceOf(typeof(IButton), contentControl.Controls[0]); }
public 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()); CollapsibleMenuBuilderWin menuBuilder = (CollapsibleMenuBuilderWin)CreateMenuBuilder(); IMenuItem menuItem = new CollapsibleSubMenuItemWin(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); IControlHabanero firstControl = contentControl.Controls[0]; IControlHabanero secondControl = contentControl.Controls[1]; Assert.GreaterOrEqual(secondControl.Top, firstControl.Top + firstControl.Height); }
public void Test_AddSubMenuItem_ShouldAddCollapsiblePanel() { //---------------Set up test pack------------------- string name = TestUtil.GetRandomString(); CollapsibleMenuWin menu = new CollapsibleMenuWin(); CollapsibleMenuItemCollectionWin collapsibleMenuItemCollection = new CollapsibleMenuItemCollectionWin(menu); HabaneroMenu.Item item = new HabaneroMenu.Item(null, name); IMenuItem menuLeafItem = new CollapsibleSubMenuItemWin(GetControlFactory(), item); //---------------Assert Precondition---------------- Assert.AreSame(menu, collapsibleMenuItemCollection.OwnerMenuItem); Assert.IsInstanceOf(typeof(CollapsibleSubMenuItemWin), menuLeafItem); Assert.AreEqual(0, collapsibleMenuItemCollection.Count); //---------------Execute Test ---------------------- collapsibleMenuItemCollection.Add(menuLeafItem); //---------------Test Result ----------------------- Assert.AreEqual(1, collapsibleMenuItemCollection.Count); Assert.AreEqual(1, menu.PanelsList.Count); ICollapsiblePanel collapsiblePanel = menu.PanelsList[0]; Assert.AreEqual(name, collapsiblePanel.Text); }
public void Test_CreateSubMenuItems_ShouldCreatePanelWithLeafMenu() { //---------------Set up test pack------------------- HabaneroMenu habaneroMenu = new HabaneroMenu("Main"); string subMenuName = TestUtil.GetRandomString(); habaneroMenu.AddSubMenu(subMenuName); habaneroMenu.AddSubMenu("SecondSubMenu"); CollapsibleMenuBuilderWin menuBuilder = (CollapsibleMenuBuilderWin)CreateMenuBuilder(); IMenuItem menuItem = new CollapsibleSubMenuItemWin(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); }