TestActionItem
TestActionItem represents a single execution of an
ITestAction. It is used to track whether the BeforeTest
method has been called and suppress calling the
AfterTest method if it has not.
using NUnit.Framework.Interfaces;
namespace NUnit.Framework.Internal.Commands
{
public class TestActionItem
{
private readonly ITestAction _action;
private bool _beforeTestWasRun;
public TestActionItem(ITestAction action)
{
_action = action;
}
public void BeforeTest(ITest test)
{
_beforeTestWasRun = true;
_action.BeforeTest(test);
}
public void AfterTest(ITest test)
{
if (_beforeTestWasRun)
_action.AfterTest(test);
}
}
}