TestEvent.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Collections.Generic;
  3. using sccdlib;
  4. namespace csharp_tests
  5. {
  6. public class TestEvent
  7. {
  8. string name;
  9. string port;
  10. List<string> parameters;
  11. public TestEvent(string name, string port, List<string> parameters)
  12. {
  13. this.name = name;
  14. this.port = port;
  15. this.parameters = parameters;
  16. }
  17. public bool matches(Event output_event)
  18. {
  19. if (output_event == null)
  20. return false;
  21. if (output_event.getName() != this.name)
  22. return false;
  23. if (output_event.getPort() != this.port)
  24. return false;
  25. List<object> compare_parameters = new List<object>(output_event.getParameters());
  26. if (this.parameters.Count != compare_parameters.Count)
  27. return false;
  28. for (int i = 0; i < this.parameters.Count; i++)
  29. {
  30. if (this.parameters [i] != compare_parameters[i].ToString())
  31. return false;
  32. }
  33. return true;
  34. }
  35. public override string ToString()
  36. {
  37. return string.Format("(event name : {0}; port : {1}; parameters : [{2}])", this.name, this.port, string.Join(", ", this.parameters));
  38. }
  39. }
  40. }