public async Task ObserveOn_NewThreadScheduler_ShortTasksExecutesAsOne() { var res = await _source.ObserveOn(NewThreadScheduler.Default) .Select(x => (x, ThreadId: Thread.CurrentThread.ManagedThreadId)) .ToArray(); Assert.AreEqual(10, res.Length); EnumerableAssert.All(res, x => x.ThreadId == res[0].ThreadId); }
public async Task ObserveOn_NewThreadScheduler_() { var res = await _source.ObserveOn(NewThreadScheduler.Default) .Do(_ => Thread.Sleep(TimeSpan.FromSeconds(2))) .Select(x => (x, ThreadId: Thread.CurrentThread.ManagedThreadId)) .ToArray(); Assert.AreEqual(10, res.Length); EnumerableAssert.All(res, x => x.ThreadId == res[0].ThreadId); }
public void RefreshAllTest() { using (var refresher = new Subject <Unit>()) using (var cache = new SourceCache <Valuable <string>, Guid>(x => x.Key)) using (var aggregator = cache.Connect().AutoRefreshOnObservable(x => refresher).AsAggregator()) { cache.AddOrUpdate(_items); refresher.OnNext(Unit.Default); Assert.AreEqual(101, aggregator.Messages.Count); EnumerableAssert.All(aggregator.Messages.SelectMany(x => x), x => x.Reason == ChangeReason.Refresh); } }
public void GroupTest_Update() { using (var cache = new SourceCache <Groupable <int, string>, Guid>(x => x.Key)) using (var aggregator = cache.Connect() .Group(x => x.GroupKey) .AsAggregator()) { cache.AddOrUpdate(_items); cache.AddOrUpdate(_items[0]); Assert.AreEqual(2, aggregator.Messages.Count); EnumerableAssert.All(aggregator.Messages.SelectMany(x => x), x => x.Reason == ChangeReason.Refresh); } }