RunAll() public method

public RunAll ( ) : void
return void
Esempio n. 1
0
        public void publishing_is_run_through_publishing_scheduler()
        {
            ManualScheduler scheduler = new ManualScheduler();

            obs = Observable.Empty<int>(scheduler);

            bool completed = false;

            var subs = obs.Subscribe(x => { }, () => completed = true);

            Assert.IsFalse(completed);

            scheduler.RunAll();

            Assert.IsTrue(completed);
        }
Esempio n. 2
0
        public void honours_window_for_replays_with_priority_to_most_recent()
        {
            ManualScheduler scheduler = new ManualScheduler();

            ReplaySubject<int> subject =
                new ReplaySubject<int>(TimeSpan.FromMilliseconds(10), scheduler);

            StatsObserver<int> stats = new StatsObserver<int>();

            DateTime start = DateTime.UtcNow;

            scheduler.Now = start;
            subject.OnNext(1);

            scheduler.Now = start.AddMilliseconds(5);
            subject.OnNext(2);

            scheduler.Now = start.AddMilliseconds(10);
            subject.OnNext(3);

            scheduler.Now = start.AddMilliseconds(11);
            subject.Subscribe(stats);

            scheduler.RunAll();

            Assert.AreEqual(2, stats.NextCount);
            Assert.IsTrue(stats.NextValues.SequenceEqual(new int[] { 2, 3 }));
            Assert.IsFalse(stats.CompletedCalled);
        }
Esempio n. 3
0
        public void with_both_window_and_buffer_size_values_can_be_ignored_by_window()
        {
            ManualScheduler scheduler = new ManualScheduler();

            ReplaySubject<int> subject =
                new ReplaySubject<int>(3, TimeSpan.FromMilliseconds(10), scheduler);

            StatsObserver<int> stats = new StatsObserver<int>();

            DateTime start = DateTime.UtcNow;

            scheduler.Now = start; // ignored by window
            subject.OnNext(1);

            scheduler.Now = start.AddMilliseconds(5);
            subject.OnNext(2);

            scheduler.Now = start.AddMilliseconds(8);
            subject.OnCompleted();

            scheduler.Now = start.AddMilliseconds(11);
            subject.Subscribe(stats);

            scheduler.RunAll();

            Assert.AreEqual(1, stats.NextCount);
            Assert.IsTrue(stats.NextValues.SequenceEqual(new int[] { 2 }));
            Assert.IsTrue(stats.CompletedCalled);
        }
Esempio n. 4
0
        public void window_includes_onerror()
        {
            ManualScheduler scheduler = new ManualScheduler();

            ReplaySubject<int> subject =
                new ReplaySubject<int>(TimeSpan.FromMilliseconds(10), scheduler);

            StatsObserver<int> stats = new StatsObserver<int>();

            DateTime start = DateTime.UtcNow;

            scheduler.Now = start;
            subject.OnNext(1);

            scheduler.Now = start.AddMilliseconds(5);
            subject.OnNext(2);

            scheduler.Now = start.AddMilliseconds(10);
            subject.OnError(new Exception());

            scheduler.Now = start.AddMilliseconds(11);
            subject.Subscribe(stats);

            scheduler.RunAll();

            Assert.AreEqual(1, stats.NextCount);
            Assert.IsTrue(stats.NextValues.SequenceEqual(new int[] { 2 }));
            Assert.IsTrue(stats.ErrorCalled);
        }
Esempio n. 5
0
        public void window_can_pass_error()
        {
            ManualScheduler scheduler = new ManualScheduler();

            ReplaySubject<int> subject =
                new ReplaySubject<int>(TimeSpan.FromMilliseconds(10), scheduler);

            StatsObserver<int> stats = new StatsObserver<int>();

            DateTime start = DateTime.UtcNow;

            scheduler.Now = start;
            subject.OnError(new Exception());

            scheduler.Now = start.AddMilliseconds(11);
            subject.Subscribe(stats);

            scheduler.RunAll();

            Assert.IsFalse(stats.ErrorCalled);
        }
Esempio n. 6
0
        public void window_can_pass_complete()
        {
            ManualScheduler scheduler = new ManualScheduler();

            ReplaySubject<int> subject =
                new ReplaySubject<int>(TimeSpan.FromMilliseconds(10), scheduler);

            StatsObserver<int> stats = new StatsObserver<int>();

            DateTime start = DateTime.UtcNow;

            scheduler.Now = start;
            subject.OnCompleted();

            scheduler.Now = start.AddMilliseconds(11);
            subject.Subscribe(stats);

            scheduler.RunAll();

            Assert.AreEqual(0, stats.NextCount);
            Assert.IsFalse(stats.CompletedCalled);
        }
Esempio n. 7
0
        public void catch_with_observer_subscribes_to_first_through_scheduler()
        {
            ManualScheduler scheduler = new ManualScheduler();

            StatsObserver<IEvent<EventArgs>> observer = new StatsObserver<IEvent<EventArgs>>();

            EventOwner owner = new EventOwner();

            Observable.FromEvent<EventArgs>(x => owner.Event += x, x => owner.Event -= x)
                .Catch(Observable.Empty<IEvent<EventArgs>>(), scheduler)
                .Subscribe(observer);

            Assert.IsFalse(owner.HasSubscriptions);

            scheduler.RunAll();

            Assert.IsTrue(owner.HasSubscriptions);
        }