Esempio n. 1
0
        public async Task UnableToFindMinimumTempSpreadWhenNoDays()
        {
            var sut = new DailyWeatherService(_mockFileParser.Object, _mockLoggingService.Object);

            var result = await sut.GetWeatherWithSmallestTempSpread();

            Assert.Equal(DailyWeather.EmptyDailyWeather, result);
        }
Esempio n. 2
0
        public async Task FindsMinimumTempSpreadSingleDay()
        {
            var weather1 = new DailyWeather(1, 2, 10);

            _weatherData.Add(weather1);

            var sut = new DailyWeatherService(_mockFileParser.Object, _mockLoggingService.Object);

            var result = await sut.GetWeatherWithSmallestTempSpread();

            Assert.Equal(weather1.DayOfMonth, result.DayOfMonth);
        }
Esempio n. 3
0
        public async Task FindsMinimumTempSpreadAmongManyDays()
        {
            var weather1 = new DailyWeather(1, 2, 10);
            var weather2 = new DailyWeather(2, 4, 6);
            var weather3 = new DailyWeather(3, 11, 14);

            _weatherData.AddRange(new DailyWeather[] { weather1, weather2, weather3 });

            var sut = new DailyWeatherService(_mockFileParser.Object, _mockLoggingService.Object);

            var result = await sut.GetWeatherWithSmallestTempSpread();

            Assert.Equal(weather2.DayOfMonth, result.DayOfMonth);
        }
Esempio n. 4
0
        public static async Task Main()
        {
            BuildDependencies();

            // For a real world application, we would want this file path configurable.
            // For now, this file is added to the project and copied to the output
            // directory for simplicity._dailyWeatherFileParser

            var dailyWeatherService = new DailyWeatherService(_dailyWeatherFileParser, _loggingService);

            var programRunner = new ConsoleDifferentiableDisplayer <int>(dailyWeatherService);

            await programRunner.DisplayMinDifferential <IDailyTemperature>(
                (result) => $"Day number with minimum temperature spread: { result.DayOfMonth }",
                "Unable to determine day number with minimum temperature spread. See logs.",
                DailyTemperature.EmptyDailyWeather).ConfigureAwait(false);
        }
Esempio n. 5
0
        public static async Task Main()
        {
            BuildDependencies();

            // For a real world application, we would want this file path configurable.
            // For now, this file is added to the project and copied to the output
            // directory for simplicity._dailyWeatherFileParser

            var dailyWeatherService = new DailyWeatherService(_dailyWeatherFileParser, _loggingService);

            var smallestSpreadDay = await dailyWeatherService.GetWeatherWithSmallestTempSpread().ConfigureAwait(false);

            if ((DailyWeather)smallestSpreadDay != DailyWeather.EmptyDailyWeather)
            {
                Console.Out.WriteLine($"Day number with minimum temperature spread: {smallestSpreadDay.DayOfMonth}");
            }
            else
            {
                Console.Out.WriteLine("Unable to determine day number with minimum temperature spread. See logs.");
            }
            Console.In.ReadLine();
        }