public async Task InterceptsParsedResponses( [FrozenWithoutAutoProperties] InterceptorSpy spy, [WithInterceptor(typeof(InterceptorSpy))] JSendClient client) { using (client) using (var response = await client.GetAsync <string>("http://localhost/users/get")) { // Exercise system and verify outcome spy.ResponseParsedContext.Should().NotBeNull(); spy.ResponseParsedContext.As <ResponseParsedContext <string> >() .JSendResponse.Should().Be(response); } }
public async Task InterceptsExceptions( [FrozenWithoutAutoProperties] InterceptorSpy spy, [WithInterceptor(typeof(InterceptorSpy))] JSendClient client) { using (client) { try { await client.GetAsync <string>("http://localhost/users/non-jsend"); } catch { } // Exercise system and verify outcome spy.ExceptionContext.Should().NotBeNull(); spy.ExceptionContext.Exception .Should().BeOfType <JSendParseException>(); } }