Insert() private méthode

private Insert ( int index, MenuItem mi ) : void
index int
mi MenuItem
Résultat void
Exemple #1
0
        public void MenuItemCollection_Insert_IListNotMenuItem_ThrowsArgumentException(object value)
        {
            var   menu       = new SubMenu(new MenuItem[0]);
            IList collection = new Menu.MenuItemCollection(menu);

            Assert.Throws <ArgumentException>("value", () => collection.Insert(0, value));
        }
Exemple #2
0
        public void MenuItemCollection_Insert_IListInvoke_Success()
        {
            var   menu       = new SubMenu(new MenuItem[0]);
            IList collection = new Menu.MenuItemCollection(menu);

            var menuItem1 = new MenuItem("text1");

            collection.Insert(0, menuItem1);
            Assert.Same(menuItem1, Assert.Single(collection));
            Assert.Equal(menu, menuItem1.Parent);
            Assert.Equal(0, menuItem1.Index);

            var menuItem2 = new MenuItem("text1");

            collection.Insert(0, menuItem2);
            Assert.Equal(2, collection.Count);
            Assert.Same(menuItem2, collection[0]);
            Assert.Same(menuItem1, collection[1]);
            Assert.Equal(menu, menuItem1.Parent);
            Assert.Equal(1, menuItem1.Index);
            Assert.Equal(menu, menuItem2.Parent);
            Assert.Equal(0, menuItem2.Index);
        }