public async Task MarkAjaxRequestAsHealthyReturnsAppropriateResponseWhenPatchMessageSent(bool success, HttpStatusCode statusCode) { // Arrange var httpClientFactory = A.Fake <IHttpClientFactory>(); using var httpResponse = new HttpResponseMessage { StatusCode = statusCode }; var fakeHttpRequestSender = A.Fake <IFakeHttpRequestSender>(); var fakeILogger = A.Fake <ILogger <AppRegistryService> >(); using var fakeHttpMessageHandler = new FakeHttpMessageHandler(fakeHttpRequestSender); using var httpClient = new HttpClient(fakeHttpMessageHandler) { BaseAddress = new Uri("http://baseaddress.com") }; A.CallTo(() => fakeHttpRequestSender.Send(A <HttpRequestMessage> .Ignored)).Returns(httpResponse); A.CallTo(() => httpClientFactory.CreateClient(A <string> .Ignored)).Returns(httpClient); var appRegistryService = new AppRegistryService(httpClientFactory, fakeILogger); // Act var response = await appRegistryService.MarkAjaxRequestAsHealthy("path1", "ajax-1").ConfigureAwait(false); // Assert Assert.Equal(success, response); }
public async Task MarkAjaxRequestAsHealthyCatchesExceoptionTest() { // Arrange var httpClientFactory = A.Fake <IHttpClientFactory>(); var fakeILogger = A.Fake <ILogger <AppRegistryService> >(); A.CallTo(() => httpClientFactory.CreateClient(A <string> .Ignored)).Throws <HttpRequestException>(); var appRegistryService = new AppRegistryService(httpClientFactory, fakeILogger); // Act var response = await appRegistryService.MarkAjaxRequestAsHealthy("path1", "ajax-1").ConfigureAwait(false); // Assert Assert.False(response); }