blob: 9c707c43e33fe5fa3691135873d262d4a8281324 (
plain)
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
|
using System;
using NUnit.Framework;
namespace NUnit.Runner
{
/// <summary>
/// Collects the names of all classes in an assembly that are tests.
/// </summary>
public sealed class AssemblyTestCollector : MarshalByRefObject, ITestCollector
{
#region Instance Variables
private string fAssemblyName;
private StandardLoader fLoader;
#endregion
#region Constructors
/// <summary>
/// Create a new AssemblyTestCollector for the specified
/// assembly, and uses the supplied loader to load the tests
/// from the assembly.
/// </summary>
/// <param name="assemblyName">The file name of the assembly
/// from which to load classes</param>
/// <param name="loader">An instance if the standard loader to
/// use for loading tests from the assembly.</param>
public AssemblyTestCollector(string assemblyName,
StandardLoader loader)
{
if(loader!=null)
fLoader = loader;
else
throw new ArgumentNullException("loader");
if(assemblyName != null)
{
fAssemblyName = assemblyName;
}
else
throw new ArgumentNullException("assemblyName");
}
/// <summary>
/// Create a new AssemblyTestCollector for the specified
/// assembly.
/// </summary>
/// <param name="assemblyName">The file name of the assembly
/// from which to load classes.</param>
public AssemblyTestCollector(string assemblyName)
: this(assemblyName,new StandardLoader()){}
/// <summary>
/// returns a System.String[] of FullNames for all test classes
/// contained within the assembly.
/// Implements ITestCollector.CollectTestsClassNames()
/// </summary>
#endregion
#region ITestCollector Methods
public string[] CollectTestsClassNames()
{
Type[] tests = fLoader.GetTestTypes(fAssemblyName);
string[] ret = new string[tests.Length];
int i=0;
foreach (Type testType in tests)
{
ret[i] = testType.FullName;
i++;
}
return ret;
}
#endregion
}
}
|