public void AddRange() { var batchCollection = new DispatchingCollection <int>(); using (var actual = batchCollection.SubscribeAll()) { var expectedChanges = new List <EventArgs> { CachedEventArgs.CountPropertyChanged, CachedEventArgs.IndexerPropertyChanged, CachedEventArgs.NotifyCollectionReset, }; batchCollection.AddRange(new[] { 1, 2 }); CollectionAssert.AreEqual(new[] { 1, 2 }, batchCollection); CollectionAssert.AreEqual(expectedChanges, actual, EventArgsComparer.Default); batchCollection.AddRange(new[] { 3, 4 }); CollectionAssert.AreEqual(new[] { 1, 2, 3, 4 }, batchCollection); expectedChanges.AddRange( new EventArgs[] { CachedEventArgs.CountPropertyChanged, CachedEventArgs.IndexerPropertyChanged, CachedEventArgs.NotifyCollectionReset, }); CollectionAssert.AreEqual(expectedChanges, actual, EventArgsComparer.Default); } }
public static void AddRangeSingle() { var reference = new ObservableCollection <int>(); using var expected = reference.SubscribeAll(); var batchCollection = new DispatchingCollection <int>(); using var actual = batchCollection.SubscribeAll(); reference.Add(1); batchCollection.AddRange(new[] { 1 }); CollectionAssert.AreEqual(reference, batchCollection); CollectionAssert.AreEqual(expected, actual, EventArgsComparer.Default); reference.Add(2); batchCollection.AddRange(new[] { 2 }); CollectionAssert.AreEqual(reference, batchCollection); CollectionAssert.AreEqual(expected, actual, EventArgsComparer.Default); }
public static void Remove() { 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.Remove(1); CollectionAssert.AreEqual(reference, batchCollection); CollectionAssert.AreEqual(expected, actual, EventArgsComparer.Default); reference.Remove(2); batchCollection.Remove(2); CollectionAssert.AreEqual(reference, batchCollection); CollectionAssert.AreEqual(expected, actual, EventArgsComparer.Default); }