Class SnapshotEvaluator
- Namespace
- SnapshotAssertions
- Assembly
- SnapshotAssertions.dll
Orchestrates a single snapshot comparison: reads the expected baseline from disk if
present, compares against the actual content under the supplied options, applies
accept-mode when active, and writes the normalized actual content to .actual.txt
on failure. Every baseline-candidate is persisted in normalized form so an accepted
baseline matches the form the comparison reads back.
public static class SnapshotEvaluator
- Inheritance
-
SnapshotEvaluator
- Inherited Members
Remarks
The evaluator is the integration point between the pure helpers (SnapshotComparer, SnapshotAcceptMode, LineDiffRenderer, SnapshotFileResolver) and the filesystem. Test-framework adapters call EvaluateAsync(string, SnapshotPaths, SnapshotOptions, bool?, CancellationToken) and translate the returned SnapshotResult into their framework's pass/fail vocabulary.
Methods
EvaluateAsync(string, SnapshotPaths, SnapshotOptions, bool?, CancellationToken)
Compares actualContent against the baseline at
paths's expected path. On mismatch or missing baseline, writes the
normalized actual content to the actual path (or, if accept-mode is active, over the
expected path) and returns a result describing the outcome. The written form is the
option-driven normalized form, not the raw subject.
public static Task<SnapshotResult> EvaluateAsync(string actualContent, SnapshotPaths paths, SnapshotOptions options, bool? acceptModeOverride = null, CancellationToken cancellationToken = default)
Parameters
actualContentstringThe string produced by the test.
pathsSnapshotPathsThe expected and actual file paths.
optionsSnapshotOptionsThe comparison options.
acceptModeOverridebool?Optional override for accept-mode detection. When null (the default), the live environment is consulted via IsActive(). Tests pass an explicit value to keep their behavior independent of the host environment.
cancellationTokenCancellationTokenCancellation token propagated to the underlying file IO.
Returns
- Task<SnapshotResult>
The comparison outcome.
Exceptions
- ArgumentNullException
A required argument is null.