public void ColumnHeaderCollection_RemoveAt_HasHandle_Success() { var listView = new ListView(); var collection = new ListView.ColumnHeaderCollection(listView); var header = new ColumnHeader(); collection.Add(header); collection.Add(new ColumnHeader()); collection.Add(new ColumnHeader()); collection.Add(new ColumnHeader()); Assert.NotEqual(IntPtr.Zero, listView.Handle); // Remove from start. collection.RemoveAt(0); Assert.Equal(3, collection.Count); Assert.Equal(0, collection[0].DisplayIndex); Assert.Equal(1, collection[1].DisplayIndex); Assert.Equal(2, collection[2].DisplayIndex); // Remove from middle. collection.RemoveAt(1); Assert.Equal(2, collection.Count); Assert.Equal(0, collection[0].DisplayIndex); Assert.Equal(1, collection[1].DisplayIndex); // Remove from end. collection.RemoveAt(1); Assert.Single(collection); Assert.Equal(0, collection[0].DisplayIndex); // Remove only. collection.RemoveAt(0); Assert.Empty(collection); Assert.Null(header.ListView); }
ColumnHeaderEx IList <ColumnHeaderEx> .this[int index] { get { return(this[index]); } set { if (index >= list.Count) { throw new IndexOutOfRangeException(); } list.RemoveAt(index); list.Insert(index, value); } }
public void ColumnHeaderCollection_RemoveAt_InvalidIndexEmpty_ThrowsArgumentOutOfRangeException(int index) { var listView = new ListView(); var collection = new ListView.ColumnHeaderCollection(listView); Assert.Throws <ArgumentOutOfRangeException>("index", () => collection.RemoveAt(index)); }