Class Criterion<T>
Serves as a criterion against which a value can be compared. When a given value equals the criterion, it can be said to match the criterion; otherwise not.
Inheritance
Implements
Inherited Members
Namespace: AutoFixture.Kernel
Assembly: AutoFixture.dll
Syntax
public class Criterion<T> : IEquatable<T>
Type Parameters
Name | Description |
---|---|
T | The type of values being compared. |
Remarks
Sometimes you need to compare various candidates against a particular value, but the comparison rules may vary. Sometimes, strict equality is warranted, but otherwise (e.g. when comparing strings) looser comparison rules can be applied (e.g. case-insensitve comparison of strings).
The Criterion class enables you to capture the desied value (the Target) together with the appropriate comparison method (the Comparer) in a single object.
Constructors
| Improve this Doc View SourceCriterion(T, IEqualityComparer<T>)
Initializes a new instance of the Criterion<T> class.
Declaration
public Criterion(T target, IEqualityComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
T | target | The target value against which candidates will be compared. Can be null. |
System.Collections.Generic.IEqualityComparer<T> | comparer | The comparison method used to compare candidates against
|
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
See Also
Properties
| Improve this Doc View SourceComparer
The comparison method used to compare Target to candidates.
Declaration
public IEqualityComparer<T> Comparer { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEqualityComparer<T> |
Target
The desired target value, as supplied via the constructor.
Declaration
public T Target { get; }
Property Value
Type | Description |
---|---|
T |
Methods
| Improve this Doc View SourceEquals(T)
Compares a candidate value against this Criterion<T>.
Declaration
public bool Equals(T other)
Parameters
Type | Name | Description |
---|---|---|
T | other | The candidate to compare against this value. |
Returns
Type | Description |
---|---|
System.Boolean | true if |
Remarks
This method compares the candidate other
against Target, using Comparer as
the comparison method. If this combination of target value and
comparison method deems the candidate to be equal to this
criterion, the return value is true.
Equals(Object)
Determines whether this object is equal to another object.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The object to compare to this object. |
Returns
Type | Description |
---|---|
System.Boolean | true if |
Overrides
GetHashCode()
Returns the hash code for the object.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | The hash code. |