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

AssignableToConstraint

AssignableToConstraint is used to test that an object can be assigned to a given Type.
using NUnit.Compatibility; using System; namespace NUnit.Framework.Constraints { public class AssignableToConstraint : TypeConstraint { public AssignableToConstraint(Type type) : base(type, "assignable to ") { } protected override bool Matches(object actual) { if (expectedType != (Type)null && actual != null) return expectedType.GetTypeInfo().IsAssignableFrom(actual.GetType().GetTypeInfo()); return false; } } }