BeforeTestCommand
BeforeTestCommand is a DelegatingTestCommand that performs some
specific action before the inner command is run.
using System;
namespace NUnit.Framework.Internal.Commands
{
public abstract class BeforeTestCommand : DelegatingTestCommand
{
protected Action<TestExecutionContext> BeforeTest;
public BeforeTestCommand(TestCommand innerCommand)
: base(innerCommand)
{
}
public override TestResult Execute(TestExecutionContext context)
{
Guard.OperationValid(BeforeTest != null, "BeforeTest was not set by the derived class constructor");
BeforeTest(context);
return context.CurrentResult = innerCommand.Execute(context);
}
}
}