Exemplo n.º 1
0
        public void AverageTemperatureTest()
        {
            Dictionary <DateTime, float> temperatureData = PrepareTemperatureData(10f, 30f);
            float avg = WeatherStatisticsCalculator.AvgTemperature(temperatureData);

            Assert.AreEqual(20f, avg);
        }
        /// Solution through 1st approach - where this will send data to WeatherStatisticsCalculator
        ///
        /// Pros - Simple
        ///
        /// Cons - Breaking changes in WeatherStatisticsCalculator will break this class as well.
        public void DoWeatherStatistics()
        {
            Tuple <DateTime, float> coldestday = WeatherStatisticsCalculator.ColdestDay(_temperatureData);

            Console.WriteLine($"Coldest day was {coldestday.Item1.ToShortDateString()} with {coldestday.Item2} temperature !!>");

            Tuple <DateTime, float> hotestday = WeatherStatisticsCalculator.HotestDay(_temperatureData);

            Console.WriteLine($"Hotestday day was {hotestday.Item1.ToShortDateString()} with {hotestday.Item2} temperature !!>");

            float avgTemperature = WeatherStatisticsCalculator.AvgTemperature(_temperatureData);

            Console.WriteLine($"Average temperature was {avgTemperature:f2}");
        }