public virtual void Test_AddLeafMenuItem_ShouldAddButtonToCollapsiblePanel() { //---------------Set up test pack------------------- string name = TestUtil.GetRandomString(); HabaneroMenu.Item ownerItem = new HabaneroMenu.Item(null, name); CollapsibleSubMenuItemVWG subMenuItem = new CollapsibleSubMenuItemVWG(GetControlFactory(), ownerItem); CollapsibleMenuItemCollectionVWG collapsibleMenuItemCollection = new CollapsibleMenuItemCollectionVWG (subMenuItem); HabaneroMenu.Item item = new HabaneroMenu.Item(null, name); CollapsibleMenuItemVWG menuLeafItem = new CollapsibleMenuItemVWG(GetControlFactory(), item); //---------------Assert Precondition---------------- Assert.AreSame(subMenuItem, collapsibleMenuItemCollection.OwnerMenuItem); Assert.IsInstanceOf(typeof(CollapsibleMenuItemVWG), 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]); Assert.AreEqual(menuLeafItem.Dock, DockStyleVWG.GetDockStyle(DockStyle.Top)); }
public virtual void Test_AddLeafMenuItem_ShouldIncreaseMinSizeOfCollapsiblePanel() { //---------------Set up test pack------------------- string name = TestUtil.GetRandomString(); HabaneroMenu.Item ownerItem = new HabaneroMenu.Item(null, name); CollapsibleSubMenuItemVWG subMenuItem = new CollapsibleSubMenuItemVWG(GetControlFactory(), ownerItem); CollapsibleMenuItemCollectionVWG collapsibleMenuItemCollection = new CollapsibleMenuItemCollectionVWG (subMenuItem); HabaneroMenu.Item item = new HabaneroMenu.Item(null, name); CollapsibleMenuItemVWG menuLeafItem = new CollapsibleMenuItemVWG(GetControlFactory(), item); //---------------Assert Precondition---------------- Assert.AreSame(subMenuItem, collapsibleMenuItemCollection.OwnerMenuItem); Assert.IsInstanceOf(typeof(CollapsibleMenuItemVWG), 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 virtual void Test_AddSubMenuItem_ShouldAddCollapsiblePanel() { //---------------Set up test pack------------------- string name = TestUtil.GetRandomString(); CollapsibleMenuVWG menu = new CollapsibleMenuVWG(); CollapsibleMenuItemCollectionVWG collapsibleMenuItemCollection = new CollapsibleMenuItemCollectionVWG(menu); HabaneroMenu.Item item = new HabaneroMenu.Item(null, name); IMenuItem menuLeafItem = new CollapsibleSubMenuItemVWG(GetControlFactory(), item); //---------------Assert Precondition---------------- Assert.AreSame(menu, collapsibleMenuItemCollection.OwnerMenuItem); Assert.IsInstanceOf(typeof(CollapsibleSubMenuItemVWG), 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); }