Ejemplo n.º 1
0
        public void ManyAddsOneResetThrottledExplicitRefresh()
        {
            var source = new ObservableCollection <int> {
                1, 2, 3
            };
            var scheduler = new TestScheduler();

            using (var view = new ThrottledView <int>(source, TimeSpan.FromMilliseconds(100), scheduler, leaveOpen: true))
            {
                using (var actual = view.SubscribeAll())
                {
                    for (var i = 4; i < 10; i++)
                    {
                        source.Add(i);
                    }

                    CollectionAssert.AreEqual(new[] { 1, 2, 3 }, view);
                    CollectionAssert.IsEmpty(actual);
                    view.Refresh();
                    CollectionAssert.AreEqual(source, view);
                    var expected = new EventArgs[]
                    {
                        CachedEventArgs.CountPropertyChanged,
                        CachedEventArgs.IndexerPropertyChanged,
                        CachedEventArgs.NotifyCollectionReset,
                    };
                    CollectionAssert.AreEqual(expected, actual, EventArgsComparer.Default);
                }
            }
        }
Ejemplo n.º 2
0
        public void AddToSourceTestScheduler()
        {
            var source = new ObservableCollection <int> {
                1, 2, 3
            };
            var scheduler = new TestScheduler();

            using var view = new ThrottledView <int>(source, TimeSpan.FromMilliseconds(10), scheduler, leaveOpen: true);
            scheduler.Start();
            using var expected = source.SubscribeAll();
            using var actual   = view.SubscribeAll();
            source.Add(4);
            scheduler.Start();
            CollectionAssert.AreEqual(source, view);
            CollectionAssert.AreEqual(expected, actual, EventArgsComparer.Default);
        }
Ejemplo n.º 3
0
 private void AddOneToView()
 {
     ThrottledView.Add(new DummyItem(_observableCollection.Count + 1));
 }