<PackageReference Include="NUnit" Version="3.10.1" />

ConstraintUtils

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