SnapshotUpdateStrategy Class

public abstract class SnapshotUpdateStrategy

No documentation is available.

Constructors

NameDescription
SnapshotUpdateStrategy()

SnapshotUpdateStrategy()

protected SnapshotUpdateStrategy()

No documentation is available.

Properties

NameDescription
Default
DisallowDo not update the snapshots and fail the tests if the snapshots are different.
MergeToolOpen a merge tool to update the snapshots. You can specify the merge tools to use using SnapshotSettings.MergeTools. The test fails if the snapshots are different.
MergeToolSyncOpen a merge tool to update the snapshots and wait for it to close before continuing the test execution. You can specify the merge tools to use using SnapshotSettings.MergeTools. The test fails if the snapshots are different.
OverwriteOverwrite the verified snapshot files with the new snapshots. The test fails if the snapshots are different.
OverwriteWithoutFailureOverwrite the verified snapshot files with the new snapshots. The test won't fail.
ReuseTemporaryFileNot used by file snapshots: the actual file always lives next to the verified file, and it is removed once it is no longer relevant.
public static SnapshotUpdateStrategy Default { get; }

No documentation is available.

Do not update the snapshots and fail the tests if the snapshots are different.

public static SnapshotUpdateStrategy Disallow { get; }

Open a merge tool to update the snapshots. You can specify the merge tools to use using SnapshotSettings.MergeTools. The test fails if the snapshots are different.

public static SnapshotUpdateStrategy MergeTool { get; }

Open a merge tool to update the snapshots and wait for it to close before continuing the test execution. You can specify the merge tools to use using SnapshotSettings.MergeTools. The test fails if the snapshots are different.

public static SnapshotUpdateStrategy MergeToolSync { get; }

Overwrite the verified snapshot files with the new snapshots. The test fails if the snapshots are different.

public static SnapshotUpdateStrategy Overwrite { get; }

OverwriteWithoutFailure

SnapshotUpdateStrategy.cs

Overwrite the verified snapshot files with the new snapshots. The test won't fail.

public static SnapshotUpdateStrategy OverwriteWithoutFailure { get; }

ReuseTemporaryFile

SnapshotUpdateStrategy.cs

Not used by file snapshots: the actual file always lives next to the verified file, and it is removed once it is no longer relevant.

public virtual bool ReuseTemporaryFile { get; }

Property value

bool

Remarks

This property has no effect and will be removed in the next major version.

Methods

NameDescription
CanUpdateSnapshot(SnapshotSettings, string, string?, string?)Indicates whether the verified snapshot files of an assertion can be updated. It is called when the snapshots differ, or when SnapshotSettings.ForceUpdateSnapshots is set.
MustReportError(SnapshotSettings, string)Indicates if an exception must be thrown when the snapshots differ.
ToString()
UpdateFile(SnapshotSettings, string, string)
UpdateFiles(SnapshotSettings, IReadOnlyList<SnapshotUpdateFile>, IReadOnlyList<string>)Updates one or more snapshot files and deletes obsolete verified files.

CanUpdateSnapshot(SnapshotSettings, string, string?, string?)

Indicates whether the verified snapshot files of an assertion can be updated. It is called when the snapshots differ, or when SnapshotSettings.ForceUpdateSnapshots is set.

public abstract bool CanUpdateSnapshot(SnapshotSettings settings, string path, string? expectedSnapshot, string? actualSnapshot)

Parameters

settings SnapshotSettings
The settings of the assertion.
path string
The path of the source file that contains the test.
expectedSnapshot string?
The paths of the verified snapshot files found on disk for the assertion, sorted and separated by \n. It is not the content of the files. It is null when there is no such file, or when the snapshots do not differ.
actualSnapshot string?
The paths of the verified snapshot files the assertion produces, sorted and separated by \n. It is not the content of the files. When a single snapshot changed, it is the same path as expectedSnapshot. It is null when the snapshots do not differ.

Returns

bool

Remarks

Use SnapshotUpdateStrategy.UpdateFiles to inspect the files: it receives each verified file with the actual file that contains the new snapshot.

MustReportError(SnapshotSettings, string)

Indicates if an exception must be thrown when the snapshots differ.

public abstract bool MustReportError(SnapshotSettings settings, string path)

Parameters

settings SnapshotSettings
path string

Returns

bool

public override string ToString()

Returns

string

No documentation is available.

UpdateFile(SnapshotSettings, string, string)

public abstract void UpdateFile(SnapshotSettings settings, string verifiedFilePath, string actualFilePath)

Parameters

settings SnapshotSettings
verifiedFilePath string
actualFilePath string

No documentation is available.

UpdateFiles(SnapshotSettings, IReadOnlyList<SnapshotUpdateFile>, IReadOnlyList<string>)

SnapshotUpdateStrategy.cs

Updates one or more snapshot files and deletes obsolete verified files.

public virtual void UpdateFiles(SnapshotSettings settings, IReadOnlyList<SnapshotUpdateFile> filesToUpdate, IReadOnlyList<string> filesToDelete)

Parameters

settings SnapshotSettings
filesToUpdate IReadOnlyList<SnapshotUpdateFile>
filesToDelete IReadOnlyList<string>