Table of Contents

Class EquivalentException

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

Exception thrown when Assert.Equivalent fails.

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

Methods

ForCircularReference(string)

Creates a new instance of EquivalentException which shows a message that indicates a circular reference was discovered.

public static EquivalentException ForCircularReference(string memberName)

Parameters

memberName string

The name of the member that caused the circular reference

Returns

EquivalentException

ForExceededDepth(int, string)

Creates a new instance of EquivalentException which shows a message that indicates that the maximum comparison depth was exceeded.

public static EquivalentException ForExceededDepth(int depth, string memberName)

Parameters

depth int

The depth reached

memberName string

The member access which caused the failure

Returns

EquivalentException

ForExtraCollectionValue(IEnumerable<object?>, IEnumerable<object?>, IEnumerable<object?>, string)

Creates a new instance of EquivalentException which shows a message that indicates that actual contained one or more values that were not specified in expected.

public static EquivalentException ForExtraCollectionValue(IEnumerable<object?> expected, IEnumerable<object?> actual, IEnumerable<object?> actualLeftovers, string memberName)

Parameters

expected IEnumerable<object>

The values expected to be found in the actual collection.

actual IEnumerable<object>

The actual collection values.

actualLeftovers IEnumerable<object>

The values from actual that did not have matching expected values

memberName string

The name of the member that was being inspected (may be an empty string for a top-level collection)

Returns

EquivalentException

ForGroupingWithMismatchedValues(object?, object?, string)

Creates a new instance of EquivalentException which shows a message that indicates that the fault comes from an individual value mismatch one of the members.

public static EquivalentException ForGroupingWithMismatchedValues(object? expected, object? actual, string keyName)

Parameters

expected object

The expected member value

actual object

The actual member value

keyName string

The name of the key with mismatched values

Returns

EquivalentException

ForMemberListMismatch(IEnumerable<string>, IEnumerable<string>, string)

Creates a new instance of EquivalentException which shows a message that indicates that the list of available members does not match.

public static EquivalentException ForMemberListMismatch(IEnumerable<string> expectedMemberNames, IEnumerable<string> actualMemberNames, string prefix)

Parameters

expectedMemberNames IEnumerable<string>

The expected member names

actualMemberNames IEnumerable<string>

The actual member names

prefix string

The prefix to be applied to the member names (may be an empty string for a top-level object, or a name in "member." format used as a prefix to show the member name list)

Returns

EquivalentException

ForMemberValueMismatch(object?, object?, string, Exception?)

Creates a new instance of EquivalentException which shows a message that indicates that the fault comes from an individual value mismatch one of the members.

public static EquivalentException ForMemberValueMismatch(object? expected, object? actual, string memberName, Exception? innerException = null)

Parameters

expected object

The expected member value

actual object

The actual member value

memberName string

The name of the mismatched member (may be an empty string for a top-level object)

innerException Exception

The inner exception that was thrown during value comparison, typically during a call to CompareTo(object)

Returns

EquivalentException

ForMismatchedTypes(Type, Type, string)

Creates a new instance of EquivalentException which shows a message that indicates that expectedType does not match actualType. This is typically only used in special case comparison where it would be known that general comparison would fail for other reasons, like two objects derived from FileSystemInfo with different concrete types.

public static EquivalentException ForMismatchedTypes(Type expectedType, Type actualType, string memberName)

Parameters

expectedType Type

The expected type

actualType Type

The actual type

memberName string

The name of the member that was being inspected (may be an empty string for a top-level comparison)

Returns

EquivalentException

ForMissingCollectionValue(object?, IEnumerable<object?>, string)

Creates a new instance of EquivalentException which shows a message that indicates a value was missing from the actual collection.

public static EquivalentException ForMissingCollectionValue(object? expected, IEnumerable<object?> actual, string memberName)

Parameters

expected object

The object that was expected to be found in actual collection.

actual IEnumerable<object>

The actual collection which was missing the object.

memberName string

The name of the member that was being inspected (may be an empty string for a top-level collection)

Returns

EquivalentException