Table of Contents

Class StringAssertExtensions

Namespace
MADE.Testing
Assembly
MADE.Testing.dll

Defines a code assertion helper for string-based scenarios.

public static class StringAssertExtensions
Inheritance
StringAssertExtensions
Inherited Members

Methods

ShouldContain(string?, string, StringComparison)

Tests whether the specified string contains the given substring and throws an exception if it does not.

public static void ShouldContain(this string? value, string substring, StringComparison comparisonType = StringComparison.Ordinal)

Parameters

value string

The string to test.

substring string

The substring to search for.

comparisonType StringComparison

The string comparison type to use. Default is Ordinal.

Exceptions

AssertFailedException

Thrown if the value does not contain the substring.

ShouldEndWith(string?, string, StringComparison)

Tests whether the specified string ends with the given suffix and throws an exception if it does not.

public static void ShouldEndWith(this string? value, string suffix, StringComparison comparisonType = StringComparison.Ordinal)

Parameters

value string

The string to test.

suffix string

The suffix to search for.

comparisonType StringComparison

The string comparison type to use. Default is Ordinal.

Exceptions

AssertFailedException

Thrown if the value does not end with the suffix.

ShouldNotContain(string?, string, StringComparison)

Tests whether the specified string does not contain the given substring and throws an exception if it does.

public static void ShouldNotContain(this string? value, string substring, StringComparison comparisonType = StringComparison.Ordinal)

Parameters

value string

The string to test.

substring string

The substring to search for.

comparisonType StringComparison

The string comparison type to use. Default is Ordinal.

Exceptions

AssertFailedException

Thrown if the value contains the substring.

ShouldStartWith(string?, string, StringComparison)

Tests whether the specified string starts with the given prefix and throws an exception if it does not.

public static void ShouldStartWith(this string? value, string prefix, StringComparison comparisonType = StringComparison.Ordinal)

Parameters

value string

The string to test.

prefix string

The prefix to search for.

comparisonType StringComparison

The string comparison type to use. Default is Ordinal.

Exceptions

AssertFailedException

Thrown if the value does not start with the prefix.