added install target and update makefiles
[mono.git] / mcs / nunit20 / util / TestLoadEventArgs.cs
1 using System;
2 using System.Diagnostics;
3
4 namespace NUnit.Util
5 {
6         /// <summary>
7         /// The delegate used for all events related to loading, unloading and reloading tests
8         /// </summary>
9         public delegate void TestLoadEventHandler( object sender, TestLoadEventArgs e );
10
11         /// <summary>
12         /// Enumeration used to distinguish test load events
13         /// </summary>
14         public enum TestLoadAction
15         {
16                 LoadStarting,
17                 LoadComplete,
18                 LoadFailed,
19                 ReloadStarting,
20                 ReloadComplete,
21                 ReloadFailed,
22                 UnloadStarting,
23                 UnloadComplete,
24                 UnloadFailed
25         }
26
27         /// <summary>
28         /// Argument used for all test load events
29         /// </summary>
30         public class TestLoadEventArgs : EventArgs
31         {
32                 private TestLoadAction action;
33                 private string assemblyName;
34                 private UITestNode test;
35                 private Exception exception;
36
37                 /// <summary>
38                 /// Helper that recognizes failure events
39                 /// </summary>
40                 private bool IsFailure( TestLoadAction action )
41                 {
42                         return action == TestLoadAction.LoadFailed ||
43                                 action == TestLoadAction.UnloadFailed ||
44                                 action == TestLoadAction.ReloadFailed;
45                 }
46
47                 /// <summary>
48                 /// Constructor for non-failure events
49                 /// </summary>
50                 public TestLoadEventArgs( TestLoadAction action, 
51                         string assemblyName, UITestNode test )
52                 {
53                         this.action = action;
54                         this.assemblyName = assemblyName;
55                         this.test = test;
56
57                         Debug.Assert( !IsFailure( action ), "Invalid TestLoadAction in Constructor" );
58                 }
59
60                 public TestLoadEventArgs( TestLoadAction action, string assemblyName )
61                 {
62                         this.action = action;
63                         this.assemblyName = assemblyName;
64
65                         Debug.Assert( action != TestLoadAction.UnloadStarting || action != TestLoadAction.UnloadComplete, 
66                                         "Invalid TestLoadAction in Constructor" );
67                 }
68
69                 /// <summary>
70                 /// Constructor for failure events
71                 /// </summary>
72                 public TestLoadEventArgs( TestLoadAction action,
73                         string assemblyName, Exception exception )
74                 {
75                         this.action = action;
76                         this.assemblyName = assemblyName;
77                         this.exception = exception;
78
79                         Debug.Assert( IsFailure( action ), "Invalid TestLoadAction in Constructor" );
80                 }
81
82                 public TestLoadAction Action
83                 {
84                         get { return action; }
85                 }
86
87                 public string AssemblyName
88                 {
89                         get { return assemblyName; }
90                 }
91
92                 public UITestNode Test
93                 {
94                         get { return test; }
95                 }
96
97                 public Exception Exception
98                 {
99                         get { return exception; }
100                 }
101         }
102 }