Class EqualConstraint<T>
EqualConstraint is able to compare an actual value with the expected value provided in its constructor. Two objects are considered equal if both are null, or if both have the same value. NUnit has special semantics for some object types.
Inherited Members
Namespace: NUnit.Framework.Constraints
Assembly: nunit.framework.dll
Syntax
public class EqualConstraint<T> : EqualConstraint, IConstraint, IResolveConstraint
Type Parameters
| Name | Description |
|---|---|
| T |
Constructors
View SourceEqualConstraint(object?)
Initializes a new instance of the EqualConstraint class.
Declaration
public EqualConstraint(object? expected)
Parameters
| Type | Name | Description |
|---|---|---|
| object | expected | The expected value. |
Methods
View SourceUsingPropertiesComparer(Func<PropertiesComparerConfiguration<T>, PropertiesComparerConfiguration<T>>)
Enables comparing a subset of instance properties.
Declaration
public EqualConstraint UsingPropertiesComparer(Func<PropertiesComparerConfiguration<T>, PropertiesComparerConfiguration<T>> configure)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<PropertiesComparerConfiguration<T>, PropertiesComparerConfiguration<T>> | configure | Function to configure the PropertiesComparerConfiguration |
Returns
| Type | Description |
|---|---|
| EqualConstraint |
Remarks
This allows comparing classes that don't implement IEquatable<T> without having to compare each property separately in own code.