Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / nunit24 / ClientUtilities / util / TestEventDispatcher.cs
1 // ****************************************************************\r
2 // Copyright 2002-2003, 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
6 \r
7 using System;\r
8 using System.Collections;\r
9 using NUnit.Core;\r
10 \r
11 namespace NUnit.Util\r
12 {\r
13         /// <summary>\r
14         /// Helper class used to dispatch test events\r
15         /// </summary>\r
16         public class TestEventDispatcher : ITestEvents\r
17         {\r
18                 #region Events\r
19 \r
20                 // Project loading events\r
21                 public event TestEventHandler ProjectLoading;\r
22                 public event TestEventHandler ProjectLoaded;\r
23                 public event TestEventHandler ProjectLoadFailed;\r
24                 public event TestEventHandler ProjectUnloading;\r
25                 public event TestEventHandler ProjectUnloaded;\r
26                 public event TestEventHandler ProjectUnloadFailed;\r
27 \r
28                 // Test loading events\r
29                 public event TestEventHandler TestLoading;      \r
30                 public event TestEventHandler TestLoaded;       \r
31                 public event TestEventHandler TestLoadFailed;\r
32 \r
33                 public event TestEventHandler TestReloading;\r
34                 public event TestEventHandler TestReloaded;\r
35                 public event TestEventHandler TestReloadFailed;\r
36 \r
37                 public event TestEventHandler TestUnloading;\r
38                 public event TestEventHandler TestUnloaded;\r
39                 public event TestEventHandler TestUnloadFailed;\r
40 \r
41                 // Test running events\r
42                 public event TestEventHandler RunStarting;      \r
43                 public event TestEventHandler RunFinished;\r
44                 \r
45                 public event TestEventHandler SuiteStarting;\r
46                 public event TestEventHandler SuiteFinished;\r
47 \r
48                 public event TestEventHandler TestStarting;\r
49                 public event TestEventHandler TestFinished;\r
50 \r
51                 public event TestEventHandler TestException;\r
52                 public event TestEventHandler TestOutput;\r
53 \r
54                 #endregion\r
55 \r
56                 #region Methods for Firing Events\r
57                 \r
58                 protected virtual void Fire( TestEventHandler handler, TestEventArgs e )\r
59                 {\r
60                         if ( handler != null )\r
61                                 handler( this, e );\r
62                 }\r
63 \r
64                 public void FireProjectLoading( string fileName )\r
65                 {\r
66                         Fire(\r
67                                 ProjectLoading,\r
68                                 new TestEventArgs( TestAction.ProjectLoading, fileName ) );\r
69                 }\r
70 \r
71                 public void FireProjectLoaded( string fileName )\r
72                 {\r
73                         Fire( \r
74                                 ProjectLoaded,\r
75                                 new TestEventArgs( TestAction.ProjectLoaded, fileName ) );\r
76                 }\r
77 \r
78                 public void FireProjectLoadFailed( string fileName, Exception exception )\r
79                 {\r
80                         Fire( \r
81                                 ProjectLoadFailed,\r
82                                 new TestEventArgs( TestAction.ProjectLoadFailed, fileName, exception ) );\r
83                 }\r
84 \r
85                 public void FireProjectUnloading( string fileName )\r
86                 {\r
87                         Fire( \r
88                                 ProjectUnloading,\r
89                                 new TestEventArgs( TestAction.ProjectUnloading, fileName ) );\r
90                 }\r
91 \r
92                 public void FireProjectUnloaded( string fileName )\r
93                 {\r
94                         Fire( \r
95                                 ProjectUnloaded,\r
96                                 new TestEventArgs( TestAction.ProjectUnloaded, fileName ) );\r
97                 }\r
98 \r
99                 public void FireProjectUnloadFailed( string fileName, Exception exception )\r
100                 {\r
101                         Fire( \r
102                                 ProjectUnloadFailed,\r
103                                 new TestEventArgs( TestAction.ProjectUnloadFailed, fileName, exception ) );\r
104                 }\r
105 \r
106                 public void FireTestLoading( string fileName )\r
107                 {\r
108                         Fire( \r
109                                 TestLoading,\r
110                                 new TestEventArgs( TestAction.TestLoading, fileName ) );\r
111                 }\r
112 \r
113                 public void FireTestLoaded( string fileName, ITest test )\r
114                 {\r
115                         Fire( \r
116                                 TestLoaded,\r
117                                 new TestEventArgs( TestAction.TestLoaded, fileName, test ) );\r
118                 }\r
119 \r
120                 public void FireTestLoadFailed( string fileName, Exception exception )\r
121                 {\r
122                         Fire(\r
123                                 TestLoadFailed,\r
124                                 new TestEventArgs( TestAction.TestLoadFailed, fileName, exception ) );\r
125                 }\r
126 \r
127                 public void FireTestUnloading( string fileName )\r
128                 {\r
129                         Fire(\r
130                                 TestUnloading,\r
131                                 new TestEventArgs( TestAction.TestUnloading, fileName ) );\r
132                 }\r
133 \r
134                 public void FireTestUnloaded( string fileName )\r
135                 {\r
136                         Fire(\r
137                                 TestUnloaded,\r
138                                 new TestEventArgs( TestAction.TestUnloaded, fileName ) );\r
139                 }\r
140 \r
141                 public void FireTestUnloadFailed( string fileName, Exception exception )\r
142                 {\r
143                         Fire(\r
144                                 TestUnloadFailed, \r
145                                 new TestEventArgs( TestAction.TestUnloadFailed, fileName, exception ) );\r
146                 }\r
147 \r
148                 public void FireTestReloading( string fileName )\r
149                 {\r
150                         Fire(\r
151                                 TestReloading,\r
152                                 new TestEventArgs( TestAction.TestReloading, fileName ) );\r
153                 }\r
154 \r
155                 public void FireTestReloaded( string fileName, ITest test )\r
156                 {\r
157                         Fire(\r
158                                 TestReloaded,\r
159                                 new TestEventArgs( TestAction.TestReloaded, fileName, test ) );\r
160                 }\r
161 \r
162                 public void FireTestReloadFailed( string fileName, Exception exception )\r
163                 {\r
164                         Fire(\r
165                                 TestReloadFailed, \r
166                                 new TestEventArgs( TestAction.TestReloadFailed, fileName, exception ) );\r
167                 }\r
168 \r
169                 public void FireRunStarting( string name, int testCount )\r
170                 {\r
171                         Fire(\r
172                                 RunStarting,\r
173                                 new TestEventArgs( TestAction.RunStarting, name, testCount ) );\r
174                 }\r
175 \r
176                 public void FireRunFinished( TestResult result )\r
177                 {       \r
178                         Fire(\r
179                                 RunFinished,\r
180                                 new TestEventArgs( TestAction.RunFinished, result ) );\r
181                 }\r
182 \r
183                 public void FireRunFinished( Exception exception )\r
184                 {\r
185                         Fire(\r
186                                 RunFinished,\r
187                                 new TestEventArgs( TestAction.RunFinished, exception ) );\r
188                 }\r
189 \r
190                 public void FireTestStarting( TestName testName )\r
191                 {\r
192                         Fire(\r
193                                 TestStarting,\r
194                                 new TestEventArgs( TestAction.TestStarting, testName ) );\r
195                 }\r
196 \r
197                 public void FireTestFinished( TestResult result )\r
198                 {       \r
199                         Fire(\r
200                                 TestFinished,\r
201                                 new TestEventArgs( TestAction.TestFinished, result ) );\r
202                 }\r
203 \r
204                 public void FireSuiteStarting( TestName testName )\r
205                 {\r
206                         Fire(\r
207                                 SuiteStarting,\r
208                                 new TestEventArgs( TestAction.SuiteStarting, testName ) );\r
209                 }\r
210 \r
211                 public void FireSuiteFinished( TestResult result )\r
212                 {       \r
213                         Fire(\r
214                                 SuiteFinished,\r
215                                 new TestEventArgs( TestAction.SuiteFinished, result ) );\r
216                 }\r
217 \r
218                 public void FireTestException( string name, Exception exception )\r
219                 {\r
220                         Fire(\r
221                                 TestException,\r
222                                 new TestEventArgs( TestAction.TestException, name, exception ) );\r
223                 }\r
224 \r
225                 public void FireTestOutput( TestOutput testOutput )\r
226                 {\r
227                         Fire(\r
228                                 TestOutput,\r
229                                 new TestEventArgs( TestAction.TestOutput, testOutput ) );\r
230                 }\r
231 \r
232                 #endregion\r
233         }\r
234 }\r