Table of Contents

Class AssertEqualityResult

Namespace
Xunit.Sdk
Assembly
xunit.v3.assert.dll

Indicates the result of comparing two values for equality. Includes success/failure information, as well as indices where the values differ, if the values are indexed (e.g., collections or strings).

public class AssertEqualityResult : IEquatable<AssertEqualityResult>
Inheritance
AssertEqualityResult
Implements
Inherited Members

Properties

Equal

Returns true if the values were equal; false, otherwise.

public bool Equal { get; }

Property Value

bool

Exception

Returns the exception that caused the failure, if it was based on an exception.

public Exception? Exception { get; }

Property Value

Exception

InnerResult

Returns the comparer result for any inner comparison that caused this result to fail; returns null if there was no inner comparison.

public AssertEqualityResult? InnerResult { get; }

Property Value

AssertEqualityResult

Remarks

If this value is set, then it generally indicates that this comparison was a failed collection comparison, and the inner result indicates the specific item comparison that caused the failure.

MismatchIndexX

Returns the index of the mismatch for the X value, if the comparison failed on a specific index.

public int? MismatchIndexX { get; }

Property Value

int?

MismatchIndexY

Returns the index of the mismatch for the Y value, if the comparison failed on a specific index.

public int? MismatchIndexY { get; }

Property Value

int?

X

The left-hand value in the comparison

public object? X { get; }

Property Value

object

Y

The right-hand value in the comparison

public object? Y { get; }

Property Value

object

Methods

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

Returns true if the values are equal; false, otherwise.

Equals(AssertEqualityResult?)

Determines whether the specified object is equal to the current object.

public bool Equals(AssertEqualityResult? other)

Parameters

other AssertEqualityResult

The object to compare with the current object.

Returns

bool

Returns true if the values are equal; false, otherwise.

ForMismatch(object?, object?, int, Exception?, AssertEqualityResult?)

Creates an instance of AssertEqualityResult where the values were not equal, and there is a single mismatch index (for example, when comparing two collections).

public static AssertEqualityResult ForMismatch(object? x, object? y, int mismatchIndex, Exception? exception = null, AssertEqualityResult? innerResult = null)

Parameters

x object

The left-hand value in the comparison

y object

The right-hand value in the comparison

mismatchIndex int

The mismatch index for both X and Y values

exception Exception

The optional exception that was thrown to cause the failure

innerResult AssertEqualityResult

The optional inner result that caused the equality failure

Returns

AssertEqualityResult

ForMismatch(object?, object?, int, int, Exception?, AssertEqualityResult?)

Creates an instance of AssertEqualityResult where the values were not equal, and there are separate mismatch indices (for example, when comparing two strings under special circumstances).

public static AssertEqualityResult ForMismatch(object? x, object? y, int mismatchIndexX, int mismatchIndexY, Exception? exception = null, AssertEqualityResult? innerResult = null)

Parameters

x object

The left-hand value in the comparison

y object

The right-hand value in the comparison

mismatchIndexX int

The mismatch index for the X value

mismatchIndexY int

The mismatch index for the Y value

exception Exception

The optional exception that was thrown to cause the failure

innerResult AssertEqualityResult

The optional inner result that caused the equality failure

Returns

AssertEqualityResult

ForResult(bool, object?, object?, Exception?, AssertEqualityResult?)

Creates an instance of AssertEqualityResult.

public static AssertEqualityResult ForResult(bool equal, object? x, object? y, Exception? exception = null, AssertEqualityResult? innerResult = null)

Parameters

equal bool

A flag which indicates whether the values were equal

x object

The left-hand value in the comparison

y object

The right-hand value in the comparison

exception Exception

The optional exception that was thrown to cause the failure

innerResult AssertEqualityResult

The optional inner result that caused the equality failure

Returns

AssertEqualityResult

GetHashCode()

Gets a hash code for the object, to be used in hashed containers.

public override int GetHashCode()

Returns

int

Operators

operator ==(AssertEqualityResult?, AssertEqualityResult?)

Determines whether two instances of AssertEqualityResult are equal.

public static bool operator ==(AssertEqualityResult? left, AssertEqualityResult? right)

Parameters

left AssertEqualityResult

The first value

right AssertEqualityResult

The second value

Returns

bool

Returns true if the values are equal; false, otherwise.

operator !=(AssertEqualityResult?, AssertEqualityResult?)

Determines whether two instances of AssertEqualityResult are not equal.

public static bool operator !=(AssertEqualityResult? left, AssertEqualityResult? right)

Parameters

left AssertEqualityResult

The first value

right AssertEqualityResult

The second value

Returns

bool

Returns true if the values are not equal; false, otherwise.