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