예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
                    }
        }
예제 #4
0
        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);
                }
        }