1 // ****************************************************************
2 // This is free software licensed under the NUnit license. You
3 // may obtain a copy of the license as well as information regarding
4 // copyright ownership at http://nunit.org/?p=license&r=2.4.
5 // ****************************************************************
9 using System
.Collections
;
13 /// DelegatingTestRUnner is the abstract base for core TestRunner
14 /// implementations that operate by controlling a downstream
15 /// TestRunner. All calls are simply passed on to the
16 /// TestRunner that is provided to the constructor.
18 /// Although the class is abstract, it has no abstract
19 /// methods specified because each implementation will
20 /// need to override different methods. All methods are
21 /// specified using interface syntax and the derived class
22 /// must explicitly implement TestRunner in order to
23 /// redefine the selected methods.
25 public abstract class ProxyTestRunner
: MarshalByRefObject
, TestRunner
27 #region Instance Variables
32 protected int runnerID
;
35 /// The downstream TestRunner
37 private TestRunner testRunner
;
40 /// The event listener for the currently running test
42 protected EventListener listener
;
47 public ProxyTestRunner(TestRunner testRunner
)
49 this.testRunner
= testRunner
;
50 this.runnerID
= testRunner
.ID
;
54 /// Protected constructor for runners that delay creation
55 /// of their downstream runner.
57 protected ProxyTestRunner( int runnerID
)
59 this.runnerID
= runnerID
;
66 get { return runnerID; }
69 public virtual bool Running
71 get { return testRunner != null && testRunner.Running; }
74 public virtual IList AssemblyInfo
76 get { return testRunner == null ? null : testRunner.AssemblyInfo; }
79 public virtual ITest Test
81 get { return testRunner == null ? null : testRunner.Test; }
84 public virtual TestResult TestResult
86 get { return testRunner == null ? null : testRunner.TestResult; }
90 /// Protected property copies any settings to the downstream test runner
91 /// when it is set. Derived runners overriding this should call the base
92 /// or copy the settings themselves.
94 protected virtual TestRunner TestRunner
96 get { return testRunner; }
97 set { testRunner = value; }
101 #region Load and Unload Methods
102 public virtual bool Load( TestPackage package
)
104 return this.testRunner
.Load( package
);
107 public virtual void Unload()
109 if ( this.testRunner
!= null )
110 this.testRunner
.Unload();
114 #region CountTestCases
115 public virtual int CountTestCases( ITestFilter filter
)
117 return this.testRunner
.CountTestCases( filter
);
121 #region Methods for Running Tests
122 public virtual TestResult
Run(EventListener listener
)
124 // Save active listener for derived classes
125 this.listener
= listener
;
126 return this.testRunner
.Run(listener
);
129 public virtual TestResult
Run(EventListener listener
, ITestFilter filter
)
131 // Save active listener for derived classes
132 this.listener
= listener
;
133 return this.testRunner
.Run(listener
, filter
);
136 public virtual void BeginRun( EventListener listener
)
138 // Save active listener for derived classes
139 this.listener
= listener
;
140 this.testRunner
.BeginRun( listener
);
143 public virtual void BeginRun( EventListener listener
, ITestFilter filter
)
145 // Save active listener for derived classes
146 this.listener
= listener
;
147 this.testRunner
.BeginRun( listener
, filter
);
150 public virtual TestResult
EndRun()
152 return this.testRunner
.EndRun();
155 public virtual void CancelRun()
157 this.testRunner
.CancelRun();
160 public virtual void Wait()
162 this.testRunner
.Wait();
166 #region InitializeLifetimeService Override
167 public override object InitializeLifetimeService()