DisposeFixtureCommand
OneTimeTearDownCommand performs any teardown actions
specified for a suite and calls Dispose on the user
test object, if any.
using NUnit.Framework.Interfaces;
using System;
namespace NUnit.Framework.Internal.Commands
{
public class DisposeFixtureCommand : AfterTestCommand
{
public DisposeFixtureCommand(TestCommand innerCommand)
: base(innerCommand)
{
Guard.OperationValid(base.Test is IDisposableFixture, "DisposeFixtureCommand does not apply to a " + base.Test.GetType().Name);
AfterTest = delegate(TestExecutionContext context) {
try {
(context.TestObject as IDisposable)?.Dispose();
} catch (Exception ex) {
context.CurrentResult.RecordTearDownException(ex);
}
};
}
}
}