Esempio n. 1
0
        public void MultiSubjectProxy_AsObserver_OnCompleted()
        {
            Run(client =>
            {
                var env = new TestExecutionEnvironment();
                var ctx = client.CreateContext(env);

                var inputUri     = new Uri("test://stream/input");
                var outputUri    = new Uri("test://stream/output");
                var sf           = env.Reactive.GetStreamFactory <int, int>(new Uri("rx://subject/inner"));
                var inputStream  = sf.Create(inputUri, null);
                var outputStream = sf.Create(outputUri, null);

                var inputProxy  = new MultiSubjectProxy <int, int>(inputUri);
                var outputProxy = new MultiSubjectProxy <int, int>(outputUri);
                var observer    = new MockObserver <int>(client);
                var inputSub    = SubscribeRoot(inputProxy, outputProxy.CreateObserver());
                var outputSub   = SubscribeRoot(outputProxy, observer);
                new SubscriptionInitializeVisitor(inputSub).Initialize(ctx);
                new SubscriptionInitializeVisitor(outputSub).Initialize(ctx);

                Schedule(client, 10, () => inputStream.OnCompleted());
                client.Start();

                observer.Messages.AssertEqual(
                    OnCompleted <int>(10)
                    );
            });
        }
Esempio n. 2
0
        public void Window_Settings_MaxWindowCount()
        {
            Run(client =>
            {
                var env = new TestExecutionEnvironment();

                var ctx = client.CreateContext(env, settings: new Dictionary <string, object>
                {
                    { "rx://operators/window/settings/maxWindowCount", 5 },
                });

                var xs = client.CreateHotObservable <int>(
                    );

                var res = client.Start(ctx, () =>
                                       xs.Window(TimeSpan.FromTicks(10), TimeSpan.FromTicks(1)).Merge(),
                                       100, 200, 1000);

                res.Messages.AssertEqual(
                    OnError <int>(205, ex => ex is InvalidOperationException)
                    );

                xs.Subscriptions.AssertEqual(
                    Subscribe(201, 205)
                    );
            });
        }
Esempio n. 3
0
        public void MultiSubjectProxy_Untyped_AsObserver()
        {
            Run(client =>
            {
                var env = new TestExecutionEnvironment();
                var ctx = client.CreateContext(env);

                var inputUri     = new Uri("test://stream/input");
                var outputUri    = new Uri("test://stream/output");
                var sf           = env.Reactive.GetStreamFactory <int, int>(new Uri("rx://subject/inner/untyped"));
                var inputStream  = sf.Create(inputUri, null);
                var outputStream = sf.Create(outputUri, null);

                var inputProxy  = new MultiSubjectProxy(inputUri);
                var outputProxy = new MultiSubjectProxy(outputUri);
                var observer    = new MockObserver <int>(client);
                var inputSub    = SubscribeRoot(inputProxy.GetObservable <int>(), outputProxy.GetObserver <int>());
                var outputSub   = SubscribeRoot(outputProxy.GetObservable <int>(), observer);
                new SubscriptionInitializeVisitor(inputSub).Initialize(ctx);
                new SubscriptionInitializeVisitor(outputSub).Initialize(ctx);

                Schedule(client, 10, () => inputStream.OnNext(1));
                Schedule(client, 20, () => inputStream.OnNext(2));
                Schedule(client, 30, () => inputStream.OnNext(3));
                client.Start();

                observer.Messages.AssertEqual(
                    OnNext(10, 1),
                    OnNext(20, 2),
                    OnNext(30, 3)
                    );
            });
        }
Esempio n. 4
0
        public void Distinct_Environment_Return()
        {
            Run(client =>
            {
                var env = new TestExecutionEnvironment();

                var ctx = client.CreateContext(env);

                var xs = client.CreateHotObservable(
                    OnNext(150, 1),
                    OnNext(220, 2),
                    OnCompleted <int>(250)
                    );

                var res = client.Start(ctx, () =>
                                       xs.Distinct(),
                                       100, 200, 1000);

                res.Messages.AssertEqual(
                    OnNext(220, 2),
                    OnCompleted <int>(250)
                    );

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

                Assert.AreEqual(0, env.ArtifactCount);
            });
        }
