public void ObserverTestCase()
        {
            var speedometer = new Speedometer();
            var speedMonitor = new SpeedMonitor(speedometer);
            var autogear = new AutomaticGearBox(speedometer);

            //Log
            speedometer.CurrentSpeed = 50;
            speedometer.CurrentSpeed = 10;
            speedometer.CurrentSpeed = 20;
            speedometer.CurrentSpeed = 150;

            Assert.IsTrue(speedMonitor.HasAlerts);
        }
예제 #2
0
 public AutomaticGearBox(Speedometer speedo)
 {
     speedo.ValueChanged += SpeedoValueChanged;
 }
예제 #3
0
 public SpeedMonitor(Speedometer speedo)
 {
     _alert = false;
     speedo.ValueChanged += SpeedoValueChanged;
 }