Class SnapshotResult
- Namespace
- SnapshotAssertions
- Assembly
- SnapshotAssertions.dll
The outcome of a snapshot comparison, including paths to the expected baseline and (on mismatch or no-baseline) the written actual file, plus a rendered line-based diff for failure messages.
public sealed record SnapshotResult : IEquatable<SnapshotResult>
- Inheritance
-
SnapshotResult
- Implements
- Inherited Members
Properties
ActualFilePath
Absolute path to the written .actual.txt file when
Outcome is Mismatched or
NoBaseline; null otherwise.
public string? ActualFilePath { get; }
Property Value
Diff
Rendered line-based diff between expected and actual content when Outcome is Mismatched; null otherwise. Format is not stable; intended for failure-message display, not programmatic parsing.
public string? Diff { get; }
Property Value
ExpectedFilePath
Absolute path to the expected baseline file. Always populated.
public string ExpectedFilePath { get; }
Property Value
IsPass
public bool IsPass { get; }
Property Value
Outcome
The classification of the comparison outcome.
public SnapshotMatchOutcome Outcome { get; }
Property Value
Methods
Accepted(string)
Constructs a Accepted result.
public static SnapshotResult Accepted(string expectedFilePath)
Parameters
expectedFilePathstringAbsolute path to the now-overwritten expected file.
Returns
- SnapshotResult
A passing result indicating the actual content was written over the baseline (accept-mode).
Exceptions
- ArgumentNullException
expectedFilePathis null.
Describe()
Renders a multi-line description of the result for use in assertion failure messages and diagnostic output. Includes the expected path, the actual path (when applicable), the diff (when applicable), and accept-flow guidance.
public string Describe()
Returns
- string
A multi-line description; format is not stable.
Matched(string)
Constructs a Matched result.
public static SnapshotResult Matched(string expectedFilePath)
Parameters
expectedFilePathstringAbsolute path to the matching expected file.
Returns
- SnapshotResult
A passing result.
Exceptions
- ArgumentNullException
expectedFilePathis null.
Mismatched(string, string, string)
Constructs a Mismatched result.
public static SnapshotResult Mismatched(string expectedFilePath, string actualFilePath, string diff)
Parameters
expectedFilePathstringAbsolute path to the expected file.
actualFilePathstringAbsolute path to the written
.actual.txtfile.diffstringRendered line-based diff for failure-message display.
Returns
- SnapshotResult
A failing result describing the mismatch.
Exceptions
- ArgumentNullException
A required argument is null.
NoBaseline(string, string)
Constructs a NoBaseline result.
public static SnapshotResult NoBaseline(string expectedFilePath, string actualFilePath)
Parameters
expectedFilePathstringAbsolute path to where the expected file would be.
actualFilePathstringAbsolute path to the written
.actual.txtfile the caller can inspect and rename to.expected.txtto accept.
Returns
- SnapshotResult
A failing result describing the missing baseline.
Exceptions
- ArgumentNullException
A required argument is null.
WriteDescription(TextWriter)
Writes the same description as Describe() to writer.
public void WriteDescription(TextWriter writer)
Parameters
writerTextWriterThe destination text writer.
Exceptions
- ArgumentNullException
writeris null.