Ejemplo n.º 1
0
        public void GetCityWeather_WithMatchingResults_ReturnsResults(
            [Frozen] ICityRepository cityRepository,
            [Frozen] IWeatherService weatherService,
            CityWeatherSearchService sut,
            City city,
            IEnumerable <Weather> weather,
            string cityName)
        {
            //Arrange
            cityRepository.GetCity(Arg.Is <string>(m => m == cityName))
            .Returns(city);

            weatherService.GetHourlyWeather(Arg.Is <Guid>(m => m == city.Id))
            .Returns(weather);

            // Act
            var cityWeather = sut.GetCityWeather(cityName);

            // Assert
            cityRepository.Received(1).GetCity(Arg.Is <string>(m => m == cityName));
            weatherService.Received(1).GetHourlyWeather(Arg.Is <Guid>(m => m == city.Id));

            cityWeather.City.Should().Be(city);
            cityWeather.HourlyWeather.Should().BeSameAs(weather);
        }
Ejemplo n.º 2
0
        public void GetCityWeather_WithValidCityName_DoesntThrow(
            CityWeatherSearchService sut,
            string cityName)
        {
            // Act
            Func <CityWeather> act = () => sut.GetCityWeather(cityName);

            act.Should().NotThrow <ArgumentNullException>();
        }
Ejemplo n.º 3
0
        public void GetCityWeather_WithValidCityName_CallsRepository(
            [Frozen] ICityRepository cityRepository,
            CityWeatherSearchService sut,
            string cityName)
        {
            // Act
            sut.GetCityWeather(cityName);

            cityRepository.Received(1).GetCity(Arg.Is <string>(m => m == cityName));
        }
Ejemplo n.º 4
0
        public void SearchAsync_WithNoWeatherResults_NoWeatherReturned(
            CityWeatherSearchService sut,
            string cityName)
        {
            // Act
            var weather = sut.GetCityWeather(cityName);

            weather.HourlyWeather.Should().BeEmpty();
            weather.City.Should().NotBeNull();
        }
Ejemplo n.º 5
0
        public void SearchAsync_WithWeatherResults_WeatherReturned(
            CityWeatherSearchService sut,
            IEnumerable <Weather> weather,
            string cityName)
        {
            // Act
            var cityWeather = sut.GetCityWeather(cityName);

            cityWeather.HourlyWeather.Should().BeSameAs(weather);
            cityWeather.City.Should().NotBeNull();
        }
Ejemplo n.º 6
0
 public void GetCityWeather_Guarded()
 {
     // Arrange
     Assert.Throws <ArgumentNullException>(() => _sut.GetCityWeather(null))
     .Message.Should().Be("Value cannot be null. (Parameter 'cityName')");
 }