public void RaisesSingleEventWhileInsertingRange() { var counter = 0; var fastCollection = new FastObservableCollection <int>(); fastCollection.AutomaticallyDispatchChangeNotifications = false; fastCollection.CollectionChanged += (sender, e) => counter++; fastCollection.InsertItems(new[] { 1, 2, 3, 4, 5 }, 0); Assert.AreEqual(1, counter); fastCollection.InsertItems(new[] { 1, 2, 3, 4, 5 }, 0, SuspensionMode.Adding); Assert.AreEqual(2, counter); fastCollection.InsertItems(new ArrayList(new[] { 1, 2, 3, 4, 5 }), 0); Assert.AreEqual(3, counter); fastCollection.InsertItems(new ArrayList(new[] { 1, 2, 3, 4, 5 }), 0, SuspensionMode.Adding); Assert.AreEqual(4, counter); }
public void RaisesSingleAddEventWhileInsertingRangeWithoutSuspensionMode() { var eventArgs = default(NotifyCollectionChangedEventArgs); var fastCollection = new FastObservableCollection <int>(); fastCollection.AutomaticallyDispatchChangeNotifications = false; fastCollection.CollectionChanged += (sender, e) => eventArgs = e; fastCollection.InsertItems(new[] { 1, 2, 3, 4, 5 }, 0); Assert.AreEqual(NotifyCollectionChangedAction.Reset, eventArgs.Action); }
public void RaisesSingleAddEventWhileInsertingRangeInSuspensionModeAdding() { var eventArgs = default(NotifyCollectionChangedEventArgs); int count = 0; var fastCollection = new FastObservableCollection <int>(); fastCollection.AutomaticallyDispatchChangeNotifications = false; fastCollection.CollectionChanged += (sender, e) => { eventArgs = e; count++; }; fastCollection.InsertItems(new[] { 1, 2, 3, 4, 5 }, 0, SuspensionMode.Adding); Assert.AreEqual(NotifyCollectionChangedAction.Add, eventArgs.Action); Assert.AreEqual(1, count); }
public void ThrowsInvalidOperationExceptionForInvalidSuspensionMode() { var fastCollection = new FastObservableCollection <int>(); fastCollection.AutomaticallyDispatchChangeNotifications = false; ExceptionTester.CallMethodAndExpectException <InvalidOperationException>(() => fastCollection.InsertItems(new[] { 1, 2, 3, 4, 5 }, 0, SuspensionMode.Removing)); }
public void ThrowsArgumentNullExceptionForNullCollection() { var fastCollection = new FastObservableCollection <int>(); fastCollection.AutomaticallyDispatchChangeNotifications = false; ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => fastCollection.InsertItems(null, 0)); ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => fastCollection.InsertItems(null, 0, SuspensionMode.Adding)); }