Example #1
0
        public static void Start()
        {
            var weatherData      = new WeatherData();
            var currentDisplay   = new CurrentConditionalDisplay(weatherData);
            var statisticDisplay = new StatisticDisplay(weatherData);

            weatherData.SetMeasurements(80, 65, 30.4f);
            weatherData.SetMeasurements(82, 70, 29.2f);
            weatherData.SetMeasurements(78, 90, 29.2f);
        }
        public void WeatherDataAndCurrentConditionalDisplayTest()
        {
            Init();
            var weatherData    = new WeatherData();
            var weatherDisplay = new CurrentConditionalDisplay(weatherData);

            _verifyResult = null;
            weatherData.SetMeasurements(10, 10, 10);
            Assert.IsFalse(String.IsNullOrEmpty(_verifyResult));
            Assert.AreEqual(_verifyResult, String.Format("Current conditions: {0}F degrees and {1}% humidity", 10,
                                                         10));
        }
        static void Main(string[] args)
        {
            Console.WriteLine("*** Observer ***");

            WeatherData weatherData = new WeatherData();

            CurrentConditionalDisplay conditionalDisplay = new CurrentConditionalDisplay(weatherData);
            StatisticsDisplay         statisticsDisplay  = new StatisticsDisplay(weatherData);
            ForecastDisplay           forecastDisplay    = new ForecastDisplay(weatherData);
            HeatIndexDisplay          heatIndexDisplay   = new HeatIndexDisplay(weatherData);

            weatherData.SetMeasurements(26, 65, 760);
            weatherData.SetMeasurements(30, 70, 750);
            weatherData.SetMeasurements(0, 90, 790);

            #if (!vscode) // Add this for run from VS in order to console window will keep open
            Console.WriteLine("Press Enter for exit");
            Console.ReadLine();
            #endif
        }