Esempio n. 5
0
        public void SelectMany_Environment_NonQuoted()
        {
            Run(client =>
            {
                var xs = client.CreateHotObservable(
                    OnNext(200, 2)
                    );

                var ys = client.CreateColdObservable(
                    OnNext(10, "bar")
                    );

                var env = new TestExecutionEnvironment();

                var ctx = client.CreateContext(env);

                var res = client.Start(ctx, () =>
                                       from x in xs
                                       from y in ys
                                       select x + " - " + y,
                                       100, 150, 1000
                                       );

                res.Messages.AssertEqual(
                    OnError <string>(200, ex => ex is HigherOrderSubscriptionFailedException)
                    );
            });
        }
Esempio n. 6
0
        public void SelectMany_Environment_BridgeSubscribeFailure()
        {
            Run(client =>
            {
                var err = new Exception();

                var xs = client.CreateHotObservable(
                    OnNext(200, 2)
                    );

                var ys = client.CreateColdObservable(
                    OnNext(10, "bar")
                    );

                var qys = new QuotedSubscribable <string>(ys, Expression.Constant(ys, typeof(ISubscribable <string>)));

                var env = new TestExecutionEnvironment()
                {
                    BridgeSubscriptionError = err
                };

                var ctx = client.CreateContext(env);

                var res = client.Start(ctx, () =>
                                       from x in xs
                                       from y in qys
                                       select x + " - " + y,
                                       100, 150, 1000
                                       );

                res.Messages.AssertEqual(
                    OnError <string>(200, ex => ex is HigherOrderSubscriptionFailedException && ex.InnerException == err)
                    );
            });
        }
Esempio n. 7
0
        public void MultiSubjectProxy_AsObservable()
        {
            Run(client =>
            {
                var env = new TestExecutionEnvironment();
                var ctx = client.CreateContext(env);

                var uri    = new Uri("test://stream");
                var sf     = env.Reactive.GetStreamFactory <int, int>(new Uri("rx://subject/inner"));
                var stream = sf.Create(uri, null);

                var proxy    = new MultiSubjectProxy <int, int>(uri);
                var observer = new MockObserver <int>(client);
                var sub      = ((IObservable <int>)proxy).Subscribe(observer);
                new SubscriptionInitializeVisitor((ISubscription)sub).Initialize(ctx);

                Schedule(client, 10, () => stream.OnNext(1));
                Schedule(client, 20, () => stream.OnNext(2));
                Schedule(client, 30, () => stream.OnNext(3));
                client.Start();

                observer.Messages.AssertEqual(
                    OnNext(10, 1),
                    OnNext(20, 2),
                    OnNext(30, 3)
                    );
            });
        }
Esempio n. 8
0
        public void Throttle_Environment_NonQuoted()
        {
            Run(client =>
            {
                var xs = client.CreateHotObservable(
                    OnNext(200, 2)
                    );

                var ys = client.CreateColdObservable(
                    OnNext(50, "bar")
                    );

                var env = new TestExecutionEnvironment();

                var ctx = client.CreateContext(env);

                var res = client.Start(ctx, () =>
                                       xs.Throttle(_ => ys),
                                       100, 150, 1000
                                       );

                res.Messages.AssertEqual(
                    OnError <int>(200, ex => ex is HigherOrderSubscriptionFailedException)
                    );
            });
        }
Esempio n. 9
0
        public void SelectMany_Environment_SaveAndReload1()
        {
            Run(client =>
            {
                var state = client.CreateStateContainer();

                var checkpoints = new[] {
                    OnSave(250, state),
                    OnLoad(290, state),
                };

                var xs = client.CreateHotObservable(
                    OnNext(200, 2),
                    OnNext(300, 3),
                    OnNext(400, 5),
                    OnCompleted <int>(500)
                    );

                var ys = client.CreateColdObservable(
                    OnNext(10, "bar"),
                    OnNext(20, "foo"),
                    OnCompleted <string>(30)
                    );

                var qys = new QuotedSubscribable <string>(ys, Expression.Constant(ys, typeof(ISubscribable <string>)));

                var env = new TestExecutionEnvironment();

                var ctx = client.CreateContext(env);

                var res = client.Start(ctx, () =>
                                       (from x in xs
                                        from y in qys
                                        select x + " - " + y)
                                       .Apply(client, checkpoints),
                                       100, 150, 1000
                                       );

                res.Messages.AssertEqual(
                    OnNext <string>(210, "2 - bar"),
                    OnNext <string>(220, "2 - foo"),
                    OnNext <string>(310, "3 - bar"),
                    OnNext <string>(320, "3 - foo"),
                    OnNext <string>(410, "5 - bar"),
                    OnNext <string>(420, "5 - foo"),
                    OnCompleted <string>(500)
                    );

                xs.Subscriptions.AssertEqual(
                    Subscribe(150, 500)
                    );
            });
        }
