Пример #1
0
        public void ManagedList_CheckCollectionRaiseEvent()
        {
            _managedList = new ManagedList <int>();
            _managedList.CollectionChanged += HandleCollectionChange;

            _managedList.Add(1);
            AssertChangeIsRaised(1);

            _managedList.AddRange(new List <int>()
            {
                2, 3, 4, 5, 6, 7, 8, 9
            });
            AssertChangeIsRaised(9);

            _managedList.Remove(3);
            AssertChangeIsRaised(8);

            _managedList.RemoveAt(2);
            AssertChangeIsRaised(7);

            _managedList.Insert(2, 3);
            AssertChangeIsRaised(8);

            _managedList.RemoveAll(s => s == 3);
            AssertChangeIsRaised(7);

            _managedList.RemoveRange(2, 3);
            AssertChangeIsRaised(4);

            _managedList.InsertRange(2, new List <int>()
            {
                1, 2, 3
            });
            AssertChangeIsRaised(7);

            _managedList.Clear();
            AssertChangeIsRaised(0);
        }