StaticMethodValidator
Checks whether the method to execute is static.
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace NUnit.Framework.Internal.Execution
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
public class StaticMethodValidator : IMethodValidator
{
private readonly string _failMessage;
public StaticMethodValidator(string failMessage)
{
Guard.ArgumentNotNullOrEmpty(failMessage, "failMessage");
_failMessage = failMessage;
}
public void Validate(MethodInfo method)
{
if (!method.IsStatic)
throw new InvalidOperationException(_failMessage);
}
}
}