Skip to content

StringAssertions Class

Definition

Provides assertions for string values.

public sealed class StringAssertions : EnumerableAssertions<String, Char>

Constructors

Name Description
StringAssertions(String) Provides assertions for string values.

Methods

Name Description
BeEmpty() Asserts that the string is empty.
BeNullOrEmpty() Asserts that the string is null or empty.
BeNullOrWhiteSpace() Asserts that the string is null, empty, or consists only of white-space characters.
Contain(String, StringComparison) Asserts that the string contains the specified substring.
EndWith(String, StringComparison) Asserts that the string ends with the specified value.
HaveLength(Int32) Asserts that the string has the specified length.
Match(String) Asserts that the string matches the specified regular expression pattern.
NotBeEmpty() Asserts that the string is not empty.
NotBeNullOrEmpty() Asserts that the string is not null or empty.
NotBeNullOrWhiteSpace() Asserts that the string is not null, empty, or consisting only of white-space characters.
NotContain(String, StringComparison) Asserts that the string does not contain the specified substring.
NotEndWith(String, StringComparison) Asserts that the string does not end with the specified value.
NotHaveLength(Int32) Asserts that the string does not have the specified length.
NotMatch(String) Asserts that the string does not match the specified regular expression pattern.
NotStartWith(String, StringComparison) Asserts that the string does not start with the specified value.
StartWith(String, StringComparison) Asserts that the string starts with the specified value.