PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/src/NUnit/core/SetUpFixture.cs

#
C# | 54 lines | 35 code | 6 blank | 13 comment | 3 complexity | baa7a901abcaa3ffc95de5aa5e92192b MD5 | raw file
Possible License(s): GPL-2.0
  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.
  5. // ****************************************************************
  6. using System;
  7. using System.IO;
  8. using System.Reflection;
  9. namespace NUnit.Core
  10. {
  11. /// <summary>
  12. /// SetUpFixture extends TestSuite and supports
  13. /// Setup and TearDown methods.
  14. /// </summary>
  15. public class SetUpFixture : TestSuite
  16. {
  17. #region Constructor
  18. public SetUpFixture( Type type ) : base( type )
  19. {
  20. this.TestName.Name = type.Namespace;
  21. if (this.TestName.Name == null)
  22. this.TestName.Name = "[default namespace]";
  23. int index = TestName.Name.LastIndexOf('.');
  24. if (index > 0)
  25. this.TestName.Name = this.TestName.Name.Substring(index + 1);
  26. this.fixtureSetUpMethods = Reflect.GetMethodsWithAttribute( type, NUnitFramework.SetUpAttribute, true );
  27. this.fixtureTearDownMethods = Reflect.GetMethodsWithAttribute( type, NUnitFramework.TearDownAttribute, true );
  28. }
  29. #endregion
  30. #region TestSuite Overrides
  31. /// <summary>
  32. /// Gets a string representing the kind of test
  33. /// that this object represents, for use in display.
  34. /// </summary>
  35. public override string TestType
  36. {
  37. get { return "SetUpFixture"; }
  38. }
  39. public override TestResult Run(EventListener listener, ITestFilter filter)
  40. {
  41. using ( new DirectorySwapper( AssemblyHelper.GetDirectoryName( FixtureType.Assembly ) ) )
  42. {
  43. return base.Run(listener, filter);
  44. }
  45. }
  46. #endregion
  47. }
  48. }