public void CurrentConditionsSubscriber_NotifyFirstChange_Temperature() { var wdp = new WeatherDataProvider(); var ccs = new CurrentConditionsSubscriber(wdp); wdp.SetMeasurements(10, 20, 30); Assert.That(ccs.Data.Temperature, Is.EqualTo(10.0).Within(0.001)); }
public void CurrentConditionsSubscriber_NotifySecondChange_Temperature() { var wdp = new WeatherDataProvider(); var ccs = new CurrentConditionsSubscriber(wdp); wdp.Notify(10, 20, 30); wdp.Notify(40, 50, 60); Assert.That(ccs.Data.Temperature, Is.EqualTo(40.0).Within(0.001)); }
static void Main(string[] args) { //create new subscribers ISubscriber rain = new RainConditionsSubscriber(60); ISubscriber curr = new CurrentConditionsSubscriber(60, 60, 60); ISubscriber pred = new WeatherPredictSubscriber(56, 40); //register subscribers WeatherData weather = new WeatherData(74, 24, 60); weather.RegisterSubscriber(rain); weather.RegisterSubscriber(curr); weather.RegisterSubscriber(pred); //update weather conditions weather.SetWeatherData(76, 24, 60); weather.SetWeatherData(84, 44, 80); Console.ReadKey(); }