Welcome to mirror list, hosted at ThFree Co, Russian Federation.

TestSetup.cs « NUnitCore « src « nunit « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fb360a60351564747c2d702da18e285a58b0f5f7 (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
55
56
57
58
namespace NUnit.Extensions {

  using System;

  using NUnit.Framework;
  
  /// <summary>A Decorator to set up and tear down additional fixture state.
  /// </summary><remarks>
  /// Subclass TestSetup and insert it into your tests when you want
  /// to set up additional state once before the tests are run.</remarks>
  public class TestSetup: TestDecorator {
    /// <summary>
    /// 
    /// </summary>
    /// <param name="test"></param>
    public TestSetup(ITest test) : base(test) {}
    /// <summary>
    /// 
    /// </summary>
    protected class ProtectedProtect: IProtectable {
      private readonly TestSetup fTestSetup;
      private readonly TestResult fTestResult;
	/// <summary>
	/// 
	/// </summary>
	/// <param name="testSetup"></param>
	/// <param name="testResult"></param>
      public ProtectedProtect(TestSetup testSetup, TestResult testResult) {
        fTestSetup = testSetup;
        fTestResult = testResult;
      }
	/// <summary>
	/// 
	/// </summary>
      public void Protect() {
        fTestSetup.SetUp();
        fTestSetup.BasicRun(fTestResult);
        fTestSetup.TearDown();
      }
    }
    /// <summary>
    /// 
    /// </summary>
    /// <param name="result"></param>
    public override void Run(TestResult result) {
      IProtectable p= new ProtectedProtect(this, result);
      result.RunProtected(this, p);
    }
    /// <summary>Sets up the fixture. Override to set up additional fixture
    /// state.</summary>
    protected virtual void SetUp() {
    }
    /// <summary>Tears down the fixture. Override to tear down the additional
    /// fixture state.</summary>
    protected virtual void TearDown() {
    }
  }
}