Table of Contents

Class StringAssertEqualityComparer

Namespace
Xunit.Sdk
Assembly
xunit.v3.assert.dll

This static class offers equivalence comparisons for string values

public static class StringAssertEqualityComparer
Inheritance
StringAssertEqualityComparer
Inherited Members

Methods

Equivalent(ReadOnlySpan<char>, ReadOnlySpan<char>, bool, bool, bool, bool)

Compare two string values for equalivalence.

public static AssertEqualityResult Equivalent(ReadOnlySpan<char> expected, ReadOnlySpan<char> actual, bool ignoreCase = false, bool ignoreLineEndingDifferences = false, bool ignoreWhiteSpaceDifferences = false, bool ignoreAllWhiteSpace = false)

Parameters

expected ReadOnlySpan<char>

The expected string value.

actual ReadOnlySpan<char>

The actual string value.

ignoreCase bool

If set to true, ignores cases differences. The invariant culture is used.

ignoreLineEndingDifferences bool

If set to true, treats \r\n, \r, and \n as equivalent.

ignoreWhiteSpaceDifferences bool

If set to true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks) in any non-zero quantity as equivalent.

ignoreAllWhiteSpace bool

If set to true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks), including zero quantities, as equivalent.

Returns

AssertEqualityResult

Remarks

The ignoreWhiteSpaceDifferences and ignoreAllWhiteSpace flags consider the following characters to be white-space: Tab (\t), Space (\u0020), No-Break Space (\u00A0), Ogham Space Mark (\u1680), Mongolian Vowel Separator (\u180E), En Quad (\u2000), Em Quad (\u2001), En Space (\u2002), Em Space (\u2003), Three-Per-Em Space (\u2004), Four-Per-Em Space (\u2004), Six-Per-Em Space (\u2006), Figure Space (\u2007), Punctuation Space (\u2008), Thin Space (\u2009), Hair Space (\u200A), Zero Width Space (\u200B), Narrow No-Break Space (\u202F), Medium Mathematical Space (\u205F), Ideographic Space (\u3000), and Zero Width No-Break Space (\uFEFF). In particular, it does not include carriage return (\r) or line feed (\n), which are covered by ignoreLineEndingDifferences.

Equivalent(string?, string?, bool, bool, bool, bool)

Compare two string values for equalivalence.

public static AssertEqualityResult Equivalent(string? expected, string? actual, bool ignoreCase = false, bool ignoreLineEndingDifferences = false, bool ignoreWhiteSpaceDifferences = false, bool ignoreAllWhiteSpace = false)

Parameters

expected string

The expected string value.

actual string

The actual string value.

ignoreCase bool

If set to true, ignores cases differences. The invariant culture is used.

ignoreLineEndingDifferences bool

If set to true, treats \r\n, \r, and \n as equivalent.

ignoreWhiteSpaceDifferences bool

If set to true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks) in any non-zero quantity as equivalent.

ignoreAllWhiteSpace bool

If set to true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks), including zero quantities, as equivalent.

Returns

AssertEqualityResult

Remarks

The ignoreWhiteSpaceDifferences and ignoreAllWhiteSpace flags consider the following characters to be white-space: Tab (\t), Space (\u0020), No-Break Space (\u00A0), Ogham Space Mark (\u1680), Mongolian Vowel Separator (\u180E), En Quad (\u2000), Em Quad (\u2001), En Space (\u2002), Em Space (\u2003), Three-Per-Em Space (\u2004), Four-Per-Em Space (\u2004), Six-Per-Em Space (\u2006), Figure Space (\u2007), Punctuation Space (\u2008), Thin Space (\u2009), Hair Space (\u200A), Zero Width Space (\u200B), Narrow No-Break Space (\u202F), Medium Mathematical Space (\u205F), Ideographic Space (\u3000), and Zero Width No-Break Space (\uFEFF). In particular, it does not include carriage return (\r) or line feed (\n), which are covered by ignoreLineEndingDifferences.