Esempio n. 1
0
        public void EndUpdate_NestedUpdates_CollectionChangedRaised()
        {
            var collectionChangedEventArgsList = new List <NotifyCollectionChangedEventArgs>();

            var collection = new ExtendedObservableCollection <int>();

            collection.CollectionChanged += (_, args) => collectionChangedEventArgsList.Add(args);

            collection.BeginUpdate();

            collection.Add(1234);

            collection.BeginUpdate();

            collection.Add(5678);

            collection.EndUpdate();

            Assert.Empty(collectionChangedEventArgsList);

            collection.EndUpdate();

            Assert.Equal(2, collection.Count);
            Assert.Single(collectionChangedEventArgsList);
            Assert.Equal(NotifyCollectionChangedAction.Reset, collectionChangedEventArgsList[0].Action);
        }
Esempio n. 2
0
        public void EndUpdate_NoUpdateMade_NoCollectionChangedRaised()
        {
            var collectionChangedEventArgsList = new List <NotifyCollectionChangedEventArgs>();

            var collection = new ExtendedObservableCollection <int>();

            collection.CollectionChanged += (_, args) => collectionChangedEventArgsList.Add(args);

            collection.BeginUpdate();
            collection.EndUpdate();

            Assert.Empty(collection);
            Assert.Empty(collectionChangedEventArgsList);
        }
Esempio n. 3
0
        public void EndUpdate_EndUpdateAfterBeginUpdate_NoCollectionChangedRaised()
        {
            var collectionChangedEventArgsList = new List <NotifyCollectionChangedEventArgs>();

            var collection = new ExtendedObservableCollection <int> {
                135, 123, 456, 789
            };

            collection.CollectionChanged += (_, args) => collectionChangedEventArgsList.Add(args);

            collection.BeginUpdate();
            collection.Add(42);

            Assert.Empty(collectionChangedEventArgsList);

            collection.EndUpdate();

            Assert.Single(collectionChangedEventArgsList);
            Assert.Equal(NotifyCollectionChangedAction.Reset, collectionChangedEventArgsList[0].Action);
        }