Ejemplo n.º 1
0
        public void RepeatingTimer_Periodic2()
        {
            var scheduler = new PeriodicTestScheduler();

            var res = scheduler.Start(() =>
                                      Observable.Timer(TimeSpan.FromTicks(100), TimeSpan.FromTicks(100), scheduler),
                                      0, 200, 750
                                      );

            res.Messages.AssertEqual(
                OnNext(300, 0L),
                OnNext(400, 1L),
                OnNext(500, 2L),
                OnNext(600, 3L),
                OnNext(700, 4L)
                );

#if !WINDOWS
            scheduler.Timers.AssertEqual(
                new TimerRun(200, 750)
            {
                300, 400, 500, 600, 700
            }
                );
#endif
        }
Ejemplo n.º 2
0
        public void Sample_Periodic_Never()
        {
            var scheduler = new PeriodicTestScheduler();

            var xs = scheduler.CreateHotObservable(
                OnNext(150, 1)
                );

            var res = scheduler.Start(() =>
                                      xs.Sample(TimeSpan.FromTicks(50), scheduler)
                                      );

            res.Messages.AssertEqual(
                );

            xs.Subscriptions.AssertEqual(
                Subscribe(200, 1000)
                );

#if !WINDOWS
            scheduler.Timers.AssertEqual(
                new TimerRun(200, 1000)
            {
                250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950
            }
                );
#endif
        }
Ejemplo n.º 3
0
        public void Sample_Periodic_Error()
        {
            var scheduler = new PeriodicTestScheduler();

            var ex = new Exception();

            var xs = scheduler.CreateHotObservable(
                OnNext(150, 1),
                OnError <int>(300, ex)
                );

            var res = scheduler.Start(() =>
                                      xs.Sample(TimeSpan.FromTicks(50), scheduler)
                                      );

            res.Messages.AssertEqual(
                OnError <int>(300, ex)
                );

            xs.Subscriptions.AssertEqual(
                Subscribe(200, 300)
                );

#if !WINDOWS
            scheduler.Timers.AssertEqual(
                new TimerRun(200, 300)
            {
                250
            }
                );
#endif
        }
Ejemplo n.º 4
0
        public void BufferWithTime_Basic_Same_Periodic_Error()
        {
            var ex = new Exception();

            var scheduler = new PeriodicTestScheduler();

            var xs = scheduler.CreateHotObservable(
                OnNext(100, 1),
                OnNext(210, 2),
                OnNext(240, 3),
                OnNext(280, 4),
                OnNext(320, 5),
                OnNext(350, 6),
                OnNext(380, 7),
                OnNext(420, 8),
                OnNext(470, 9),
                OnError <int>(480, ex)
                );

            var res = scheduler.Start(() =>
                                      xs.Buffer(TimeSpan.FromTicks(100), scheduler).Select(x => string.Join(",", x.Select(xx => xx.ToString()).ToArray()))
                                      );

            res.Messages.AssertEqual(
                OnNext(300, "2,3,4"),
                OnNext(400, "5,6,7"),
                OnError <string>(480, ex)
                );

            xs.Subscriptions.AssertEqual(
                Subscribe(200, 480)
                );

#if !WINDOWS
            scheduler.Timers.AssertEqual(
                new TimerRun(200, 480)
            {
                300, 400
            }
                );
#endif
        }
Ejemplo n.º 5
0
        public void Sample_Periodic_Regular()
        {
            var scheduler = new PeriodicTestScheduler();

            var xs = scheduler.CreateHotObservable(
                OnNext(150, 1),
                OnNext(210, 2),
                OnNext(230, 3),
                OnNext(260, 4),
                OnNext(300, 5),
                OnNext(350, 6),
                OnNext(380, 7),
                OnCompleted <int>(390)
                );

            var res = scheduler.Start(() =>
                                      xs.Sample(TimeSpan.FromTicks(50), scheduler)
                                      );

            res.Messages.AssertEqual(
                OnNext(250, 3),
                OnNext(300, 5), /* CHECK: boundary of sampling */
                OnNext(350, 6),
                OnNext(400, 7), /* Sample in last bucket */
                OnCompleted <int>(400)
                );

            xs.Subscriptions.AssertEqual(
                Subscribe(200, 390)
                );

#if !WINDOWS
            scheduler.Timers.AssertEqual(
                new TimerRun(200, 400)
            {
                250, 300, 350, 400
            }
                );
#endif
        }
Ejemplo n.º 6
0
        public void Sample_Periodic_ErrorInFlight()
        {
            var scheduler = new PeriodicTestScheduler();

            var ex = new Exception();

            var xs = scheduler.CreateHotObservable(
                OnNext(150, 1),
                OnNext(210, 2),
                OnNext(230, 3),
                OnNext(260, 4),
                OnNext(300, 5),
                OnNext(310, 6),
                OnError <int>(330, ex)
                );

            var res = scheduler.Start(() =>
                                      xs.Sample(TimeSpan.FromTicks(50), scheduler)
                                      );

            res.Messages.AssertEqual(
                OnNext(250, 3),
                OnNext(300, 5), /* CHECK: boundary of sampling */
                OnError <int>(330, ex)
                );

            xs.Subscriptions.AssertEqual(
                Subscribe(200, 330)
                );

#if !WINDOWS
            scheduler.Timers.AssertEqual(
                new TimerRun(200, 330)
            {
                250, 300
            }
                );
#endif
        }