Exemple #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);
        }
Exemple #2
0
        public CityWeatherSearchServiceWithoutAutoFixtureFixture()
        {
            _cityRepository = Substitute.For <ICityRepository>();
            _weatherService = Substitute.For <IWeatherService>();

            _sut = new CityWeatherSearchService(_weatherService, _cityRepository);
        }
Exemple #3
0
        public void GetCityWeather_WithValidCityName_DoesntThrow(
            CityWeatherSearchService sut,
            string cityName)
        {
            // Act
            Func <CityWeather> act = () => sut.GetCityWeather(cityName);

            act.Should().NotThrow <ArgumentNullException>();
        }
Exemple #4
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));
        }
Exemple #5
0
        public void SearchAsync_WithNoWeatherResults_NoWeatherReturned(
            CityWeatherSearchService sut,
            string cityName)
        {
            // Act
            var weather = sut.GetCityWeather(cityName);

            weather.HourlyWeather.Should().BeEmpty();
            weather.City.Should().NotBeNull();
        }
Exemple #6
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();
        }