protected async Task CallDisconnectAndReconnectCore(JsonServer js, JsonClient jc, ICredentials credentials = null) { js.ProductName = "My awesome server"; js.ProductVersion = "1.2.3.4"; js.Start(); // connect, call, disconnect await Assert_NotTimedOut(jc.ConnectAsync(credentials), "connect"); var result = await Assert_NotTimedOut(jc.Call(new VersionRequest()), "jc.Call(VersionRequest)"); Assert.NotNull(result); Assert.AreEqual(js.ProductName, result.ProductName); Assert.AreEqual(js.ProductVersion, result.ProductVersion); await Assert_NotTimedOut(jc.DisconnectAsync(), "disconnect"); // reconnect, call, disconnect await Assert_NotTimedOut(jc.ConnectAsync(credentials), "reconnect"); result = await Assert_NotTimedOut(jc.Call(new VersionRequest()), "jc.Call(VersionRequest) after reconnect"); Assert.NotNull(result); Assert.AreEqual(js.ProductName, result.ProductName); Assert.AreEqual(js.ProductVersion, result.ProductVersion); await Assert_NotTimedOut(jc.DisconnectAsync(), "disconnect completely"); Assert.AreEqual(0, jc.PendingMessages.Count); }
protected async Task CallDelayServiceAndDisconnectCore(JsonServer js, JsonClient jc, ICredentials credentials = null) { js.Start(); await jc.ConnectAsync(credentials); var call = jc.Call(new DelayRequest { Milliseconds = 1000 }); await Task.Delay(100); // make sure that the call was actually sent await jc.DisconnectAsync(); Assert.ThrowsAsync <ClientDisconnectedException>(async() => await Assert_NotTimedOut(call, "jc.Call(Delay 1000)", Task.Delay(2000))); }