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