PageRenderTime 100ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/src/NUnit/interfaces/TestAgent.cs

#
C# | 111 lines | 49 code | 12 blank | 50 comment | 0 complexity | 8fce262ad129a3a24d9254199df91c7f MD5 | raw file
Possible License(s): GPL-2.0
  1. // ****************************************************************
  2. // Copyright 2008, Charlie Poole
  3. // This is free software licensed under the NUnit license. You may
  4. // obtain a copy of the license at http://nunit.org
  5. // ****************************************************************
  6. using System;
  7. namespace NUnit.Core
  8. {
  9. /// <summary>
  10. /// Abstract base for all types of TestAgents.
  11. /// A TestAgent provides services of locating,
  12. /// loading and running tests in a particular
  13. /// context such as an AppDomain or Process.
  14. /// </summary>
  15. public abstract class TestAgent : MarshalByRefObject, IDisposable
  16. {
  17. #region Fields
  18. /// <summary>
  19. /// Reference to the TestAgency that controls this agent
  20. /// </summary>
  21. private IAgency agency;
  22. /// <summary>
  23. /// This agent's assigned id
  24. /// </summary>
  25. private Guid agentId;
  26. #endregion
  27. #region Constructors
  28. /// <summary>
  29. /// Constructs a TestAgent
  30. /// </summary>
  31. /// <param name="agentId"></param>
  32. public TestAgent(Guid agentId)
  33. {
  34. this.agentId = agentId;
  35. }
  36. /// <summary>
  37. /// Consructor used by TestAgency when creating
  38. /// an agent.
  39. /// </summary>
  40. /// <param name="agentId"></param>
  41. /// <param name="agency"></param>
  42. public TestAgent( Guid agentId, IAgency agency )
  43. {
  44. this.agency = agency;
  45. this.agentId = agentId;
  46. }
  47. #endregion
  48. #region Properties
  49. /// <summary>
  50. /// The TestAgency with which this agent is asssociated,
  51. /// or null if the agent is not tied to an agency.
  52. /// </summary>
  53. public IAgency Agency
  54. {
  55. get { return agency; }
  56. }
  57. /// <summary>
  58. /// A Guid that uniquely identifies this agent.
  59. /// </summary>
  60. public Guid Id
  61. {
  62. get { return agentId; }
  63. }
  64. #endregion
  65. #region Absract Methods
  66. /// <summary>
  67. /// Starts the agent, performing any required initialization
  68. /// </summary>
  69. /// <returns></returns>
  70. public abstract bool Start();
  71. /// <summary>
  72. /// Stops the agent, releasing any resources
  73. /// </summary>
  74. public abstract void Stop();
  75. /// <summary>
  76. /// Creates a runner using a given runner id
  77. /// </summary>
  78. public abstract TestRunner CreateRunner(int runnerId);
  79. #endregion
  80. #region IDisposable Members
  81. /// <summary>
  82. /// Dispose is overridden to stop the agent
  83. /// </summary>
  84. public void Dispose()
  85. {
  86. this.Stop();
  87. }
  88. #endregion
  89. #region InitializeLifeTimeService
  90. /// <summary>
  91. /// Overridden to cause object to live indefinitely
  92. /// </summary>
  93. public override object InitializeLifetimeService()
  94. {
  95. return null;
  96. }
  97. #endregion
  98. }
  99. }