public void Api_Submit_ValidWeatherRequest_ReturnsForecasts( int woeId, int expectedCount, ApiProxy apiProxy, IWeatherRequest weatherRequest, IWeatherResponse weatherResponse) { $"Given a woeId value of {woeId}" .x(() => weatherRequest = new WeatherRequest { WoeId = woeId }); "And an ApiProxy" .x(() => apiProxy = new ApiProxy(_metaWeatherService)); "When the weather request is submitted" .x( async() => weatherResponse = await apiProxy.SubmitWeatherRequest(weatherRequest).ConfigureAwait(false)); $"Then the weather response should return StatusCode HttpStatusCode.OK), and contain {expectedCount} Forecasts" .x( () => { using (new AssertionScope()) { weatherResponse.StatusCode.Should().Be(HttpStatusCode.OK); weatherResponse.Forecasts.Should().HaveCount(expectedCount); } }); }
public void Api_Submit_InvalidWeatherRequest_ReturnsNotFound( int woeId, ApiProxy apiProxy, IWeatherRequest weatherRequest, IWeatherResponse weatherResponse) { $"Given a woeId value of {woeId}" .x(() => weatherRequest = new WeatherRequest { WoeId = woeId }); "And an ApiProxy" .x(() => apiProxy = new ApiProxy(_metaWeatherService)); "When the weather request is submitted" .x( async() => weatherResponse = await apiProxy.SubmitWeatherRequest(weatherRequest).ConfigureAwait(false)); "Then the weather response should return StatusCode 404, and Forecasts should be empty" .x( () => { using (new AssertionScope()) { weatherResponse.StatusCode.Should().Be(HttpStatusCode.NotFound); weatherResponse.Forecasts.Should().BeNullOrEmpty(); } }); }
public IndexModel(ILogger <IndexModel> logger, IWeatherResponse weatherResponse) { _logger = logger; _weatherResponse = weatherResponse; }