예제 #1
0
        public void AddRange()
        {
            var scheduledCollection = new ScheduledCollection <int>();

            using (var actualChanges = scheduledCollection.SubscribeAll())
            {
                var expectedChanges = new List <EventArgs>
                {
                    CachedEventArgs.CountPropertyChanged,
                    CachedEventArgs.IndexerPropertyChanged,
                    CachedEventArgs.NotifyCollectionReset
                };
                scheduledCollection.AddRange(new[] { 1, 2 });
                CollectionAssert.AreEqual(new[] { 1, 2 }, scheduledCollection);
                CollectionAssert.AreEqual(expectedChanges, actualChanges, EventArgsComparer.Default);

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

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

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