ImageComparer Class
Compares image snapshots by their pixels, exactly or by similarity when ImageComparisonSettings sets a threshold. Every format Meziantou.Framework.Imaging decodes is supported. Every frame is compared: the frames of an animation, the pages of a TIFF file and the representations of an ICO or CUR file.
public sealed class ImageComparer : ISnapshotComparer- Implements
Constructors
| Name | Description |
|---|---|
| ImageComparer(ImageComparisonSettings?) | Compares image snapshots by their pixels, exactly or by similarity when ImageComparisonSettings sets a threshold. Every format Meziantou.Framework.Imaging decodes is supported. Every frame is compared: the frames of an animation, the pages of a TIFF file and the representations of an ICO or CUR file. |
ImageComparer(ImageComparisonSettings?)
ImageComparer.csCompares image snapshots by their pixels, exactly or by similarity when ImageComparisonSettings sets a threshold. Every format Meziantou.Framework.Imaging decodes is supported. Every frame is compared: the frames of an animation, the pages of a TIFF file and the representations of an ICO or CUR file.
public ImageComparer(ImageComparisonSettings? settings = null)Parameters
settingsImageComparisonSettings?
Methods
| Name | Description |
|---|---|
| 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)
ImageComparer.csCompares two snapshots.
public bool Equals(SnapshotData expected, SnapshotData actual)Parameters
expectedSnapshotData- The verified snapshot.
actualSnapshotData- The snapshot produced by the test.
Returns
bool true when the snapshots match.
Equals(SnapshotData, SnapshotData, string?)
ImageComparer.csCompares two snapshots and, when they do not match, describes why.
public bool Equals(SnapshotData expected, SnapshotData actual, out string? mismatchReason)Parameters
expectedSnapshotData- The verified snapshot.
actualSnapshotData- The snapshot produced by the test.
mismatchReasonstring?- 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
nullwhen the comparer has nothing to add. Alwaysnullwhen the snapshots match.
Returns
bool true when the snapshots match.
Remarks
The default implementation calls ISnapshotComparer.Equals and gives no reason.