PageRenderTime 32ms CodeModel.GetById 19ms app.highlight 7ms 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
  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
  7using System;
  8
  9namespace NUnit.Core
 10{
 11    /// <summary>
 12	/// Abstract base for all types of TestAgents.
 13    /// A TestAgent provides services of locating,
 14    /// loading and running tests in a particular
 15    /// context such as an AppDomain or Process.
 16	/// </summary>
 17	public abstract class TestAgent : MarshalByRefObject, IDisposable
 18	{
 19		#region Fields
 20		/// <summary>
 21		/// Reference to the TestAgency that controls this agent
 22		/// </summary>
 23		private IAgency agency;
 24
 25		/// <summary>
 26		/// This agent's assigned id
 27		/// </summary>
 28		private Guid agentId;
 29		#endregion
 30
 31		#region Constructors
 32        /// <summary>
 33        /// Constructs a TestAgent
 34        /// </summary>
 35        /// <param name="agentId"></param>
 36        public TestAgent(Guid agentId)
 37        {
 38            this.agentId = agentId;
 39        }
 40
 41        /// <summary>
 42        /// Consructor used by TestAgency when creating
 43        /// an agent.
 44        /// </summary>
 45        /// <param name="agentId"></param>
 46        /// <param name="agency"></param>
 47		public TestAgent( Guid agentId, IAgency agency )
 48		{
 49			this.agency = agency;
 50			this.agentId = agentId;
 51		}
 52		#endregion
 53
 54		#region Properties
 55        /// <summary>
 56        /// The TestAgency with which this agent is asssociated,
 57        /// or null if the agent is not tied to an agency.
 58        /// </summary>
 59		public IAgency Agency
 60		{
 61			get { return agency; }
 62		}
 63
 64        /// <summary>
 65        /// A Guid that uniquely identifies this agent.
 66        /// </summary>
 67		public Guid Id
 68		{
 69			get { return agentId; }
 70		}
 71		#endregion
 72
 73		#region Absract Methods
 74        /// <summary>
 75        /// Starts the agent, performing any required initialization
 76        /// </summary>
 77        /// <returns></returns>
 78        public abstract bool Start();
 79
 80        /// <summary>
 81        /// Stops the agent, releasing any resources
 82        /// </summary>
 83        public abstract void Stop();
 84
 85		/// <summary>
 86		///  Creates a runner using a given runner id
 87		/// </summary>
 88        public abstract TestRunner CreateRunner(int runnerId);
 89		#endregion
 90
 91        #region IDisposable Members
 92        /// <summary>
 93        /// Dispose is overridden to stop the agent
 94        /// </summary>
 95        public void Dispose()
 96        {
 97            this.Stop();
 98        }
 99        #endregion
100
101        #region InitializeLifeTimeService
102        /// <summary>
103        /// Overridden to cause object to live indefinitely
104        /// </summary>
105        public override object InitializeLifetimeService()
106        {
107            return null;
108        }
109        #endregion
110    }
111}