public void RemoveRange() { var batchCollection = new DispatchingCollection <int> { 1, 2, 3, 4 }; using (var actual = batchCollection.SubscribeAll()) { var expectedChanges = new List <EventArgs> { CachedEventArgs.CountPropertyChanged, CachedEventArgs.IndexerPropertyChanged, CachedEventArgs.NotifyCollectionReset, }; batchCollection.RemoveRange(new[] { 1, 2 }); CollectionAssert.AreEqual(new[] { 3, 4 }, batchCollection); CollectionAssert.AreEqual(expectedChanges, actual, EventArgsComparer.Default); batchCollection.RemoveRange(new[] { 3, 4 }); CollectionAssert.IsEmpty(batchCollection); expectedChanges.AddRange( new EventArgs[] { CachedEventArgs.CountPropertyChanged, CachedEventArgs.IndexerPropertyChanged, CachedEventArgs.NotifyCollectionReset, }); CollectionAssert.AreEqual(expectedChanges, actual, EventArgsComparer.Default); } }
public static void RemoveRangeSingle() { var reference = new ObservableCollection <int> { 1, 2, 3 }; using var expected = reference.SubscribeAll(); var batchCollection = new DispatchingCollection <int>(reference); using var actual = batchCollection.SubscribeAll(); reference.Remove(1); batchCollection.RemoveRange(new[] { 1 }); CollectionAssert.AreEqual(reference, batchCollection); CollectionAssert.AreEqual(expected, actual, EventArgsComparer.Default); reference.Remove(2); batchCollection.RemoveRange(new[] { 2 }); CollectionAssert.AreEqual(reference, batchCollection); CollectionAssert.AreEqual(expected, actual, EventArgsComparer.Default); }