Пример #1
0
        public async void CantParseUnitsOfMeasurementReturnsBadRequest()
        {
            var controller = new WeatherController(null);

            var result = await controller.GetWeather(Location, "a", "b");
            result.Should().BeOfType<BadRequestResult>();
        }
Пример #2
0
        public async void ReturnsJsonResult()
        {
            WeatherApiResult resultA = TestData.GetTestWeatherResult(10, 15);
            WeatherApiResult resultB = TestData.GetTestWeatherResult(11, 20);
            var results = new List<WeatherApiResult> {resultA, resultB};

            var service = new Mock<IWeatherAggregatorService>();
            service.Setup(o => o.GetWeatherResults(Location)).ReturnsAsync(results);

            var controller = new WeatherController(service.Object);

            var result = await controller.GetWeather(Location, "DegreeCelsius", "KilometerPerHour");

            result.Should().BeOfType<JsonResult<WeatherApiResult>>();

            var jsonResult = result as JsonResult<WeatherApiResult>;
            jsonResult.Content.Should().NotBeNull();
        }
Пример #3
0
 public async void NullModelReturnsBadRequest()
 {
     var controller = new WeatherController(null);
     var result = await controller.GetWeather(null, null, null);
     result.Should().BeOfType<BadRequestResult>();
 }