Class AssertEquivalenceComparer<T>
- Namespace
- Xunit
- Assembly
- xunit.v3.assert.dll
An implementation of IEqualityComparer<T> that uses the same logic from Assert.Equivalent.
public class AssertEquivalenceComparer<T> : IEqualityComparer<T>
Type Parameters
TThe item type being compared
- Inheritance
-
AssertEquivalenceComparer<T>
- Implements
- Inherited Members
Remarks
A generic version of this is provided so that it can be used with Assert.Equal<T>(IEnumerable<T>?, IEnumerable<T>?, IEqualityComparer<T>) to ensure strict ordering of collections while doing equivalence comparisons for the items inside the collection, per https://github.com/xunit/xunit/discussions/3186.
Constructors
AssertEquivalenceComparer(bool)
Initializes a new instance of the AssertEquivalenceComparer<T> class.
public AssertEquivalenceComparer(bool strict)
Parameters
strictboolA flag indicating whether comparisons should be strict.
Methods
Equals(T?, T?)
public bool Equals(T? x, T? y)
Parameters
xTyT
Returns
GetHashCode(T)
public int GetHashCode(T obj)
Parameters
objT