Guest User

Untitled

a guest
Oct 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. namespace Mjunit.Clients.GHI
  2. {
  3. public class LedTestClient : ITestClient
  4. {
  5. private readonly MulticolorLed _led;
  6.  
  7. private bool _isBlinking;
  8. private bool _hasFailed;
  9.  
  10. public LedTestClient(MulticolorLed led)
  11. {
  12. _led = led;
  13. Init();
  14. }
  15.  
  16. public void Init()
  17. {
  18. _led.TurnOff();
  19. _isBlinking = false;
  20. _hasFailed = false;
  21. }
  22.  
  23. public void OnTestRunStart(object sender,
  24. TestRunEventHandlerArgs args)
  25. {
  26. Init();
  27. }
  28.  
  29. public void OnTestRunComplete(object sender,
  30. TestRunEventHandlerArgs args)
  31. {
  32. OnAnyTestComplete(sender, args);
  33. }
  34.  
  35. private void OnAnyTestComplete(object sender,
  36. TestRunEventHandlerArgs args)
  37. {
  38. if (!_hasFailed)
  39. {
  40. if (args.Result.Outcome == TestOutcome.Fail)
  41. {
  42. _led.BlinkRepeatedly(Colors.Red);
  43. _hasFailed = true;
  44. }
  45. else if (!_isBlinking)
  46. {
  47. _led.BlinkRepeatedly(Colors.Green);
  48. _isBlinking = true;
  49. }
  50. }
  51. }
  52.  
  53. public void OnSingleTestComplete(object sender,
  54. TestRunEventHandlerArgs args)
  55. {
  56. OnAnyTestComplete(sender, args);
  57. }
  58. }
  59. }
Add Comment
Please, Sign In to add comment