예제 #1
0
        public void RemoveRange()
        {
            var scheduledCollection = new ScheduledCollection <int> {
                1, 2, 3, 4
            };

            using (var actualChanges = scheduledCollection.SubscribeAll())
            {
                var expectedChanges = new List <EventArgs>
                {
                    CachedEventArgs.CountPropertyChanged,
                    CachedEventArgs.IndexerPropertyChanged,
                    CachedEventArgs.NotifyCollectionReset
                };

                scheduledCollection.RemoveRange(new[] { 1, 2 });
                CollectionAssert.AreEqual(new[] { 3, 4 }, scheduledCollection);
                CollectionAssert.AreEqual(expectedChanges, actualChanges, EventArgsComparer.Default);

                scheduledCollection.RemoveRange(new[] { 3, 4 });
                CollectionAssert.IsEmpty(scheduledCollection);
                expectedChanges.AddRange(
                    new EventArgs[]
                {
                    CachedEventArgs.CountPropertyChanged,
                    CachedEventArgs.IndexerPropertyChanged,
                    CachedEventArgs.NotifyCollectionReset
                });
                CollectionAssert.AreEqual(expectedChanges, actualChanges, EventArgsComparer.Default);
            }
        }
예제 #2
0
        public void RemoveRangeSingle()
        {
            var reference = new ObservableCollection <int> {
                1, 2, 3
            };

            using (var expectedChanges = reference.SubscribeAll())
            {
                var scheduledCollection = new ScheduledCollection <int>(reference);
                using (var actualChanges = scheduledCollection.SubscribeAll())
                {
                    reference.Remove(1);
                    scheduledCollection.RemoveRange(new[] { 1 });
                    CollectionAssert.AreEqual(reference, scheduledCollection);
                    CollectionAssert.AreEqual(expectedChanges, actualChanges, EventArgsComparer.Default);

                    reference.Remove(2);
                    scheduledCollection.RemoveRange(new[] { 2 });
                    CollectionAssert.AreEqual(reference, scheduledCollection);
                    CollectionAssert.AreEqual(expectedChanges, actualChanges, EventArgsComparer.Default);
                }
            }
        }