Created
June 14, 2012 21:03
-
-
Save einarwh/2932939 to your computer and use it in GitHub Desktop.
A simple μnit test client, using a multicolored LED light.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Mjunit.Clients.GHI | |
{ | |
public class LedTestClient : ITestClient | |
{ | |
private readonly MulticolorLed _led; | |
private bool _isBlinking; | |
private bool _hasFailed; | |
public LedTestClient(MulticolorLed led) | |
{ | |
_led = led; | |
Init(); | |
} | |
public void Init() | |
{ | |
_led.TurnOff(); | |
_isBlinking = false; | |
_hasFailed = false; | |
} | |
public void OnTestRunStart(object sender, | |
TestRunEventHandlerArgs args) | |
{ | |
Init(); | |
} | |
public void OnTestRunComplete(object sender, | |
TestRunEventHandlerArgs args) | |
{ | |
OnAnyTestComplete(sender, args); | |
} | |
private void OnAnyTestComplete(object sender, | |
TestRunEventHandlerArgs args) | |
{ | |
if (!_hasFailed) | |
{ | |
if (args.Result.Outcome == TestOutcome.Fail) | |
{ | |
_led.BlinkRepeatedly(Colors.Red); | |
_hasFailed = true; | |
} | |
else if (!_isBlinking) | |
{ | |
_led.BlinkRepeatedly(Colors.Green); | |
_isBlinking = true; | |
} | |
} | |
} | |
public void OnSingleTestComplete(object sender, | |
TestRunEventHandlerArgs args) | |
{ | |
OnAnyTestComplete(sender, args); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment