예제 #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);
        }
        public void UpdateForecast_OutputsCorrectString()
        {
            DisplayForecast forecastObserver = new DisplayForecast(weatherSubject, testOutput);

            weatherSubject.NotifyObservers(1, 2, 3);
            weatherSubject.NotifyObservers(2, 3, 4);
            string expectedForecast = "Getting warmer "+"and muggier, "+"showers expected later.";

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

            Assert.AreEqual(expectedForecast, actual, "Forecast observer updates and prints correctly");
        }