public static void EmbargoOnImportedCap(ITestbed testbed) { var impl = new TestMoreStuffImpl2(); using (var main = testbed.ConnectMain <ITestMoreStuff>(impl)) { var cap = new TestCallOrderImpl(); cap.CountToDispose = 6; var earlyCall = main.GetCallSequence(0, default); var echo = main.Echo(cap, default); testbed.MustComplete(echo); using (var pipeline = echo.Result) { 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); try { testbed.MustComplete(call0); testbed.MustComplete(call1); testbed.MustComplete(call2); testbed.MustComplete(call3); testbed.MustComplete(call4); testbed.MustComplete(call5); } catch (System.Exception) { cap.CountToDispose = null; throw; } 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); } } } }
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"); } } } }