Esempio n. 10
0
        public void Window_Environment_Time_Dependencies()
        {
            Run(client =>
            {
                var env = new TestExecutionEnvironment();

                var ctx = client.CreateContext(env);

                var xs = client.CreateHotObservable <int>(
                    OnNext(210, 1),
                    OnNext(220, 2),
                    OnNext(230, 3),
                    OnNext(240, 4),
                    OnNext(250, 5),
                    OnNext(260, 6),
                    OnNext(270, 7),
                    OnNext(280, 8),
                    OnNext(290, 9),
                    OnCompleted <int>(300)
                    );

                var s = default(ISubscription);

                client.ScheduleAbsolute(200, () =>
                {
                    s = xs.Window(TimeSpan.FromTicks(30)).Subscribe(Observer.Nop <ISubscribable <int> >());
                    new SubscriptionInitializeVisitor(s).Initialize(ctx);
                });

                foreach (var t in new[] { 215, 245, 275 })
                {
                    client.ScheduleAbsolute(t, () =>
                    {
                        var ds = default(IEnumerable <Uri>);

                        SubscriptionVisitor.Do <IDependencyOperator>(op =>
                        {
                            ds = op.Dependencies;
                        }).Apply(s);

                        Assert.IsNotNull(ds);
                        Assert.AreEqual(1, ds.Count(d => d.OriginalString.StartsWith("rx://tollbooth")));
                        Assert.AreEqual(1, ds.Count(d => d.OriginalString.StartsWith("rx://collector")));
                        Assert.AreEqual(1, ds.Count(d => d.OriginalString.StartsWith("rx://tunnel/window")));
                    });
                }

                client.Start();
            });
        }
Esempio n. 11
0
        public void Switch_Environment_Simple()
        {
            Run(client =>
            {
                var ys1 = client.CreateHotObservable(
                    OnNext(200, 2),
                    OnNext(300, 3),
                    OnNext(400, 4),
                    OnCompleted <int>(500)
                    );

                var qys1 = new QuotedSubscribable <int>(ys1, Expression.Constant(ys1, typeof(ISubscribable <int>)));

                var ys2 = client.CreateHotObservable(
                    OnNext(400, 5),
                    OnCompleted <int>(500)
                    );

                var qys2 = new QuotedSubscribable <int>(ys2, Expression.Constant(ys2, typeof(ISubscribable <int>)));

                var xss = client.CreateHotObservable(
                    OnNext <ISubscribable <int> >(190, qys1),
                    OnNext <ISubscribable <int> >(350, qys2),
                    OnCompleted <ISubscribable <int> >(450)
                    );

                var env = new TestExecutionEnvironment();

                var ctx = client.CreateContext(env);

                var res = client.Start(ctx, () =>
                                       xss.Switch(),
                                       100, 150, 1000
                                       );

                res.Messages.AssertEqual(
                    OnNext <int>(200, 2),
                    OnNext <int>(300, 3),
                    OnNext <int>(400, 5),
                    OnCompleted <int>(500)
                    );

                xss.Subscriptions.AssertEqual(
                    Subscribe(150, 450)
                    );
            });
        }
        public void ReliableMultiSubjectProxy_AsObserver_InvalidEnvironment()
        {
            Run(client =>
            {
                var env = new TestExecutionEnvironment();
                var ctx = client.CreateContext(env);

                var uri      = new Uri("test://subject");
                var observer = new SubscriptionObserver <int>();
                var subject  = new TestSubject <int>(observer);
                env.AddArtifact(uri, subject);

                var proxy = new ReliableMultiSubjectProxy <int, int>(uri);
                var sub   = SubscribeRoot(Subscribable.Never <int>(), new ObserverToReliableObserver <int>(proxy.CreateObserver()));
                Assert.ThrowsException <InvalidOperationException>(() => new SubscriptionInitializeVisitor(sub).Initialize(ctx));
            });
        }
        public void ReliableMultiSubjectProxy_AsReliableObservable_InvalidEnvironment()
        {
            Run(client =>
            {
                var env = new TestExecutionEnvironment();
                var ctx = client.CreateContext(env);

                var uri     = new Uri("test://stream");
                var subject = new ReliableSubject <int>();
                env.AddArtifact(uri, subject);

                var proxy    = new ReliableMultiSubjectProxy <int, int>(uri);
                var observer = new MockObserver <int>(client);
                var sub      = proxy.ToSubscribable().Subscribe(observer);
                Assert.ThrowsException <InvalidOperationException>(() => new SubscriptionInitializeVisitor(sub).Initialize(ctx));
            });
        }
