public void Regular_Basic()
 {
     ObservableSource.Timer(TimeSpan.FromMilliseconds(100), ThreadPoolScheduler.Instance)
     .Test()
     .AwaitDone(TimeSpan.FromSeconds(5))
     .AssertResult(0L);
 }
Esempio n. 2
0
        public void Time_Step()
        {
            var ts = new TestScheduler();

            var subj = new PublishSubject <int>();

            var to = subj.Delay(v => ObservableSource.Timer(TimeSpan.FromSeconds(1), ts)).Test();

            subj.OnNext(1);
            subj.OnNext(2);

            Assert.True(ts.HasTasks());

            to.AssertEmpty();

            ts.AdvanceTimeBy(1000);

            to.AssertValuesOnly(1, 2);

            ts.AdvanceTimeBy(1000);

            to.AssertValuesOnly(1, 2);

            subj.OnNext(3);

            ts.AdvanceTimeBy(200);

            subj.OnNext(4);

            ts.AdvanceTimeBy(200);

            subj.OnNext(5);

            ts.AdvanceTimeBy(200);

            to.AssertValuesOnly(1, 2);

            ts.AdvanceTimeBy(400);

            to.AssertValuesOnly(1, 2, 3);

            ts.AdvanceTimeBy(200);

            to.AssertValuesOnly(1, 2, 3, 4);

            ts.AdvanceTimeBy(200);

            to.AssertValuesOnly(1, 2, 3, 4, 5);

            subj.OnCompleted();

            ts.AdvanceTimeBy(500);

            to.AssertResult(1, 2, 3, 4, 5);

            Assert.False(ts.HasTasks());
        }
 public void Fused_Rejected()
 {
     ObservableSource.Timer(TimeSpan.FromMilliseconds(100), ThreadPoolScheduler.Instance)
     .Test(fusionMode: FusionSupport.Sync)
     .AssertFuseable()
     .AssertFusionMode(FusionSupport.None)
     .AwaitDone(TimeSpan.FromSeconds(5))
     .AssertResult(0L);
 }
        public void Regular_Dispose()
        {
            var ts = new TestScheduler();

            var to = ObservableSource.Timer(TimeSpan.FromSeconds(1), ts)
                     .Test();

            to.AssertEmpty();

            ts.AdvanceTimeBy(500);

            to.Dispose();

            ts.AdvanceTimeBy(500);

            to.AssertEmpty();
        }
Esempio n. 5
0
        public void Time_Step_Error()
        {
            var ts = new TestScheduler();

            var subj = new PublishSubject <int>();

            var to = subj.Delay(v => ObservableSource.Timer(TimeSpan.FromSeconds(1), ts), false).Test();

            subj.OnNext(1);
            subj.OnNext(2);
            subj.OnError(new InvalidOperationException());

            to.AssertFailure(typeof(InvalidOperationException));

            ts.AdvanceTimeBy(1000);

            to.AssertFailure(typeof(InvalidOperationException));
        }
        public void Fused_Basic2()
        {
            var ts = new TestScheduler();

            var to = ObservableSource.Timer(TimeSpan.FromSeconds(1), ts)
                     .Test(fusionMode: FusionSupport.Any)
                     .AssertFuseable()
                     .AssertFusionMode(FusionSupport.Async);

            to.AssertEmpty();

            ts.AdvanceTimeBy(500);

            to.AssertEmpty();

            ts.AdvanceTimeBy(500);

            to.AssertResult(0L);
        }