Table of Contents

Class SnapshotComparer

Namespace
SnapshotAssertions
Assembly
SnapshotAssertions.dll

Pure string-against-string comparison with SnapshotOptions-driven normalization (line endings, BOM, trailing whitespace, trailing newline). Stateless and allocation-friendly; the heavy work of computing a per-line diff is deferred to LineDiffRenderer on mismatch.

public static class SnapshotComparer
Inheritance
SnapshotComparer
Inherited Members

Methods

AreEqual(string, string, SnapshotOptions)

Compares actual against expected under options. Returns true if the two are considered equal under the option-driven normalization rules; otherwise false.

public static bool AreEqual(string actual, string expected, SnapshotOptions options)

Parameters

actual string

The actual content produced by the test.

expected string

The expected baseline content.

options SnapshotOptions

The comparison options. Required (use Default for strict-default semantics).

Returns

bool

true if the two strings are considered equal.

Exceptions

ArgumentNullException

A required argument is null.

Normalize(string, SnapshotOptions)

Applies the option-driven normalization to content and returns the result. Exposed for diff rendering, which needs to render the same normalized form the equality check used.

public static string Normalize(string content, SnapshotOptions options)

Parameters

content string

The content to normalize.

options SnapshotOptions

The options to apply.

Returns

string

The normalized content.

Exceptions

ArgumentNullException

A required argument is null.