OneTimeTearDownCommand
OneTimeTearDownCommand performs any teardown actions
specified for a suite and calls Dispose on the user
test object, if any.
using System;
namespace NUnit.Framework.Internal.Commands
{
public class OneTimeTearDownCommand : AfterTestCommand
{
public OneTimeTearDownCommand(TestCommand innerCommand, SetUpTearDownItem setUpTearDownItem)
: base(innerCommand)
{
Guard.ArgumentValid(innerCommand.Test is TestSuite, "OneTimeTearDownCommand may only apply to a TestSuite", "innerCommand");
Guard.ArgumentNotNull(setUpTearDownItem, "setUpTearDownItem");
AfterTest = delegate(TestExecutionContext context) {
TestResult currentResult = context.CurrentResult;
try {
setUpTearDownItem.RunTearDown(context);
} catch (Exception ex) {
currentResult.RecordTearDownException(ex);
}
};
}
}
}