Esempio n. 1
0
        public Form1()
        {
            InitializeComponent();

            //creates subject and observers and sets their listboxes
            weatherSubject = new WeatherMonitor();
            averageObserver = new DisplayAverage(weatherSubject, listBoxAverage);
            forecastObserver = new DisplayForecast(weatherSubject, listBoxForecast);
            temperatureObserver = new DisplayTemperature(weatherSubject, listBoxTemp);
        }
Esempio n. 2
0
        public Form1()
        {
            InitializeComponent();

            //creates subject and observers and sets their listboxes
            weatherSubject      = new WeatherMonitor();
            averageObserver     = new DisplayAverage(weatherSubject, listBoxAverage);
            forecastObserver    = new DisplayForecast(weatherSubject, listBoxForecast);
            temperatureObserver = new DisplayTemperature(weatherSubject, listBoxTemp);
        }
        public void UpdateAverage_OutputsCorrectString()
        {
            DisplayAverage averageObserver = new DisplayAverage(weatherSubject, testOutput);

            weatherSubject.NotifyObservers(1, 1, 1);
            weatherSubject.NotifyObservers(3, 3, 3);
            string expectedAverageTemp = "2";

            string actual = (string)testOutput.Items[0];

            Assert.AreEqual(expectedAverageTemp, actual, "Average observer updates and prints correctly");
        }