Class EqualException
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
mismatchedIndexint?The index at which the collections differ
expectedstringThe expected collection
expectedPointerint?The spacing into the expected collection where the difference occurs
expectedTypestringThe type of the expected collection items, when they differ in type
actualstringThe actual collection
actualPointerint?The spacing into the actual collection where the difference occurs
actualTypestringThe type of the actual collection items, when they differ in type
collectionDisplaystringThe display name for the collection type (defaults to "Collections")
Returns
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
mismatchedIndexint?The index at which the collections differ
expectedstringThe expected collection
expectedPointerint?The spacing into the expected collection where the difference occurs
expectedTypestringThe type of the expected collection items, when they differ in type
actualstringThe actual collection
actualPointerint?The spacing into the actual collection where the difference occurs
actualTypestringThe type of the actual collection items, when they differ in type
errorExceptionThe optional exception that was thrown during comparison
collectionDisplaystringThe display name for the collection type (defaults to "Collections")
Returns
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
expectedstringThe expected value
actualstringThe actual value
expectedIndexintThe index point in the expected string where the values differ
actualIndexintThe index point in the actual string where the values differ
Returns
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
expectedstringThe expected value
actualstringThe actual value
expectedIndexintThe index point in the expected string where the values differ
actualIndexintThe index point in the actual string where the values differ
headerstringThe header to display in the assertion heading
Returns
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
expectedobjectThe expected value
actualobjectThe actual value
bannerstringThe banner to show; if
null, then the standard banner of "Values differ" will be used
Returns
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
expectedobjectThe expected value
actualobjectThe actual value
errorExceptionThe optional exception that was thrown during comparison
bannerstringThe banner to show; if
null, then the standard banner of "Values differ" will be used. Iferroris notnull, then the banner used will always be "Exception thrown during comparison", regardless of the value passed here.