Пример #1
0
		public void ShouldFireEventAndUpdateScheduleOnForceChange()
		{
			MockStoplightTimer timer = new MockStoplightTimer();
			StoplightSchedule schedule = new StoplightSchedule(timer);
			TimeSpan greenSchedule = new TimeSpan(800);
			TimeSpan yellowSchedule = new TimeSpan(1500);
			TimeSpan redSchedule = new TimeSpan(100);
			schedule.Update(greenSchedule, yellowSchedule, redSchedule);

			bool eventFired = false;
			schedule.ChangeLight += delegate { eventFired = true; };

			schedule.ForceChange();
			Assert.IsTrue(eventFired);
			Assert.AreEqual(yellowSchedule, timer.Duration);
		}
Пример #2
0
		public void ShouldLogOnForceChange()
		{
			MockStoplightTimer timer = new MockStoplightTimer();
			MockLogger logger = new MockLogger();
			StoplightSchedule schedule = new StoplightSchedule(timer);
			schedule.Logger = logger;
			TimeSpan greenSchedule = new TimeSpan(800);
			TimeSpan yellowSchedule = new TimeSpan(1500);
			TimeSpan redSchedule = new TimeSpan(100);
			schedule.Update(greenSchedule, yellowSchedule, redSchedule);

			schedule.ForceChange();
			Assert.IsNotNull(logger.LastMessage);
			Assert.IsTrue(logger.LastMessage.StartsWith("FORCED CHANGE"));
		}