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

AssignableToConstraint

AssignableToConstraint is used to test that an object can be assigned to a given Type.
using System; using System.Reflection; 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; } } }