2009-06-12 Bill Holmes <billholmes54@gmail.com>
[mono.git] / mcs / nunit20 / util / TestEventDispatcher.cs
1 #region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
2 /************************************************************************************
3 '
4 ' Copyright  2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
5 ' Copyright  2000-2002 Philip A. Craig
6 '
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.
10
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:
14 '
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.
18 '
19 ' Portions Copyright  2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
20 ' or Copyright  2000-2002 Philip A. Craig
21 '
22 ' 2. Altered source versions must be plainly marked as such, and must not be 
23 ' misrepresented as being the original software.
24 '
25 ' 3. This notice may not be removed or altered from any source distribution.
26 '
27 '***********************************************************************************/
28 #endregion
29
30 using System;
31 using System.Collections;
32 using NUnit.Core;
33
34 namespace NUnit.Util
35 {
36         /// <summary>
37         /// Helper class used to dispatch test events
38         /// </summary>
39         public class ProjectEventDispatcher : TestEventDispatcher, IProjectEvents
40         {
41                 #region Events
42
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;
50
51                 // Test loading events
52 //              public event TestEventHandler TestLoading;      
53 //              public event TestEventHandler TestLoaded;       
54 //              public event TestEventHandler TestLoadFailed;
55 //
56 //              public event TestEventHandler TestReloading;
57 //              public event TestEventHandler TestReloaded;
58 //              public event TestEventHandler TestReloadFailed;
59 //
60 //              public event TestEventHandler TestUnloading;
61 //              public event TestEventHandler TestUnloaded;
62 //              public event TestEventHandler TestUnloadFailed;
63 //
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;
70 //
71 //              public event TestEventHandler TestStarting;
72 //              public event TestEventHandler TestFinished;
73 //
74 //              public event TestEventHandler TestException;
75
76                 #endregion
77
78                 #region Methods for Firing Events
79                 
80                 private void Fire( 
81                         TestEventHandler handler, TestEventArgs e )
82                 {
83                         if ( handler != null )
84                                 handler( this, e );
85                 }
86
87                 private void Fire( 
88                         TestProjectEventHandler handler, TestProjectEventArgs e )
89                 {
90                         if ( handler != null )
91                                 handler( this, e );
92                 }
93
94                 public void FireProjectLoading( string fileName )
95                 {
96                         Fire(
97                                 ProjectLoading,
98                                 new TestProjectEventArgs( TestProjectAction.ProjectLoading, fileName ) );
99                 }
100
101                 public void FireProjectLoaded( string fileName )
102                 {
103                         Fire( 
104                                 ProjectLoaded,
105                                 new TestProjectEventArgs( TestProjectAction.ProjectLoaded, fileName ) );
106                 }
107
108                 public void FireProjectLoadFailed( string fileName, Exception exception )
109                 {
110                         Fire( 
111                                 ProjectLoadFailed,
112                                 new TestProjectEventArgs( TestProjectAction.ProjectLoadFailed, fileName, exception ) );
113                 }
114
115                 public void FireProjectUnloading( string fileName )
116                 {
117                         Fire( 
118                                 ProjectUnloading,
119                                 new TestProjectEventArgs( TestProjectAction.ProjectUnloading, fileName ) );
120                 }
121
122                 public void FireProjectUnloaded( string fileName )
123                 {
124                         Fire( 
125                                 ProjectUnloaded,
126                                 new TestProjectEventArgs( TestProjectAction.ProjectUnloaded, fileName ) );
127                 }
128
129                 public void FireProjectUnloadFailed( string fileName, Exception exception )
130                 {
131                         Fire( 
132                                 ProjectUnloadFailed,
133                                 new TestProjectEventArgs( TestProjectAction.ProjectUnloadFailed, fileName, exception ) );
134                 }
135
136 //              public void FireTestLoading( string fileName )
137 //              {
138 //                      Fire( 
139 //                              TestLoading,
140 //                              new TestEventArgs( TestAction.TestLoading, fileName ) );
141 //              }
142 //
143 //              public void FireTestLoaded( string fileName, ITest test )
144 //              {
145 //                      Fire( 
146 //                              TestLoaded,
147 //                              new TestEventArgs( TestAction.TestLoaded, fileName, test ) );
148 //              }
149 //
150 //              public void FireTestLoadFailed( string fileName, Exception exception )
151 //              {
152 //                      Fire(
153 //                              TestLoadFailed,
154 //                              new TestEventArgs( TestAction.TestLoadFailed, fileName, exception ) );
155 //              }
156 //
157 //              public void FireTestUnloading( string fileName, ITest test )
158 //              {
159 //                      Fire(
160 //                              TestUnloading,
161 //                              new TestEventArgs( TestAction.TestUnloading, fileName, test ) );
162 //              }
163 //
164 //              public void FireTestUnloaded( string fileName, ITest test )
165 //              {
166 //                      Fire(
167 //                              TestUnloaded,
168 //                              new TestEventArgs( TestAction.TestUnloaded, fileName, test ) );
169 //              }
170 //
171 //              public void FireTestUnloadFailed( string fileName, Exception exception )
172 //              {
173 //                      Fire(
174 //                              TestUnloadFailed, 
175 //                              new TestEventArgs( TestAction.TestUnloadFailed, fileName, exception ) );
176 //              }
177 //
178 //              public void FireTestReloading( string fileName, ITest test )
179 //              {
180 //                      Fire(
181 //                              TestReloading,
182 //                              new TestEventArgs( TestAction.TestReloading, fileName, test ) );
183 //              }
184 //
185 //              public void FireTestReloaded( string fileName, ITest test )
186 //              {
187 //                      Fire(
188 //                              TestReloaded,
189 //                              new TestEventArgs( TestAction.TestReloaded, fileName, test ) );
190 //              }
191 //
192 //              public void FireTestReloadFailed( string fileName, Exception exception )
193 //              {
194 //                      Fire(
195 //                              TestReloadFailed, 
196 //                              new TestEventArgs( TestAction.TestReloadFailed, fileName, exception ) );
197 //              }
198 //
199 //              public void FireRunStarting( ITest[] tests, int count )
200 //              {
201 //                      Fire(
202 //                              RunStarting,
203 //                              new TestEventArgs( TestAction.RunStarting, tests, count ) );
204 //              }
205 //
206 //              public void FireRunFinished( TestResult[] results )
207 //              {       
208 //                      Fire(
209 //                              RunFinished,
210 //                              new TestEventArgs( TestAction.RunFinished, results ) );
211 //              }
212 //
213 //              public void FireRunFinished( Exception exception )
214 //              {
215 //                      Fire(
216 //                              RunFinished,
217 //                              new TestEventArgs( TestAction.RunFinished, exception ) );
218 //              }
219 //
220 //              public void FireTestStarting( ITest test )
221 //              {
222 //                      Fire(
223 //                              TestStarting,
224 //                              new TestEventArgs( TestAction.TestStarting, test ) );
225 //              }
226 //
227 //              public void FireTestFinished( TestResult result )
228 //              {       
229 //                      Fire(
230 //                              TestFinished,
231 //                              new TestEventArgs( TestAction.TestFinished, result ) );
232 //              }
233 //
234 //              public void FireSuiteStarting( ITest test )
235 //              {
236 //                      Fire(
237 //                              SuiteStarting,
238 //                              new TestEventArgs( TestAction.SuiteStarting, test ) );
239 //              }
240 //
241 //              public void FireSuiteFinished( TestResult result )
242 //              {       
243 //                      Fire(
244 //                              SuiteFinished,
245 //                              new TestEventArgs( TestAction.SuiteFinished, result ) );
246 //              }
247 //
248 //              public void FireTestException( Exception exception )
249 //              {
250 //                      Fire(
251 //                              TestException,
252 //                              new TestEventArgs( TestAction.TestException, exception ) );
253 //              }
254
255                 #endregion
256         }
257 }