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();
     }
 }
예제 #2
0
 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>();
     }
 }
예제 #3
0
 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>();
     }
 }
예제 #4
0
 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>();
 }
예제 #5
0
 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>();
 }