Esempio n. 1
0
        public void ListViewGroupCollection_RemoveAt_ValidIndex_Success()
        {
            using var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;
            var group = new ListViewGroup();

            collection.Add(group);
            collection.Add(new ListViewGroup());
            collection.Add(new ListViewGroup());
            collection.Add(new ListViewGroup());

            // Remove from start.
            collection.RemoveAt(0);
            Assert.Equal(3, collection.Count);

            // Remove from middle.
            collection.RemoveAt(1);
            Assert.Equal(2, collection.Count);

            // Remove from end.
            collection.RemoveAt(1);
            Assert.Single(collection);

            // Remove only.
            collection.RemoveAt(0);
            Assert.Empty(collection);
            Assert.Null(group.ListView);
        }
Esempio n. 2
0
        public void ListViewGroupCollection_RemoveAt_InvalidIndex_ThrowsArgumentOutOfRangeException(int index)
        {
            using var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;

            Assert.Throws <ArgumentOutOfRangeException>("index", () => collection.RemoveAt(index));
        }
        public void RemoveAtTest()
        {
            ListViewGroup obj  = new ListViewGroup("Item1");
            ListViewGroup obj2 = new ListViewGroup("Item2");

            grpCol.Add(obj);
            grpCol.Add(obj2);
            grpCol.RemoveAt(0);
            Assert.AreEqual(1, grpCol.Count, "#G1");
            Assert.AreEqual(true, grpCol.Contains(obj2), "#G2");
            Assert.AreEqual(null, obj.ListView, "#G3");
            Assert.AreEqual(lv, obj2.ListView, "#G4");
        }