Esempio n. 14
0
        public void Throttle_Environment_SaveAndReload1()
        {
            Run(client =>
            {
                var state = client.CreateStateContainer();

                var checkpoints = new[] {
                    OnSave(260, state),
                    OnLoad(290, state),
                };

                var xs = client.CreateHotObservable(
                    OnNext(200, 2),
                    OnNext(300, 3),
                    OnNext(400, 5),
                    OnCompleted <int>(500)
                    );

                var ys = client.CreateColdObservable(
                    OnNext(50, "bar"),
                    OnCompleted <string>(70)
                    );

                var qys = new QuotedSubscribable <string>(ys, Expression.Constant(ys, typeof(ISubscribable <string>)));

                var env = new TestExecutionEnvironment();

                var ctx = client.CreateContext(env);

                var res = client.Start(ctx, () =>
                                       xs.Throttle(_ => qys).Apply(client, checkpoints),
                                       100, 150, 1000
                                       );

                res.Messages.AssertEqual(
                    OnNext <int>(250, 2),
                    OnNext <int>(350, 3),
                    OnNext <int>(450, 5),
                    OnCompleted <int>(500)
                    );

                xs.Subscriptions.AssertEqual(
                    Subscribe(150, 500)
                    );
            });
        }
Esempio n. 15
0
        public void GroupBy_Environment_Simple1()
        {
            Run(client =>
            {
                var env = new TestExecutionEnvironment();

                var ctx = client.CreateContext(env);

                var xs = client.CreateHotObservable <int>(
                    OnNext(210, 1),
                    OnNext(220, 2),
                    OnNext(230, 3),
                    OnNext(240, 4),
                    OnNext(250, 5),
                    OnNext(260, 6),
                    OnNext(270, 7),
                    OnNext(280, 8),
                    OnNext(290, 9),
                    OnCompleted <int>(300)
                    );

                var res = client.Start(ctx, () =>
                                       xs.GroupBy(x => x % 2).Merge(),
                                       100, 200, 1000);

                res.Messages.AssertEqual(
                    OnNext(210, 1),
                    OnNext(220, 2),
                    OnNext(230, 3),
                    OnNext(240, 4),
                    OnNext(250, 5),
                    OnNext(260, 6),
                    OnNext(270, 7),
                    OnNext(280, 8),
                    OnNext(290, 9),
                    OnCompleted <int>(300)
                    );

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

                Assert.AreEqual(0, env.ArtifactCount);
            });
        }
Esempio n. 16
0
        public void GroupBy_Settings_MaxWindowCount()
        {
            Run(client =>
            {
                var env = new TestExecutionEnvironment();

                var ctx = client.CreateContext(env, settings: new Dictionary <string, object>
                {
                    { "rx://operators/groupBy/settings/maxGroupCount", 5 },
                });

                var xs = client.CreateHotObservable <int>(
                    OnNext(210, 1),
                    OnNext(220, 2),
                    OnNext(230, 3),
                    OnNext(240, 4),
                    OnNext(250, 5),
                    OnNext(260, 6),
                    OnNext(270, 7),
                    OnNext(280, 8),
                    OnNext(290, 9),
                    OnCompleted <int>(300)
                    );

                var res = client.Start(ctx, () =>
                                       xs.GroupBy(x => x).Merge(),
                                       100, 200, 1000);

                res.Messages.AssertEqual(
                    OnNext(210, 1),
                    OnNext(220, 2),
                    OnNext(230, 3),
                    OnNext(240, 4),
                    OnNext(250, 5),
                    OnError <int>(260, ex => ex is InvalidOperationException)
                    );

                xs.Subscriptions.AssertEqual(
                    Subscribe(200, 260)
                    );
            });
        }
