Table of Contents

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

T

The 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

strict bool

A flag indicating whether comparisons should be strict.

Methods

Equals(T?, T?)

public bool Equals(T? x, T? y)

Parameters

x T
y T

Returns

bool

GetHashCode(T)

public int GetHashCode(T obj)

Parameters

obj T

Returns

int