2010-06-03 Jb Evain <jbevain@novell.com>
[mcs.git] / nunit24 / NUnitCore / core / SetUpFixture.cs
blob3542dce27e2b44320c7a0b6897cd9e3e88270913
1 // ****************************************************************
2 // This is free software licensed under the NUnit license. You
3 // may obtain a copy of the license as well as information regarding
4 // copyright ownership at http://nunit.org/?p=license&r=2.4.
5 // ****************************************************************
7 using System;
8 using System.IO;
9 using System.Reflection;
11 namespace NUnit.Core
13 /// <summary>
14 /// SetUpFixture extends TestSuite and supports
15 /// Setup and TearDown methods.
16 /// </summary>
17 public class SetUpFixture : TestSuite
19 #region Constructor
20 public SetUpFixture( Type type ) : base( type )
22 this.TestName.Name = type.Namespace;
23 if (this.TestName.Name == null)
24 this.TestName.Name = "[default namespace]";
25 int index = TestName.Name.LastIndexOf('.');
26 if (index > 0)
27 this.TestName.Name = this.TestName.Name.Substring(index + 1);
29 this.fixtureSetUp = NUnitFramework.GetSetUpMethod( type );
30 this.fixtureTearDown = NUnitFramework.GetTearDownMethod( type );
32 #endregion
34 #region TestSuite Overrides
35 public override TestResult Run(EventListener listener, ITestFilter filter)
37 using ( new DirectorySwapper( Path.GetDirectoryName( TestFixtureBuilder.GetAssemblyPath( FixtureType ) ) ) )
39 return base.Run(listener, filter);
42 #endregion