ConstraintUtils
Provides methods to support consistent checking for constaints methods.
using System;
namespace NUnit.Framework.Internal
{
internal static class ConstraintUtils
{
public static T RequireActual<T>(object actual, string paramName, bool allowNull = false)
{
if (actual is T)
return (T)actual;
if (allowNull && actual == null && default(T) == null)
return default(T);
string arg = (actual == null) ? "null" : actual.GetType().get_Name();
throw new ArgumentException($"""{typeof(T).get_Name()}""{arg}", paramName);
}
}
}