**** Merged from MCS ****
[mono-project.git] / mcs / nunit20 / util / TestEventDispatcher.cs
blob3c4a28968b98913e6bb26df3d5de0d5ad77238e4
1 #region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
2 /************************************************************************************
4 ' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
5 ' Copyright 2000-2002 Philip A. Craig
7 ' This software is provided 'as-is', without any express or implied warranty. In no
8 ' event will the authors be held liable for any damages arising from the use of this
9 ' software.
11 ' Permission is granted to anyone to use this software for any purpose, including
12 ' commercial applications, and to alter it and redistribute it freely, subject to the
13 ' following restrictions:
15 ' 1. The origin of this software must not be misrepresented; you must not claim that
16 ' you wrote the original software. If you use this software in a product, an
17 ' acknowledgment (see the following) in the product documentation is required.
19 ' Portions Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
20 ' or Copyright 2000-2002 Philip A. Craig
22 ' 2. Altered source versions must be plainly marked as such, and must not be
23 ' misrepresented as being the original software.
25 ' 3. This notice may not be removed or altered from any source distribution.
27 '***********************************************************************************/
28 #endregion
30 using System;
31 using System.Collections;
32 using NUnit.Core;
34 namespace NUnit.Util
36 /// <summary>
37 /// Helper class used to dispatch test events
38 /// </summary>
39 public class ProjectEventDispatcher : TestEventDispatcher, IProjectEvents
41 #region Events
43 // Project loading events
44 public event TestProjectEventHandler ProjectLoading;
45 public event TestProjectEventHandler ProjectLoaded;
46 public event TestProjectEventHandler ProjectLoadFailed;
47 public event TestProjectEventHandler ProjectUnloading;
48 public event TestProjectEventHandler ProjectUnloaded;
49 public event TestProjectEventHandler ProjectUnloadFailed;
51 // Test loading events
52 // public event TestEventHandler TestLoading;
53 // public event TestEventHandler TestLoaded;
54 // public event TestEventHandler TestLoadFailed;
56 // public event TestEventHandler TestReloading;
57 // public event TestEventHandler TestReloaded;
58 // public event TestEventHandler TestReloadFailed;
60 // public event TestEventHandler TestUnloading;
61 // public event TestEventHandler TestUnloaded;
62 // public event TestEventHandler TestUnloadFailed;
64 // // Test running events
65 // public event TestEventHandler RunStarting;
66 // public event TestEventHandler RunFinished;
67 //
68 // public event TestEventHandler SuiteStarting;
69 // public event TestEventHandler SuiteFinished;
71 // public event TestEventHandler TestStarting;
72 // public event TestEventHandler TestFinished;
74 // public event TestEventHandler TestException;
76 #endregion
78 #region Methods for Firing Events
80 private void Fire(
81 TestEventHandler handler, TestEventArgs e )
83 if ( handler != null )
84 handler( this, e );
87 private void Fire(
88 TestProjectEventHandler handler, TestProjectEventArgs e )
90 if ( handler != null )
91 handler( this, e );
94 public void FireProjectLoading( string fileName )
96 Fire(
97 ProjectLoading,
98 new TestProjectEventArgs( TestProjectAction.ProjectLoading, fileName ) );
101 public void FireProjectLoaded( string fileName )
103 Fire(
104 ProjectLoaded,
105 new TestProjectEventArgs( TestProjectAction.ProjectLoaded, fileName ) );
108 public void FireProjectLoadFailed( string fileName, Exception exception )
110 Fire(
111 ProjectLoadFailed,
112 new TestProjectEventArgs( TestProjectAction.ProjectLoadFailed, fileName, exception ) );
115 public void FireProjectUnloading( string fileName )
117 Fire(
118 ProjectUnloading,
119 new TestProjectEventArgs( TestProjectAction.ProjectUnloading, fileName ) );
122 public void FireProjectUnloaded( string fileName )
124 Fire(
125 ProjectUnloaded,
126 new TestProjectEventArgs( TestProjectAction.ProjectUnloaded, fileName ) );
129 public void FireProjectUnloadFailed( string fileName, Exception exception )
131 Fire(
132 ProjectUnloadFailed,
133 new TestProjectEventArgs( TestProjectAction.ProjectUnloadFailed, fileName, exception ) );
136 // public void FireTestLoading( string fileName )
137 // {
138 // Fire(
139 // TestLoading,
140 // new TestEventArgs( TestAction.TestLoading, fileName ) );
141 // }
143 // public void FireTestLoaded( string fileName, ITest test )
144 // {
145 // Fire(
146 // TestLoaded,
147 // new TestEventArgs( TestAction.TestLoaded, fileName, test ) );
148 // }
150 // public void FireTestLoadFailed( string fileName, Exception exception )
151 // {
152 // Fire(
153 // TestLoadFailed,
154 // new TestEventArgs( TestAction.TestLoadFailed, fileName, exception ) );
155 // }
157 // public void FireTestUnloading( string fileName, ITest test )
158 // {
159 // Fire(
160 // TestUnloading,
161 // new TestEventArgs( TestAction.TestUnloading, fileName, test ) );
162 // }
164 // public void FireTestUnloaded( string fileName, ITest test )
165 // {
166 // Fire(
167 // TestUnloaded,
168 // new TestEventArgs( TestAction.TestUnloaded, fileName, test ) );
169 // }
171 // public void FireTestUnloadFailed( string fileName, Exception exception )
172 // {
173 // Fire(
174 // TestUnloadFailed,
175 // new TestEventArgs( TestAction.TestUnloadFailed, fileName, exception ) );
176 // }
178 // public void FireTestReloading( string fileName, ITest test )
179 // {
180 // Fire(
181 // TestReloading,
182 // new TestEventArgs( TestAction.TestReloading, fileName, test ) );
183 // }
185 // public void FireTestReloaded( string fileName, ITest test )
186 // {
187 // Fire(
188 // TestReloaded,
189 // new TestEventArgs( TestAction.TestReloaded, fileName, test ) );
190 // }
192 // public void FireTestReloadFailed( string fileName, Exception exception )
193 // {
194 // Fire(
195 // TestReloadFailed,
196 // new TestEventArgs( TestAction.TestReloadFailed, fileName, exception ) );
197 // }
199 // public void FireRunStarting( ITest[] tests, int count )
200 // {
201 // Fire(
202 // RunStarting,
203 // new TestEventArgs( TestAction.RunStarting, tests, count ) );
204 // }
206 // public void FireRunFinished( TestResult[] results )
207 // {
208 // Fire(
209 // RunFinished,
210 // new TestEventArgs( TestAction.RunFinished, results ) );
211 // }
213 // public void FireRunFinished( Exception exception )
214 // {
215 // Fire(
216 // RunFinished,
217 // new TestEventArgs( TestAction.RunFinished, exception ) );
218 // }
220 // public void FireTestStarting( ITest test )
221 // {
222 // Fire(
223 // TestStarting,
224 // new TestEventArgs( TestAction.TestStarting, test ) );
225 // }
227 // public void FireTestFinished( TestResult result )
228 // {
229 // Fire(
230 // TestFinished,
231 // new TestEventArgs( TestAction.TestFinished, result ) );
232 // }
234 // public void FireSuiteStarting( ITest test )
235 // {
236 // Fire(
237 // SuiteStarting,
238 // new TestEventArgs( TestAction.SuiteStarting, test ) );
239 // }
241 // public void FireSuiteFinished( TestResult result )
242 // {
243 // Fire(
244 // SuiteFinished,
245 // new TestEventArgs( TestAction.SuiteFinished, result ) );
246 // }
248 // public void FireTestException( Exception exception )
249 // {
250 // Fire(
251 // TestException,
252 // new TestEventArgs( TestAction.TestException, exception ) );
253 // }
255 #endregion