34
35
public class SetUpFixture : TestSuite
36
37
#region Constructor
40
/// Initializes a new instance of the <see cref="SetUpFixture"/> class.
42
/// <param name="type">The type.</param>
37
43
public SetUpFixture( Type type ) : base( type )
39
this.TestName.Name = type.Namespace;
40
if (this.TestName.Name == null)
41
this.TestName.Name = "[default namespace]";
42
int index = TestName.Name.LastIndexOf('.');
45
this.Name = type.Namespace;
46
if (this.Name == null)
47
this.Name = "[default namespace]";
48
int index = this.Name.LastIndexOf('.');
44
this.TestName.Name = this.TestName.Name.Substring(index + 1);
50
this.Name = this.Name.Substring(index + 1);
46
this.fixtureSetUpMethods = Reflect.GetMethodsWithAttribute( type, typeof(NUnit.Framework.SetUpAttribute), true );
47
this.fixtureTearDownMethods = Reflect.GetMethodsWithAttribute( type, typeof(NUnit.Framework.TearDownAttribute), true );
52
this.fixtureSetUpMethods = GetSetUpTearDownMethods( typeof(NUnit.Framework.SetUpAttribute) );
53
this.fixtureTearDownMethods = GetSetUpTearDownMethods( typeof(NUnit.Framework.TearDownAttribute) );
56
private MethodInfo[] GetSetUpTearDownMethods(Type attrType)
58
MethodInfo[] methods = Reflect.GetMethodsWithAttribute(FixtureType, attrType, true);
60
foreach (MethodInfo method in methods)
61
if (method.IsAbstract ||
62
!method.IsPublic && !method.IsFamily ||
63
method.GetParameters().Length > 0 ||
64
!method.ReturnType.Equals(typeof(void)))
66
this.IgnoreReason = string.Format("Invalid signature for SetUp or TearDown method: {0}", method.Name);
67
this.RunState = RunState.NotRunnable;
51
75
#region TestSuite Overrides
52
public override TestResult Run(ITestListener listener, TestFilter filter)
77
/// Runs the suite under a particular filter, sending
78
/// notifications to a listener.
80
/// <param name="listener">An event listener to receive notifications</param>
81
/// <param name="filter">A filter used in running the test</param>
82
/// <returns></returns>
83
public override TestResult Run(ITestListener listener)
54
85
using ( new DirectorySwapper( AssemblyHelper.GetDirectoryName( FixtureType.Assembly ) ) )
56
return base.Run(listener, filter);
87
return base.Run(listener);