Exemple #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);
            }
        }
Exemple #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);
                }
            }
        }
Exemple #3
0
        public void Remove()
        {
            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.Remove(1);
                    CollectionAssert.AreEqual(reference, scheduledCollection);
                    CollectionAssert.AreEqual(expectedChanges, actualChanges, EventArgsComparer.Default);

                    reference.Remove(2);
                    scheduledCollection.Remove(2);
                    CollectionAssert.AreEqual(reference, scheduledCollection);
                    CollectionAssert.AreEqual(expectedChanges, actualChanges, EventArgsComparer.Default);
                }
            }
        }