public void BufferTest(RefresherData data) { var ints = new ObservableCollection <int>(); var results = new List <Timestamped <IReadOnlyList <NotifyCollectionChangedEventArgs> > >(); var scheduler = new TestScheduler(); var observable = ThrottledRefresher.Create(Mock.Of <IUpdater>(x => x.IsUpdatingSourceItem == null), ints, TimeSpan.FromMilliseconds(10), scheduler, data.SignalInitial) .Timestamp(scheduler); observable.Subscribe(results.Add); foreach (var time in data.Times) { scheduler.Schedule(TimeSpan.FromMilliseconds(time), () => ints.Add(time)); } scheduler.Start(); Assert.AreEqual(data.Results.Count, results.Count); for (int i = 0; i < data.Results.Count; i++) { var expected = data.Results[i]; var actual = results[i]; Assert.AreEqual(expected.Count, actual.Value.Count); } var secondResults = new List <Timestamped <IReadOnlyList <NotifyCollectionChangedEventArgs> > >(); observable.Subscribe(secondResults.Add); CollectionAssert.IsEmpty(secondResults); }
public void Filters() { var ints = new ObservableCollection <int>(); var results = new List <IReadOnlyList <NotifyCollectionChangedEventArgs> >(); var observable = ThrottledRefresher.Create( Mock.Of <IUpdater>(x => x.IsUpdatingSourceItem == (object)1), ints, TimeSpan.Zero, null, false); observable.Subscribe(results.Add); ints.Add(1); CollectionAssert.IsEmpty(results); }