AfterTestCommand
AfterCommand is a DelegatingTestCommand that performs some
specific action after the inner command is run.
using System;
using System.Runtime.CompilerServices;
namespace NUnit.Framework.Internal.Commands
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
public abstract class AfterTestCommand : DelegatingTestCommand
{
[System.Runtime.CompilerServices.Nullable(new byte[] {
2,
1
})]
protected Action<TestExecutionContext> AfterTest;
public AfterTestCommand(TestCommand innerCommand)
: base(innerCommand)
{
}
public override TestResult Execute(TestExecutionContext context)
{
Guard.OperationValid(AfterTest != null, "AfterTest was not set by the derived class constructor");
DelegatingTestCommand.RunTestMethodInThreadAbortSafeZone(context, delegate {
context.CurrentResult = innerCommand.Execute(context);
});
AfterTest(context);
return context.CurrentResult;
}
}
}