Table of Contents

Class EqualException

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

Exception thrown when Assert.Equal fails.

public class EqualException : XunitException, ISerializable, IAssertionException
Inheritance
EqualException
Implements
Inherited Members

Methods

ForMismatchedCollections(int?, string, int?, string?, string, int?, string?, string?)

Creates a new instance of EqualException to be thrown when two collections are not equal.

public static EqualException ForMismatchedCollections(int? mismatchedIndex, string expected, int? expectedPointer, string? expectedType, string actual, int? actualPointer, string? actualType, string? collectionDisplay = null)

Parameters

mismatchedIndex int?

The index at which the collections differ

expected string

The expected collection

expectedPointer int?

The spacing into the expected collection where the difference occurs

expectedType string

The type of the expected collection items, when they differ in type

actual string

The actual collection

actualPointer int?

The spacing into the actual collection where the difference occurs

actualType string

The type of the actual collection items, when they differ in type

collectionDisplay string

The display name for the collection type (defaults to "Collections")

Returns

EqualException

ForMismatchedCollectionsWithError(int?, string, int?, string?, string, int?, string?, Exception?, string?)

Creates a new instance of EqualException to be thrown when two collections are not equal, and an error has occurred during comparison.

public static EqualException ForMismatchedCollectionsWithError(int? mismatchedIndex, string expected, int? expectedPointer, string? expectedType, string actual, int? actualPointer, string? actualType, Exception? error, string? collectionDisplay = null)

Parameters

mismatchedIndex int?

The index at which the collections differ

expected string

The expected collection

expectedPointer int?

The spacing into the expected collection where the difference occurs

expectedType string

The type of the expected collection items, when they differ in type

actual string

The actual collection

actualPointer int?

The spacing into the actual collection where the difference occurs

actualType string

The type of the actual collection items, when they differ in type

error Exception

The optional exception that was thrown during comparison

collectionDisplay string

The display name for the collection type (defaults to "Collections")

Returns

EqualException

ForMismatchedStrings(string?, string?, int, int)

Creates a new instance of EqualException to be thrown when two string values are not equal.

public static EqualException ForMismatchedStrings(string? expected, string? actual, int expectedIndex, int actualIndex)

Parameters

expected string

The expected value

actual string

The actual value

expectedIndex int

The index point in the expected string where the values differ

actualIndex int

The index point in the actual string where the values differ

Returns

EqualException

ForMismatchedStringsWithHeader(string?, string?, int, int, string)

Creates a new instance of EqualException to be thrown when two string values are not equal.

public static EqualException ForMismatchedStringsWithHeader(string? expected, string? actual, int expectedIndex, int actualIndex, string header)

Parameters

expected string

The expected value

actual string

The actual value

expectedIndex int

The index point in the expected string where the values differ

actualIndex int

The index point in the actual string where the values differ

header string

The header to display in the assertion heading

Returns

EqualException

ForMismatchedValues(object?, object?, string?)

Creates a new instance of EqualException to be thrown when two values are not equal. This may be simple values (like intrinsics) or complex values (like classes or structs).

public static EqualException ForMismatchedValues(object? expected, object? actual, string? banner = null)

Parameters

expected object

The expected value

actual object

The actual value

banner string

The banner to show; if null, then the standard banner of "Values differ" will be used

Returns

EqualException

ForMismatchedValuesWithError(object?, object?, Exception?, string?)

Creates a new instance of EqualException to be thrown when two values are not equal. This may be simple values (like intrinsics) or complex values (like classes or structs). Used when an error has occurred during comparison.

public static EqualException ForMismatchedValuesWithError(object? expected, object? actual, Exception? error = null, string? banner = null)

Parameters

expected object

The expected value

actual object

The actual value

error Exception

The optional exception that was thrown during comparison

banner string

The banner to show; if null, then the standard banner of "Values differ" will be used. If error is not null, then the banner used will always be "Exception thrown during comparison", regardless of the value passed here.

Returns

EqualException