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); }
public void EndUpdate_OneEndUpdateAfterTwoBeginUpdate_NoCollectionChangedRaised() { var collectionChangedEventArgsList = new List <NotifyCollectionChangedEventArgs>(); var collection = new ExtendedObservableCollection <int>(); collection.CollectionChanged += (_, args) => collectionChangedEventArgsList.Add(args); collection.BeginUpdate(); collection.BeginUpdate(); collection.Add(1234); collection.EndUpdate(); Assert.Single(collection); Assert.Empty(collectionChangedEventArgsList); }
public void BeginUpdate_AddToItemsAfterBeginUpdate_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); }
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); }