1 // ****************************************************************
\r
2 // Copyright 2007, Charlie Poole
\r
3 // This is free software licensed under the NUnit license. You may
\r
4 // obtain a copy of the license at http://nunit.org/?p=license&r=2.4
\r
5 // ****************************************************************
\r
10 using System.Collections;
\r
15 /// ProxyTestRunner is the abstract base for all client-side
\r
16 /// TestRunner implementations that delegate to a remote
\r
17 /// TestRunner. All calls are simply passed on to the
\r
18 /// TestRunner that is provided to the constructor.
\r
20 /// This class is similar to DelegatingTestRunner in the
\r
21 /// NUnit core, but is separate because of how it is used.
\r
23 /// Although the class is abstract, it has no abstract
\r
24 /// methods specified because each implementation will
\r
25 /// need to override different methods. All methods are
\r
26 /// specified using interface syntax and the derived class
\r
27 /// must explicitly implement TestRunner in order to
\r
28 /// redefine the selected methods.
\r
30 public abstract class ProxyTestRunner : TestRunner
\r
32 #region Instance Variables
\r
37 protected int runnerID;
\r
40 /// The downstream TestRunner
\r
42 private TestRunner testRunner;
\r
45 /// The event listener for the currently running test
\r
47 protected EventListener listener;
\r
51 #region Construction
\r
52 public ProxyTestRunner(TestRunner testRunner)
\r
54 this.testRunner = testRunner;
\r
55 this.runnerID = testRunner.ID;
\r
59 /// Protected constructor for runners that create their own
\r
60 /// specialized downstream runner.
\r
62 protected ProxyTestRunner( int runnerID )
\r
64 this.runnerID = runnerID;
\r
69 public virtual int ID
\r
71 get { return runnerID; }
\r
74 public virtual bool Running
\r
76 get { return testRunner != null && testRunner.Running; }
\r
79 public virtual IList AssemblyInfo
\r
81 get { return testRunner == null ? null : testRunner.AssemblyInfo; }
\r
84 public virtual ITest Test
\r
86 get { return testRunner == null ? null : testRunner.Test; }
\r
89 public virtual TestResult TestResult
\r
91 get { return testRunner == null ? null : testRunner.TestResult; }
\r
95 /// Protected property copies any settings to the downstream test runner
\r
96 /// when it is set. Derived runners overriding this should call the base
\r
97 /// or copy the settings themselves.
\r
99 protected virtual TestRunner TestRunner
\r
101 get { return testRunner; }
\r
102 set { testRunner = value; }
\r
106 #region Load and Unload Methods
\r
107 public virtual bool Load( TestPackage package )
\r
109 return this.testRunner.Load( package );
\r
112 public virtual void Unload()
\r
114 if ( this.testRunner != null )
\r
115 this.testRunner.Unload();
\r
119 #region CountTestCases
\r
120 public virtual int CountTestCases( ITestFilter filter )
\r
122 return this.testRunner.CountTestCases( filter );
\r
126 #region Methods for Running Tests
\r
127 public virtual TestResult Run(EventListener listener)
\r
129 // Save active listener for derived classes
\r
130 this.listener = listener;
\r
131 return this.testRunner.Run(listener);
\r
134 public virtual TestResult Run(EventListener listener, ITestFilter filter)
\r
136 // Save active listener for derived classes
\r
137 this.listener = listener;
\r
138 return this.testRunner.Run(listener, filter);
\r
141 public virtual void BeginRun( EventListener listener )
\r
143 // Save active listener for derived classes
\r
144 this.listener = listener;
\r
145 this.testRunner.BeginRun( listener );
\r
148 public virtual void BeginRun( EventListener listener, ITestFilter filter )
\r
150 // Save active listener for derived classes
\r
151 this.listener = listener;
\r
152 this.testRunner.BeginRun( listener, filter );
\r
155 public virtual TestResult EndRun()
\r
157 return this.testRunner.EndRun();
\r
160 public virtual void CancelRun()
\r
162 this.testRunner.CancelRun();
\r
165 public virtual void Wait()
\r
167 this.testRunner.Wait();
\r
171 #region InitializeLifetimeService Override
\r
172 // public override object InitializeLifetimeService()
\r