Esempio n. 17
0
        public void Distinct_Environment_Never()
        {
            Run(client =>
            {
                var env = new TestExecutionEnvironment();

                var ctx = client.CreateContext(env);

                var xs = client.CreateHotObservable <int>();

                var res = client.Start(ctx, () =>
                                       xs.Distinct(),
                                       100, 200, 1000);

                res.Messages.AssertEqual(
                    );

                Assert.AreEqual(0, env.ArtifactCount);
            });
        }
Esempio n. 18
0
        public void MultiSubjectProxy_Untyped_AsObserver_AsSubscription()
        {
            Run(client =>
            {
                var env = new TestExecutionEnvironment();
                var ctx = client.CreateContext(env);

                var uri      = new Uri("test://subject");
                var observer = new SubscriptionObserver <int>();
                var subject  = new TestSubject(observer);
                env.AddArtifact(uri, subject);

                var proxy = new MultiSubjectProxy(uri);
                var sub   = SubscribeRoot(new Never <int>(), proxy.GetObserver <int>());
                new SubscriptionInitializeVisitor(sub).Initialize(ctx);
                Assert.IsTrue(observer.IsAcceptCalled);

                sub.Dispose();
                Assert.IsTrue(observer.IsDisposeCalled);
            });
        }
Esempio n. 19
0
        public void Distinct_Settings_MaxDistinctElements()
        {
            Run(client =>
            {
                var env = new TestExecutionEnvironment();

                var ctx = client.CreateContext(env, settings: new Dictionary <string, object>
                {
                    { "rx://operators/distinct/settings/maxDistinctElements", 3 },
                });

                var xs = client.CreateHotObservable(
                    OnNext(150, 1),
                    OnNext(210, 2),
                    OnNext(220, 3),
                    OnNext(230, 4),
                    OnNext(240, 5),
                    OnCompleted <int>(250)
                    );

                var res = client.Start(ctx, () =>
                                       xs.Distinct(),
                                       100, 200, 1000);

                res.Messages.AssertEqual(
                    OnNext(210, 2),
                    OnNext(220, 3),
                    OnNext(230, 4),
                    OnError <int>(240, e => e is InvalidOperationException)
                    );

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

                Assert.AreEqual(0, env.ArtifactCount);
            });
        }
Esempio n. 20
0
        public void SelectMany_Settings_MaxConcurrentInnerSubscriptionCount()
        {
            Run(client =>
            {
                var env = new TestExecutionEnvironment();

                var ctx = client.CreateContext(env, settings: new Dictionary <string, object>
                {
                    { "rx://operators/bind/settings/maxConcurrentInnerSubscriptionCount", 5 },
                });

                var xs = client.CreateHotObservable <int>(
                    OnNext(210, 1),
                    OnNext(220, 2),
                    OnNext(230, 3),
                    OnNext(240, 4),
                    OnNext(250, 5),
                    OnNext(260, 6)
                    );

                var ys = client.CreateColdObservable <int>(
                    );

                var qys = new QuotedSubscribable <int>(ys, Expression.Constant(ys, typeof(ISubscribable <int>)));

                var res = client.Start(ctx, () =>
                                       xs.SelectMany(x => qys),
                                       100, 200, 1000);

                res.Messages.AssertEqual(
                    OnError <int>(260, ex => ex is InvalidOperationException)
                    );

                xs.Subscriptions.AssertEqual(
                    Subscribe(200, 260)
                    );
            });
        }
