33
34
public class TestFixture : TestSuite
35
36
#region Constructors
38
/// Initializes a new instance of the <see cref="TestFixture"/> class.
40
/// <param name="fixtureType">Type of the fixture.</param>
36
41
public TestFixture(Type fixtureType)
37
42
: this(fixtureType, null) { }
45
/// Initializes a new instance of the <see cref="TestFixture"/> class.
47
/// <param name="fixtureType">Type of the fixture.</param>
48
/// <param name="arguments">The arguments.</param>
39
49
public TestFixture(Type fixtureType, object[] arguments)
40
50
: base(fixtureType, arguments)
42
this.fixtureSetUpMethods =
43
Reflect.GetMethodsWithAttribute(fixtureType, typeof(TestFixtureSetUpAttribute), true);
44
this.fixtureTearDownMethods =
45
Reflect.GetMethodsWithAttribute(fixtureType, typeof(TestFixtureTearDownAttribute), true);
47
Reflect.GetMethodsWithAttribute(this.FixtureType, typeof(SetUpAttribute), true);
48
this.tearDownMethods =
49
Reflect.GetMethodsWithAttribute(this.FixtureType, typeof(TearDownAttribute), true);
52
this.fixtureSetUpMethods = GetSetUpTearDownMethods( typeof(TestFixtureSetUpAttribute) );
53
this.fixtureTearDownMethods = GetSetUpTearDownMethods( typeof( TestFixtureTearDownAttribute) );
54
this.setUpMethods = GetSetUpTearDownMethods( typeof(SetUpAttribute) );
55
this.tearDownMethods = GetSetUpTearDownMethods( typeof(TearDownAttribute) );
58
private MethodInfo[] GetSetUpTearDownMethods(Type attrType)
60
MethodInfo[] methods = Reflect.GetMethodsWithAttribute(FixtureType, attrType, true);
62
foreach ( MethodInfo method in methods )
63
if ( method.IsAbstract ||
64
!method.IsPublic && !method.IsFamily ||
65
method.GetParameters().Length > 0 ||
66
!method.ReturnType.Equals(typeof(void)))
68
this.IgnoreReason = string.Format("Invalid signature for SetUp or TearDown method: {0}", method.Name);
69
this.RunState = RunState.NotRunnable;
53
77
#region TestSuite Overrides
80
/// Runs the suite under a particular filter, sending
81
/// notifications to a listener.
83
/// <param name="listener">An event listener to receive notifications</param>
84
/// <param name="filter">A filter used in running the test</param>
85
/// <returns></returns>
54
86
public override TestResult Run(ITestListener listener, TestFilter filter)
56
88
using ( new DirectorySwapper( AssemblyHelper.GetDirectoryName( FixtureType.Assembly ) ) )