Class Criterion<T>
Namespace: AutoFixture.Kernel
Assembly: AutoFixture.dll
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.
public class Criterion<T> : IEquatable<T>Type Parameters
T
The type of values being compared.
Inheritance
Implements
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
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
Criterion(T, IEqualityComparer<T>)
Initializes a new instance of the Criterion%601
class.
public Criterion(T target, IEqualityComparer<T> comparer)Parameters
target T
The target value against which candidates will be compared. Can be null.
comparer IEqualityComparer<T>
The comparison method used to compare candidates against
target.
Exceptions
comparer is null.
See Also
Criterion<T>.Target, Criterion<T>.Comparer
Properties
Comparer
The comparison method used to compare Target to
candidates.
public IEqualityComparer<T> Comparer { get; }Property Value
Target
The desired target value, as supplied via the constructor.
public T Target { get; }Property Value
T
Methods
Equals(T)
Compares a candidate value against this
Criterion%601.
public bool Equals(T other)Parameters
other T
The candidate to compare against this value.
Returns
true if other is deemed
equal to this instance; otherwise, false.
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.
public override bool Equals(object obj)Parameters
obj object
The object to compare to this object.
Returns
true if obj is equal to this
object; otherwise, false.
GetHashCode()
Returns the hash code for the object.
public override int GetHashCode()Returns
The hash code.