HookDelegatingTestMethodCommand
using NUnit.Framework.Interfaces;
using System;
using System.Runtime.CompilerServices;
namespace NUnit.Framework.Internal.Commands
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
internal sealed class HookDelegatingTestMethodCommand : TestCommand
{
private readonly TestMethodCommand _innerCommand;
public HookDelegatingTestMethodCommand(TestMethodCommand innerCommand)
: base(innerCommand.Test)
{
_innerCommand = innerCommand;
}
public override TestResult Execute(TestExecutionContext context)
{
IMethodInfo method = _innerCommand.TestMethod.Method;
try {
context.ExecutionHooks.OnBeforeTest(context, method);
_innerCommand.Execute(context);
} catch (Exception exceptionContext) {
context.ExecutionHooks.OnAfterTest(context, method, exceptionContext);
throw;
}
context.ExecutionHooks.OnAfterTest(context, method, null);
return context.CurrentResult;
}
}
}