public void GetActualAPICall() { IHttpClient client = new MyHttpClient(); MetaWeatherForecast sut = new MetaWeatherForecast(client); Forecast forecast; forecast = sut.GetWeatherForecast("prague"); Assert.False(string.IsNullOrEmpty(forecast.Condition)); }
public void GetWeatherForecastInPrague() { Mock <IHttpClient> mockClient = new Mock <IHttpClient>(); mockClient.Setup(m => m.GetStringAsync("https://www.metaweather.com/api/location/search/?query=prague")).Returns("[{\"title\":\"Prague\",\"location_type\":\"City\",\"woeid\":796597,\"latt_long\":\"50.079079, 14.433220\"}]"); mockClient.Setup(m => m.GetStringAsync("https://www.metaweather.com/api/location/796597")).Returns(MOCK_API_RESPONSE); MetaWeatherForecast sut = new MetaWeatherForecast(mockClient.Object); Forecast forecast; forecast = sut.GetWeatherForecast("prague"); Assert.Equal("Light Cloud", forecast.Condition); Assert.Equal(11.98, forecast.Temperature); }