Exemple #1
0
        public void Insert()
        {
            var cut          = new SortedBindingList <Data>();
            var raisedEvents = new List <ListChangedEventArgs>();

            cut.ListChanged += (s, e) => raisedEvents.Add(e);

            var datas = AddData(cut, 5);
            var data  = new Data();

            const int index = 2;

            cut.Insert(index, data);
            var last = raisedEvents.Last();

            Assert.AreEqual(datas.Length + 1, cut.Count);

            Assert.AreEqual(data, cut[index]);

            Assert.AreEqual(ListChangedType.ItemAdded, last.ListChangedType);
            Assert.AreEqual(index, last.NewIndex);
        }