Пример #1
0
 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_IListInsert_InvalidIndex_ThrowsArgumentOutOfRangeException(int index)
        {
            var   listView   = new ListView();
            IList collection = new ListView.ColumnHeaderCollection(listView);

            Assert.Throws <ArgumentOutOfRangeException>("index", () => collection.Insert(index, new ColumnHeader()));
        }
        public void ColumnHeaderCollection_Insert_InvalidIndex_ThrowsArgumentOutOfRangeException(int index)
        {
            using var listView = new ListView();
            var collection = new ListView.ColumnHeaderCollection(listView);

            Assert.Throws <ArgumentOutOfRangeException>("index", () => collection.Insert(index, (ColumnHeader)null));
        }
        public void ColumnHeaderCollection_IListInsert_InvalidItem_Nop(object value)
        {
            var   listView   = new ListView();
            IList collection = new ListView.ColumnHeaderCollection(listView);

            collection.Insert(0, value);
            Assert.Empty(collection);
        }
        public void ColumnHeaderCollection_Insert_NullItem_ThrowsArgumentNullException()
        {
            var listView   = new ListView();
            var collection = new ListView.ColumnHeaderCollection(listView);

            collection.Add(new ColumnHeader());
            Assert.Throws <ArgumentNullException>("ch", () => collection.Insert(1, (ColumnHeader)null));
        }
        public void ColumnHeaderCollection_Insert_String_Success(string text, string expectedText)
        {
            using var listView = new ListView();
            var collection = new ListView.ColumnHeaderCollection(listView);

            collection.Insert(0, text);
            using ColumnHeader header = Assert.Single(collection.Cast <ColumnHeader>());
            Assert.Equal(expectedText, header.Text);
            Assert.Equal(listView, header.ListView);
        }
        public void ColumnHeaderCollection_Insert_String_Success(string text)
        {
            var listView   = new ListView();
            var collection = new ListView.ColumnHeaderCollection(listView);

            collection.Insert(0, text);
            ColumnHeader header = Assert.Single(collection.Cast <ColumnHeader>());

            Assert.Equal(text ?? string.Empty, header.Text);
            Assert.Equal(listView, header.ListView);
        }
        public void ColumnHeaderCollection_IListInsert_ColumnHeader_Success()
        {
            var   listView   = new ListView();
            IList collection = new ListView.ColumnHeaderCollection(listView);
            var   header     = new ColumnHeader();

            collection.Add(new ColumnHeader());
            collection.Insert(1, header);
            Assert.Equal(2, collection.Count);
            Assert.Same(header, collection[1]);
            Assert.Same(listView, header.ListView);
        }
        public void ColumnHeaderCollection_Insert_String_Int_HorizontalAlignment_Success(string text, int width, HorizontalAlignment textAlign, string expectedText)
        {
            using var listView = new ListView();
            var collection = new ListView.ColumnHeaderCollection(listView);

            collection.Insert(0, text, width, textAlign);
            using ColumnHeader header = Assert.Single(collection.Cast <ColumnHeader>());
            Assert.Equal(expectedText, header.Text);
            Assert.Equal(width, header.Width);
            Assert.Equal(textAlign, header.TextAlign);
            Assert.Equal(listView, header.ListView);
        }
        public void ColumnHeaderCollection_Insert_String_Int_Success(string text, int width, string expectedText)
        {
            var listView   = new ListView();
            var collection = new ListView.ColumnHeaderCollection(listView);

            collection.Insert(0, text, width);
            ColumnHeader header = Assert.Single(collection.Cast <ColumnHeader>());

            Assert.Same(expectedText, header.Text);
            Assert.Equal(width, header.Width);
            Assert.Equal(listView, header.ListView);
        }
        public void ColumnHeaderCollection_Insert_String_String_Int_Success(string name, string text, int width)
        {
            var listView   = new ListView();
            var collection = new ListView.ColumnHeaderCollection(listView);

            collection.Insert(0, name, text, width);
            ColumnHeader header = Assert.Single(collection.Cast <ColumnHeader>());

            Assert.Equal(name ?? string.Empty, header.Name);
            Assert.Equal(text ?? string.Empty, header.Text);
            Assert.Equal(width, header.Width);
            Assert.Equal(listView, header.ListView);
        }
        public void ColumnHeaderCollection_Insert_String_String_Int_HorizontalAlignment_String_Success(string name, string text, int width, HorizontalAlignment textAlign, string imageKey, string expectedName, string expectedText, string expectedImageKey)
        {
            var listView   = new ListView();
            var collection = new ListView.ColumnHeaderCollection(listView);

            collection.Insert(0, name, text, width, textAlign, imageKey);
            ColumnHeader header = Assert.Single(collection.Cast <ColumnHeader>());

            Assert.Equal(expectedName, header.Name);
            Assert.Equal(expectedText, header.Text);
            Assert.Equal(width, header.Width);
            Assert.Equal(textAlign, header.TextAlign);
            Assert.Equal(expectedImageKey, header.ImageKey);
            Assert.Equal(listView, header.ListView);
        }
        public void ColumnHeaderCollection_Insert_String_String_Int_HorizontalAlignment_Int_Success(string name, string text, int width, HorizontalAlignment textAlign, int imageIndex)
        {
            var listView   = new ListView();
            var collection = new ListView.ColumnHeaderCollection(listView);

            collection.Insert(0, name, text, width, textAlign, imageIndex);
            ColumnHeader header = Assert.Single(collection.Cast <ColumnHeader>());

            Assert.Equal(name ?? string.Empty, header.Name);
            Assert.Equal(text ?? string.Empty, header.Text);
            Assert.Equal(width, header.Width);
            Assert.Equal(textAlign, header.TextAlign);
            Assert.Equal(imageIndex, header.ImageIndex);
            Assert.Equal(listView, header.ListView);
        }