ISnapshotComparer Interface

Decides whether the snapshot produced by a test matches the verified snapshot. A comparer is registered for a SnapshotType in SnapshotComparerCollection.

public interface ISnapshotComparer

Methods

NameDescription
Equals(SnapshotData, SnapshotData)Compares two snapshots.
Equals(SnapshotData, SnapshotData, string?)Compares two snapshots and, when they do not match, describes why.

Equals overloads

Equals(SnapshotData, SnapshotData)

Compares two snapshots.

bool Equals(SnapshotData expected, SnapshotData actual)
Parameters
expected SnapshotData
The verified snapshot.
actual SnapshotData
The snapshot produced by the test.
Returns

bool true when the snapshots match.

Equals(SnapshotData, SnapshotData, string?)

ISnapshotComparer.cs

Compares two snapshots and, when they do not match, describes why.

public bool Equals(SnapshotData expected, SnapshotData actual, out string? mismatchReason)
Parameters
expected SnapshotData
The verified snapshot.
actual SnapshotData
The snapshot produced by the test.
mismatchReason string?
When the snapshots do not match, a short description of the difference that is added to the assertion message (for example, the similarity score and the threshold it did not reach), or null when the comparer has nothing to add. Always null when the snapshots match.
Returns

bool true when the snapshots match.

Remarks

The default implementation calls ISnapshotComparer.Equals and gives no reason.