public async Task TimeoutPerRequest() { for (int i = 0; i < 20; i++) { var request = new SystemMessage { RequestTimeout = TimeSpan.FromMilliseconds(10), Delay = 100 }; Exception exception = null; try { await _computingClient.SendMessage(request); } catch (TimeoutException ex) { exception = ex; } catch (RemoteException ex) { exception = ex; ex.Is <TimeoutException>().ShouldBeTrue(); } exception.Message.ShouldBe($"{nameof(_computingClient.SendMessage)} timed out."); await AddFloat(); } }
private async Task CallbackCore() { var proxy = new NamedPipeClientBuilder <IComputingServiceBase>(PipeName).RequestTimeout(RequestTimeout).AllowImpersonation().ValidateAndBuild(); var message = new SystemMessage { Text = Guid.NewGuid().ToString() }; var computingTask = _computingClient.SendMessage(message); var systemTask = _systemClient.SendMessage(message); var computingBaseTask = proxy.AddFloat(1, 2); await Task.WhenAll(computingTask, systemTask, computingBaseTask); systemTask.Result.ShouldBe($"{Environment.UserName}_{_systemCallback.Id}_{message.Text}"); computingTask.Result.ShouldBe($"{Environment.UserName}_{_computingCallback.Id}_{message.Text}"); computingBaseTask.Result.ShouldBe(3); }