blob: 4938ee952e920525fc3d775087148cc09d6821e4 (
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
|
namespace NUnit.Runner
{
using System;
using System.Reflection;
using NUnit.Framework;
/// <summary>
/// An implementation of a TestCollector that loads
/// all classes on the class path and tests whether
/// it is assignable from ITest or provides a static Suite property.
/// <see cref="ITestCollector"/>
/// </summary>
[Obsolete("Use StandardLoader or UnloadingLoader")]
public class LoadingClassPathTestCollector: ClassPathTestCollector
{
TestCaseClassLoader fLoader;
/// <summary>
///
/// </summary>
public LoadingClassPathTestCollector()
{
fLoader= new TestCaseClassLoader();
}
/// <summary>
///
/// </summary>
/// <param name="classFileName"></param>
/// <returns></returns>
protected override bool IsTestClass(string classFileName)
{
try
{
if (classFileName.EndsWith(".dll") || classFileName.EndsWith(".exe"))
{
Type testClass= ClassFromFile(classFileName);
return (testClass != null); //HACK: && TestCase.IsTest(testClass);
}
}
catch (TypeLoadException)
{
}
return false;
}
private Type ClassFromFile(string classFileName)
{
string className = base.ClassNameFromFile(classFileName);
if (!fLoader.IsExcluded(className))
return fLoader.LoadClass(className, false);
return null;
}
}
}
|