public object Any(HelloFilter request) => !request.Throw ? new HelloFilterResponse { Result = $"Hi {request.Name}!" } : throw new ArgumentException(request.Name);
public void Does_call_OnBeforeExecute_and_OnAfterExecute() { var client = new JsonServiceClient(Config.ListeningOn) { ResponseFilter = res => { $"X-Filter: {res.Headers["X-Filter"]}".Print(); Assert.That(res.Headers["X-Filter"], Is.EqualTo("OnAfterExecute")); } }; var request = new HelloFilter { Name = nameof(HelloFilter) }; var response = client.Get(request); Assert.That(response.Result, Is.EqualTo($"Hi {request.Name} OnBeforeExecute! OnAfterExecute")); }
public void Does_call_OnExceptionAsync_on_Error() { var client = new JsonServiceClient(Config.ListeningOn); var request = new HelloFilter { Name = nameof(HelloFilter), Throw = true, }; try { var response = client.Get(request); Assert.Fail("Should throw"); } catch (WebServiceException webEx) { Assert.That(webEx.Message, Is.EqualTo($"{request.Name} OnBeforeExecute OnExceptionAsync")); } }