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

ConstraintUtils

static class ConstraintUtils
Provides methods to support consistent checking in constraints.
using System; using System.Runtime.CompilerServices; namespace NUnit.Framework.Internal { internal static class ConstraintUtils { [System.Runtime.CompilerServices.NullableContext(1)] public static T RequireActual<[System.Runtime.CompilerServices.Nullable(2)] T>([System.Runtime.CompilerServices.Nullable(2)] object actual, string paramName, bool allowNull = false) { if (TypeHelper.TryCast(actual, out T value) && (allowNull || value != null)) return value; string str = (actual == null) ? "null" : actual.GetType().Name; throw new ArgumentException("Expected: " + typeof(T).Name + " But was: " + str, paramName); } } }