public void CallingResetWhileAddingItemsInAddingMode() { var counter = 0; var eventArgs = (NotifyCollectionChangedEventArgs)null; var fastCollection = new FastObservableCollection <int>(); fastCollection.AutomaticallyDispatchChangeNotifications = false; fastCollection.CollectionChanged += (sender, e) => { counter++; eventArgs = e; }; var token = fastCollection.SuspendChangeNotifications(SuspensionMode.Adding); fastCollection.Add(1); fastCollection.Add(2); fastCollection.Reset(); Assert.AreEqual(0, counter); fastCollection.Add(3); fastCollection.Add(4); fastCollection.Add(5); token.Dispose(); Assert.AreEqual(1, counter); Assert.AreEqual(NotifyCollectionChangedAction.Add, eventArgs.Action); CollectionAssert.AreEqual(eventArgs.NewItems, new[] { 1, 2, 3, 4, 5 }); }
public void ResetWithoutSuspendChangeNotifications() { var collectionChanged = false; var fastCollection = new FastObservableCollection <int>(); fastCollection.AutomaticallyDispatchChangeNotifications = false; fastCollection.CollectionChanged += (sender, e) => { collectionChanged = true; }; fastCollection.Reset(); Assert.AreEqual(true, collectionChanged); }