public void InterceptsResponsesBeforeBeingParsed( [WithInterceptor(typeof(ReplaceEmptyBodyInterceptor))] JSendClient client) { using (client) { // Exercise system and verify outcome client.Awaiting(c => c.GetAsync <string>("http://localhost/users/empty-body")) .ShouldNotThrow(); } }
public void DoesNotParseInvalidResponses(string route, JSendClient client) { using (client) { // Exercise system and verify outcome client .Awaiting(c => c.GetAsync <User>("http://localhost/users/" + route)) .ShouldThrow <JSendParseException>(); } }
public void DoesNotParseInvalidResponses(string route, JSendClient client) { using (client) { // Exercise system and verify outcome client .Awaiting(c => c.GetAsync<User>("http://localhost/users/" + route)) .ShouldThrow<JSendParseException>(); } }
public void HttpClientExceptionsAreWrappedAndRethrown( HttpRequestMessage request, [MockHttpClient] HttpClient httpClient, [Greedy] JSendClient client) { // Fixture setup Mock.Get(httpClient) .Setup(c => c.SendAsync(request, It.IsAny <CancellationToken>())) .Throws <HttpRequestException>(); // Exercise system and verify outcome client .Awaiting(c => c.SendAsync <object>(request)) .ShouldThrow <JSendRequestException>() .WithInnerException <HttpRequestException>(); }
public void ParserExceptionsBubbleUp( HttpRequestMessage request, JSendParseException exception, [Frozen] IJSendParser parser, [Greedy, MockHttpClient] JSendClient client) { // Fixture setup Mock.Get(parser) .Setup(p => p.ParseAsync <object>(It.IsAny <JsonSerializerSettings>(), It.IsAny <HttpResponseMessage>())) .ThrowsAsync(exception); // Exercise system and verify outcome client .Awaiting(c => c.SendAsync <object>(request)) .ShouldThrow <JSendParseException>(); }