AfterTestActionCommand
TestActionAfterCommand handles the AfterTest method of a single
TestActionItem, provided the items BeforeTest has been run.
using System;
using System.Runtime.CompilerServices;
namespace NUnit.Framework.Internal.Commands
{
public class AfterTestActionCommand : AfterTestCommand
{
[System.Runtime.CompilerServices.NullableContext(1)]
public AfterTestActionCommand(TestCommand innerCommand, TestActionItem action)
: base(innerCommand)
{
Guard.ArgumentValid(innerCommand.Test is TestSuite, "BeforeTestActionCommand may only apply to a TestSuite", "innerCommand");
ArgumentNullExceptionExtensions.ThrowIfNull(action, "action");
AfterTest = delegate(TestExecutionContext context) {
if (action.BeforeTestWasRun) {
int assertionResultCount = context.CurrentResult.AssertionResultCount;
action.AfterTest(base.Test);
if (context.CurrentResult.AssertionResultCount > assertionResultCount)
context.CurrentResult.RecordTestCompletion();
}
};
}
}
}