Exemple #1
0
		public void ShouldTransitionGreenToYellow()
		{
			Stoplight light = new Stoplight();
			light.Next();

			Assert.AreEqual(Stoplight.Yellow, light.CurrentColor);
		}
Exemple #2
0
		public void ShouldTransitionYellowToRed()
		{
			Stoplight light = new Stoplight();
			light.Next();
			light.Next();

			Assert.AreEqual(Stoplight.Red, light.CurrentColor);
		}
Exemple #3
0
		public void ShouldTransitionRedToGreen()
		{
			Stoplight light = new Stoplight();
			light.Next();
			light.Next();
			light.Next();

			Assert.AreEqual(Stoplight.Green, light.CurrentColor);
		}
Exemple #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"));
		}
Exemple #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);
		}
Exemple #6
0
		public void ShouldInitializeToGreen()
		{
			Stoplight light = new Stoplight();
			Assert.AreEqual(Stoplight.Green, light.CurrentColor);
		}