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

AssignableFromConstraint

AssignableFromConstraint is used to test that an object can be assigned from a given Type.
using System; using System.Runtime.CompilerServices; namespace NUnit.Framework.Constraints { public class AssignableFromConstraint : TypeConstraint { [System.Runtime.CompilerServices.NullableContext(1)] public AssignableFromConstraint(Type type) : base(type, "assignable from ") { } [System.Runtime.CompilerServices.NullableContext(2)] protected override bool Matches(object actual) { return actual?.GetType().IsAssignableFrom(expectedType) ?? false; } } }