Class MatchesSnapshotShorthandExtensions
- Namespace
- TUnit.Assertions.Extensions
- Assembly
- SnapshotAssertions.TUnit.dll
Top-level shorthand entry points that wrap the most common MatchesSnapshot()...
chains. Each shorthand is equivalent to spelling out the underlying chain: they exist
purely to reduce ceremony.
public static class MatchesSnapshotShorthandExtensions
- Inheritance
-
MatchesSnapshotShorthandExtensions
- Inherited Members
Remarks
Lives in TUnit.Assertions.Extensions (where TUnit's source generator emits the core
entry-point extension method MatchesSnapshot()) so consumers do not need a second
using directive to discover these shorthands. If you can call
Assert.That(actual).MatchesSnapshot() in a file, you can also call
Assert.That(actual).MatchesSnapshot("custom-name") and
Assert.That(actual).MatchesSnapshotFile("/path/to/file.txt") there: same auto-import.
Methods
MatchesSnapshot(IAssertionSource<string>, SnapshotOptions)
Asserts that source's actual content matches the snapshot baseline
(resolved via the active TUnit test context), comparing under the supplied
options. Equivalent to source.MatchesSnapshot().WithOptions(options).
public static SnapshotAssertion MatchesSnapshot(this IAssertionSource<string> source, SnapshotOptions options)
Parameters
sourceIAssertionSource<string>The assertion source over a string.
optionsSnapshotOptionsThe comparison options.
Returns
- SnapshotAssertion
The assertion configured for the supplied options.
MatchesSnapshot(IAssertionSource<string>, string)
Asserts that source's actual content matches the snapshot baseline
identified by snapshotName under the project's Snapshots/
directory. Equivalent to source.MatchesSnapshot().WithName(snapshotName).
public static SnapshotAssertion MatchesSnapshot(this IAssertionSource<string> source, string snapshotName)
Parameters
sourceIAssertionSource<string>The assertion source over a string.
snapshotNamestringThe base name (without extension).
Returns
- SnapshotAssertion
The assertion configured for the explicit name.
MatchesSnapshot(IAssertionSource<string>, string, SnapshotOptions)
Asserts that source's actual content matches the snapshot baseline
identified by snapshotName, comparing under the supplied
options.
public static SnapshotAssertion MatchesSnapshot(this IAssertionSource<string> source, string snapshotName, SnapshotOptions options)
Parameters
sourceIAssertionSource<string>The assertion source over a string.
snapshotNamestringThe base name (without extension).
optionsSnapshotOptionsThe comparison options.
Returns
- SnapshotAssertion
The assertion configured for the explicit name and options.
MatchesSnapshotFile(IAssertionSource<string>, string)
Asserts that source's actual content matches the snapshot baseline
at the explicit absolute or relative filePath. Equivalent to
source.MatchesSnapshot().AtPath(filePath).
public static SnapshotAssertion MatchesSnapshotFile(this IAssertionSource<string> source, string filePath)
Parameters
sourceIAssertionSource<string>The assertion source over a string.
filePathstringThe path to the expected baseline file.
Returns
- SnapshotAssertion
The assertion configured for the explicit path.
MatchesSnapshotFile(IAssertionSource<string>, string, SnapshotOptions)
Asserts that source's actual content matches the snapshot baseline
at the explicit filePath, comparing under the supplied
options.
public static SnapshotAssertion MatchesSnapshotFile(this IAssertionSource<string> source, string filePath, SnapshotOptions options)
Parameters
sourceIAssertionSource<string>The assertion source over a string.
filePathstringThe path to the expected baseline file.
optionsSnapshotOptionsThe comparison options.
Returns
- SnapshotAssertion
The assertion configured for the explicit path and options.