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 scheduler_is_used_to_send_values()
        {
            Subject<int> subject = new Subject<int>();

            var scheduler = new ManualScheduler();

            var stats = new StatsObserver<int>();

            var obs = subject.Prune(scheduler);
            var connection = obs.Connect();

            subject.OnNext(1);
            subject.OnCompleted();

            obs.Subscribe(stats);

            scheduler.RunAll();

            Assert.IsTrue(stats.NextCalled);
            Assert.IsTrue(stats.CompletedCalled);
        }
Esempio n. 3
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. 4
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. 5
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. 6
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. 7
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);
        }