Esempio n. 21
0
        public void SelectMany_Environment_SaveAndReload2()
        {
            var ys2 = default(ISubscribable <string>);
            var ys3 = default(ISubscribable <string>);
            var ys5 = default(ISubscribable <string>);

            var qyss = new Dictionary <int, ISubscribable <string> >
            {
#pragma warning disable IDE0004 // Remove Unnecessary Cast. (Only unnecessary on C# 10 or later.)
                { 2, new QuotedSubscribable <string>(ys2, Expression.Invoke((Expression <Func <ISubscribable <string> > >)(() => ys2))) },
                { 3, new QuotedSubscribable <string>(ys3, Expression.Invoke((Expression <Func <ISubscribable <string> > >)(() => ys3))) },
                { 5, new QuotedSubscribable <string>(ys5, Expression.Invoke((Expression <Func <ISubscribable <string> > >)(() => ys5))) },
#pragma warning restore IDE0004 // Remove Unnecessary Cast
            };

            var getQuery = FromContext(client =>
            {
                var xs = client.CreateHotObservable(
                    OnNext(200, 2),
                    OnNext(300, 3),
                    OnNext(400, 5),
                    OnCompleted <int>(500)
                    );

                ys2 = client.CreateHotObservable(
                    OnNext(210, "bar"),
                    OnNext(220, "foo"),
                    OnCompleted <string>(230)
                    );

                ys3 = client.CreateHotObservable(
                    OnNext(310, "qux"),
                    OnNext(320, "baz"),
                    OnCompleted <string>(330)
                    );

                ys5 = client.CreateHotObservable(
                    OnNext(410, "corge"),
                    OnNext(420, "grault"),
                    OnCompleted <string>(430)
                    );

                var query = from x in xs
                            from y in qyss[x]
                            select x + " - " + y;

                return(query);
            });

            var state = default(IOperatorStateContainer);
            var env   = new TestExecutionEnvironment();

            // Before checkpoint
            Run(client =>
            {
                client.Schedule(TimeSpan.FromTicks(324), new ActionTask(env.Freeze));

                state = client.CreateStateContainer();

                var query = getQuery(client);

                var ctx = client.CreateContext(env);

                var res = client.Start(ctx, () =>
                                       query.Apply(client, OnSave(315, state)),
                                       100, 150, 325
                                       );

                res.Messages.AssertEqual(
                    OnNext <string>(210, "2 - bar"),
                    OnNext <string>(220, "2 - foo"),
                    OnNext <string>(310, "3 - qux"),
                    OnNext <string>(320, "3 - baz")
                    );
            });

            // After checkpoint
            Run(client =>
            {
                client.Schedule(TimeSpan.FromTicks(324), new ActionTask(env.Defrost));

                var query = getQuery(client);

                var ctx = client.CreateContext(env);

                var res = client.Start(ctx, () =>
                                       query,
                                       100, 325, 1000, state
                                       );

                res.Messages.AssertEqual(
                    OnNext <string>(410, "5 - corge"),
                    OnNext <string>(420, "5 - grault"),
                    OnCompleted <string>(500)
                    );
            });
        }
Esempio n. 22
0
        public void Switch_Environment_SaveAndReload2()
        {
            var ys1 = default(ISubscribable <int>);
            var ys2 = default(ISubscribable <int>);

            var qyss = new ISubscribable <int>[]
            {
                new QuotedSubscribable <int>(ys1, Expression.Invoke((Expression <Func <ISubscribable <int> > >)(() => ys1))),
                new QuotedSubscribable <int>(ys2, Expression.Invoke((Expression <Func <ISubscribable <int> > >)(() => ys2))),
            };

            var getQuery = FromContext(client =>
            {
                ys1 = client.CreateHotObservable(
                    OnNext(200, 2),
                    OnNext(300, 3),
                    OnNext(400, 4),
                    OnCompleted <int>(500)
                    );

                ys2 = client.CreateHotObservable(
                    OnNext(400, 5),
                    OnCompleted <int>(500)
                    );

                var xss = client.CreateHotObservable(
                    OnNext <ISubscribable <int> >(190, qyss[0]),
                    OnNext <ISubscribable <int> >(350, qyss[1]),
                    OnCompleted <ISubscribable <int> >(250)
                    );

                return(xss.Switch());
            });

            var state = default(IOperatorStateContainer);
            var env   = new TestExecutionEnvironment();

            // Before checkpoint
            Run(client =>
            {
                client.Schedule(TimeSpan.FromTicks(259), new ActionTask(env.Freeze));

                state = client.CreateStateContainer();

                var query = getQuery(client);

                var ctx = client.CreateContext(env);

                var res = client.Start(ctx, () =>
                                       query.Apply(client, OnSave(255, state)),
                                       100, 150, 260
                                       );

                res.Messages.AssertEqual(
                    OnNext <int>(200, 2)
                    );
            });

            // After checkpoint
            Run(client =>
            {
                client.Schedule(TimeSpan.FromTicks(259), new ActionTask(env.Defrost));

                var query = getQuery(client);

                var ctx = client.CreateContext(env);

                var res = client.Start(ctx, () =>
                                       query,
                                       100, 260, 1000, state
                                       );

                res.Messages.AssertEqual(
                    OnNext <int>(300, 3),
                    OnNext <int>(400, 5),
                    OnCompleted <int>(500)
                    );
            });
        }