public void ShouldTransitionGreenToYellow() { Stoplight light = new Stoplight(); light.Next(); Assert.AreEqual(Stoplight.Yellow, light.CurrentColor); }
public void ShouldTransitionYellowToRed() { Stoplight light = new Stoplight(); light.Next(); light.Next(); Assert.AreEqual(Stoplight.Red, light.CurrentColor); }
public void ShouldTransitionRedToGreen() { Stoplight light = new Stoplight(); light.Next(); light.Next(); light.Next(); Assert.AreEqual(Stoplight.Green, light.CurrentColor); }
public void ShouldLogMessageOnChange() { Stoplight light = new Stoplight(); MockLogger logger = new MockLogger(); light.Logger = logger; light.Next(); Assert.IsNotNull(logger.LastMessage); Assert.IsTrue(logger.LastMessage.StartsWith("LIGHT CHANGED TO")); }
public void ShouldRaiseChangedEventOnTransition() { bool eventFired = false; StoplightColors newColor = StoplightColors.Green; Stoplight light = new Stoplight(); light.Changed += delegate(object sender, LightChangedEventArgs e) { eventFired = true; newColor = e.CurrentColor; }; light.Next(); Assert.IsTrue(eventFired); Assert.AreEqual(Stoplight.Yellow, newColor); }
public void ShouldInitializeToGreen() { Stoplight light = new Stoplight(); Assert.AreEqual(Stoplight.Green, light.CurrentColor); }