public void WillAddMenuItemToToolStripMenuItem() { Form f = new Form(); MenuStrip ms = new MenuStrip(); f.Controls.Add(ms); ms.Name = "MainMenu"; ToolStripMenuItem item = new ToolStripMenuItem(); item.Name = "Help"; ms.Items.Add(item); MenuItemData data = new MenuItemData(); data.Parent = "Help"; MenuExtensions.AddMenuItem(f, data); Assert.AreEqual(1, item.DropDownItems.Count); }
public void WillAddMenuItemToMenu_WhenParentIsNestedMenuItem() { Form f = new Form(); MenuStrip ms = new MenuStrip(); f.Controls.Add(ms); ms.Name = "MainMenu"; ToolStripMenuItem item = new ToolStripMenuItem(); item.Name = "Help"; ms.Items.Add(item); ToolStripMenuItem community = new ToolStripMenuItem(); community.Name = "Community"; item.DropDownItems.Add(community); MenuItemData data = new MenuItemData(); data.Parent = "Community"; MenuExtensions.AddMenuItem(f, data); Assert.AreEqual(1, community.DropDownItems.Count); }