示例#1
0
        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);
                }
            });
        }
示例#2
0
        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();
                }
            });
        }
示例#3
0
 public IndexModel(ILogger <IndexModel> logger, IWeatherResponse weatherResponse)
 {
     _logger          = logger;
     _weatherResponse = weatherResponse;
 }