public async Task GetLocationsReturnsLocations() { //Setup var expectedResponse = GetTestResponse(); var httpResponse = new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(expectedResponse)), StatusCode = HttpStatusCode.Accepted, }; var fakeHttpRequestSender = A.Fake <IFakeHttpRequestSender>(); var fakeHttpMessageHandler = new FakeHttpMessageHandler(fakeHttpRequestSender); var httpClient = new HttpClient(fakeHttpMessageHandler); httpClient.BaseAddress = new System.Uri("https://dummy.com"); A.CallTo(() => fakeHttpRequestSender.Send(A <HttpRequestMessage> .Ignored)).Returns(httpResponse); var nationalStatisticsLocationService = new NationalStatisticsLocationService(fakeLogger, httpClient); //Act var actual = await nationalStatisticsLocationService.GetLocationsAsync().ConfigureAwait(false); //Assert actual.Should().BeEquivalentTo(expectedResponse.Locations); httpResponse.Dispose(); httpClient.Dispose(); fakeHttpMessageHandler.Dispose(); }