Exemple #1
0
        public static void EmbargoOnPromisedAnswer(ITestbed testbed)
        {
            var counters = new Counters();
            var impl     = new TestMoreStuffImpl(counters);

            using (var main = testbed.ConnectMain <ITestMoreStuff>(impl))
            {
                if (main is IResolvingCapability resolving)
                {
                    testbed.MustComplete(resolving.WhenResolved.WrappedTask);
                }

                var cap = new TestCallOrderImpl();
                cap.CountToDispose = 6;

                var earlyCall = main.GetCallSequence(0, default);

                var echo = main.Echo(cap, default);
                testbed.MustComplete(Task.CompletedTask);
                using (var pipeline = echo.Eager(true))
                {
                    var call0 = pipeline.GetCallSequence(0, default);
                    var call1 = pipeline.GetCallSequence(1, default);

                    testbed.MustComplete(earlyCall);

                    impl.EnableEcho();

                    var call2 = pipeline.GetCallSequence(2, default);

                    testbed.MustComplete(echo);
                    using (var resolved = echo.Result)
                    {
                        var call3 = pipeline.GetCallSequence(3, default);
                        var call4 = pipeline.GetCallSequence(4, default);
                        var call5 = pipeline.GetCallSequence(5, default);

                        testbed.MustComplete(call0);
                        testbed.MustComplete(call1);
                        testbed.MustComplete(call2);
                        testbed.MustComplete(call3);
                        testbed.MustComplete(call4);
                        testbed.MustComplete(call5);

                        Assert.AreEqual(0u, call0.Result);
                        Assert.AreEqual(1u, call1.Result);
                        Assert.AreEqual(2u, call2.Result);
                        Assert.AreEqual(3u, call3.Result);
                        Assert.AreEqual(4u, call4.Result);
                        Assert.AreEqual(5u, call5.Result);
                        Assert.AreEqual(cap.Count, cap.CountToDispose, "counter must have reached number of calls");
                    }
                }
            }
        }
Exemple #2
0
        public static void EmbargoError(ITestbed testbed)
        {
            var counters = new Counters();
            var impl     = new TestMoreStuffImpl(counters);

            using (var main = testbed.ConnectMain <ITestMoreStuff>(impl))
            {
                if (main is IResolvingCapability resolving)
                {
                    testbed.MustComplete(resolving.WhenResolved.WrappedTask);
                }

                var cap = new TaskCompletionSource <ITestCallOrder>();

                var earlyCall = main.GetCallSequence(0, default);
                var echo      = main.Echo(cap.Task.Eager(true), default);

                using (var pipeline = echo.Eager(true))
                {
                    var call0 = pipeline.GetCallSequence(0, default);
                    var call1 = pipeline.GetCallSequence(1, default);

                    testbed.MustComplete(earlyCall);

                    impl.EnableEcho();

                    var call2 = pipeline.GetCallSequence(2, default);

                    testbed.MustComplete(echo);
                    var resolved = echo.Result;
                    var call3    = pipeline.GetCallSequence(3, default);
                    var call4    = pipeline.GetCallSequence(4, default);
                    var call5    = pipeline.GetCallSequence(5, default);

                    cap.SetException(new InvalidTimeZoneException("I'm annoying"));

                    testbed.ExpectPromiseThrows(call0, call1, call2, call3, call4, call5);

                    // Verify that we're still connected (there were no protocol errors).
                    testbed.MustComplete(main.GetCallSequence(1, default));
                }
            }
        }