Class AssertEqualityResult
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
Exception
Returns the exception that caused the failure, if it was based on an exception.
public Exception? Exception { get; }
Property Value
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
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
Y
The right-hand value in the comparison
public object? Y { get; }
Property Value
Methods
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current object.
Returns
- bool
Returns
trueif 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
otherAssertEqualityResultThe object to compare with the current object.
Returns
- bool
Returns
trueif 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
xobjectThe left-hand value in the comparison
yobjectThe right-hand value in the comparison
mismatchIndexintThe mismatch index for both
XandYvaluesexceptionExceptionThe optional exception that was thrown to cause the failure
innerResultAssertEqualityResultThe optional inner result that caused the equality failure
Returns
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
xobjectThe left-hand value in the comparison
yobjectThe right-hand value in the comparison
mismatchIndexXintThe mismatch index for the
XvaluemismatchIndexYintThe mismatch index for the
YvalueexceptionExceptionThe optional exception that was thrown to cause the failure
innerResultAssertEqualityResultThe optional inner result that caused the equality failure
Returns
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
equalboolA flag which indicates whether the values were equal
xobjectThe left-hand value in the comparison
yobjectThe right-hand value in the comparison
exceptionExceptionThe optional exception that was thrown to cause the failure
innerResultAssertEqualityResultThe optional inner result that caused the equality failure
Returns
GetHashCode()
Gets a hash code for the object, to be used in hashed containers.
public override int GetHashCode()
Returns
Operators
operator ==(AssertEqualityResult?, AssertEqualityResult?)
Determines whether two instances of AssertEqualityResult are equal.
public static bool operator ==(AssertEqualityResult? left, AssertEqualityResult? right)
Parameters
leftAssertEqualityResultThe first value
rightAssertEqualityResultThe second value
Returns
- bool
Returns
trueif 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
leftAssertEqualityResultThe first value
rightAssertEqualityResultThe second value
Returns
- bool
Returns
trueif the values are not equal;false, otherwise.