public async Task TestUsingMachine() { var link = new Link() { Target = new Uri("http://localhost") }; var responseMachine = new HttpResponseMachine(); var notFoundHandler = new NotFoundHandler(new OkHandler(null)); responseMachine .When(HttpStatusCode.NotFound) .Then((l, r) => notFoundHandler.HandleResponseAsync(l, r)); var client = new HttpClient(new FakeHandler() { Response = new HttpResponseMessage() { StatusCode = HttpStatusCode.NotFound } }); await client.FollowLinkAsync(link, responseMachine); Assert.True(notFoundHandler.NotFound); }
public async Task Test() { var link = new Link(){Target = new Uri("http://localhost")}; var notFoundHandler = new NotFoundHandler(new OkHandler(null)); var machine = new HttpResponseMachine(); machine.AddResponseHandler(notFoundHandler.HandleResponseAsync, HttpStatusCode.NotFound); var client = new HttpClient(new FakeHandler() {Response = new HttpResponseMessage() {StatusCode = HttpStatusCode.NotFound}}); await client.FollowLinkAsync(link,machine); Assert.True(notFoundHandler.NotFound); }