Class TypeConstraint
TypeConstraint is the abstract base for constraints that take a Type as their expected value.
Inheritance
TypeConstraint
Inherited Members
Namespace: NUnit.Framework.Constraints
Assembly: nunit.framework.dll
Syntax
public abstract class TypeConstraint : Constraint, IConstraint, IResolveConstraint
Constructors
View SourceTypeConstraint(Type, string)
Construct a TypeConstraint for a given Type
Declaration
protected TypeConstraint(Type type, string descriptionPrefix)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The expected type for the constraint |
string | descriptionPrefix | Prefix used in forming the constraint description |
Fields
View SourceactualType
The type of the actual argument to which the constraint was applied
Declaration
protected Type? actualType
Field Value
Type | Description |
---|---|
Type |
expectedType
The expected Type used by the constraint
Declaration
protected Type expectedType
Field Value
Type | Description |
---|---|
Type |
Properties
View SourceDescription
The Description of what this constraint tests, for use in messages and in the ConstraintResult.
Declaration
public override string Description { get; }
Property Value
Type | Description |
---|---|
string |
Overrides
Methods
View SourceApplyTo<TActual>(TActual)
Applies the constraint to an actual value, returning a ConstraintResult.
Declaration
public override ConstraintResult ApplyTo<TActual>(TActual actual)
Parameters
Type | Name | Description |
---|---|---|
TActual | actual | The value to be tested |
Returns
Type | Description |
---|---|
ConstraintResult | A ConstraintResult |
Type Parameters
Name | Description |
---|---|
TActual |
Overrides
View SourceMatches(object?)
Apply the constraint to an actual value, returning true if it succeeds
Declaration
protected abstract bool Matches(object? actual)
Parameters
Type | Name | Description |
---|---|---|
object | actual | The actual argument |
Returns
Type | Description |
---|---|
bool | True if the constraint succeeds, otherwise false. |