public async Task ShouldGetTemperatureDataFromEndpoint() { const string url = "http://good.uri"; const string json = @"{ ""observations"": { ""data"": [ {""air_temp"": 10.3}, {""air_temp"": 3}, {""air_temp"": -3}, {""air_temp"": 23.6}, {""air_temp"": 13.9} ]}}" ; var httpClientFactoryMock = Substitute.For <IHttpClientFactory>(); var fakeHttpMessageHandler = new FakeHttpMessageHandler(new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = new StringContent(json, Encoding.UTF8, "application/json") }); var expected = new List <double> { 10.3, 3, -3, 23.6, 13.9 }; var fakeHttpClient = new HttpClient(fakeHttpMessageHandler) { BaseAddress = new Uri(url) }; httpClientFactoryMock.CreateClient().Returns(fakeHttpClient); var sut = new BomService(fakeHttpClient); var actual = await sut.GetTemperatureDataAsync(); actual.Should().BeEquivalentTo(expected); }