Class EquivalentException
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
memberNamestringThe name of the member that caused the circular reference
Returns
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
Returns
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
expectedIEnumerable<object>The values expected to be found in the
actualcollection.actualIEnumerable<object>The actual collection values.
actualLeftoversIEnumerable<object>The values from
actualthat did not have matchingexpectedvaluesmemberNamestringThe name of the member that was being inspected (may be an empty string for a top-level collection)
Returns
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
expectedobjectThe expected member value
actualobjectThe actual member value
keyNamestringThe name of the key with mismatched values
Returns
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
expectedMemberNamesIEnumerable<string>The expected member names
actualMemberNamesIEnumerable<string>The actual member names
prefixstringThe 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
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
expectedobjectThe expected member value
actualobjectThe actual member value
memberNamestringThe name of the mismatched member (may be an empty string for a top-level object)
innerExceptionExceptionThe inner exception that was thrown during value comparison, typically during a call to CompareTo(object)
Returns
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
expectedTypeTypeThe expected type
actualTypeTypeThe actual type
memberNamestringThe name of the member that was being inspected (may be an empty string for a top-level comparison)
Returns
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
expectedobjectThe object that was expected to be found in
actualcollection.actualIEnumerable<object>The actual collection which was missing the object.
memberNamestringThe name of the member that was being inspected (may be an empty string for a top-level collection)