Ejemplo n.º 1
0
		public void ShouldTransitionYellowToRed()
		{
			Stoplight light = new Stoplight();
			light.Next();
			light.Next();

			Assert.AreEqual(Stoplight.Red, light.CurrentColor);
		}
Ejemplo n.º 2
0
		public void ShouldTransitionRedToGreen()
		{
			Stoplight light = new Stoplight();
			light.Next();
			light.Next();
			light.Next();

			Assert.AreEqual(Stoplight.Green, light.CurrentColor);
		}
Ejemplo n.º 3
0
		public void ShouldTransitionGreenToYellow()
		{
			Stoplight light = new Stoplight();
			light.Next();

			Assert.AreEqual(Stoplight.Yellow, light.CurrentColor);
		}
Ejemplo n.º 4
0
		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"));
		}
Ejemplo n.º 5
0
		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);
		}