SnapshotUpdateStrategy Class
public abstract class SnapshotUpdateStrategyNo documentation is available.
Constructors
| Name | Description |
|---|---|
| SnapshotUpdateStrategy() |
SnapshotUpdateStrategy()
protected SnapshotUpdateStrategy()No documentation is available.
Properties
| Name | Description |
|---|---|
| Default | |
| Disallow | Do not update the snapshots and fail the tests if the snapshots are different. |
| MergeTool | 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. |
| MergeToolSync | 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. |
| Overwrite | Overwrite the verified snapshot files with the new snapshots. The test fails if the snapshots are different. |
| OverwriteWithoutFailure | Overwrite the verified snapshot files with the new snapshots. The test won't fail. |
| ReuseTemporaryFile | 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. |
Default
SnapshotUpdateStrategy.csDisallow
SnapshotUpdateStrategy.csDo not update the snapshots and fail the tests if the snapshots are different.
public static SnapshotUpdateStrategy Disallow { get; }Property value
MergeTool
SnapshotUpdateStrategy.csOpen 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; }Property value
MergeToolSync
SnapshotUpdateStrategy.csOpen 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; }Property value
Overwrite
SnapshotUpdateStrategy.csOverwrite the verified snapshot files with the new snapshots. The test fails if the snapshots are different.
public static SnapshotUpdateStrategy Overwrite { get; }Property value
OverwriteWithoutFailure
SnapshotUpdateStrategy.csOverwrite the verified snapshot files with the new snapshots. The test won't fail.
public static SnapshotUpdateStrategy OverwriteWithoutFailure { get; }Property value
ReuseTemporaryFile
SnapshotUpdateStrategy.csMethods
| Name | Description |
|---|---|
| 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
settingsSnapshotSettings- The settings of the assertion.
pathstring- The path of the source file that contains the test.
expectedSnapshotstring?- 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 isnullwhen there is no such file, or when the snapshots do not differ. actualSnapshotstring?- 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 asexpectedSnapshot. It isnullwhen the snapshots do not differ.
Returns
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)ToString()
SnapshotUpdateStrategy.csUpdateFile(SnapshotSettings, string, string)
public abstract void UpdateFile(SnapshotSettings settings, string verifiedFilePath, string actualFilePath)Parameters
settingsSnapshotSettingsverifiedFilePathstringactualFilePathstring
No documentation is available.
UpdateFiles(SnapshotSettings, IReadOnlyList<SnapshotUpdateFile>, IReadOnlyList<string>)
SnapshotUpdateStrategy.csUpdates one or more snapshot files and deletes obsolete verified files.
public virtual void UpdateFiles(SnapshotSettings settings, IReadOnlyList<SnapshotUpdateFile> filesToUpdate, IReadOnlyList<string> filesToDelete)Parameters
settingsSnapshotSettingsfilesToUpdateIReadOnlyList<SnapshotUpdateFile>filesToDeleteIReadOnlyList<string>