Beispiel #1
0
        public async Task ShouldGetWeatherDataByWmoFromEndpoint()
        {
            const string returnData             = @"[
						
							{""Time"": ""12.30pm"", ""lat"": -35, ""air_temp"": 10.3},
							{""Time"": ""12.30pm"", ""lat"": -35, ""air_temp"": 3},
							{""Time"": ""12.30pm"", ""lat"": -35, ""air_temp"": -3},
							{""Time"": ""12.30pm"", ""lat"": -35, ""air_temp"": 23.6},
							{""Time"": ""12.30pm"", ""lat"": -35, ""air_temp"": 13.9}
						]"                        ;
            var          fakeHttpMessageHandler = new FakeHttpMessageHandler(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(_json, Encoding.UTF8, "application/json")
            });


            var fakeHttpClient = new HttpClient(fakeHttpMessageHandler)
            {
                BaseAddress = new Uri(_url)
            };

            _httpClientFactoryMock.CreateClient().Returns(fakeHttpClient);

            var sut = new BomService(fakeHttpClient);

            var actual = await sut.GetWeatherDataAsync(123);

            var expected = JsonConvert.DeserializeObject <IEnumerable <JToken> >(returnData);

            actual.Should().BeEquivalentTo(expected);
        }