Skip to content

ShouldExtensions.Should Method

Overloads

Name Description
Should<T>(T) Begins a fluent assertion on the specified value.
Should(Boolean) Begins a fluent assertion on the specified boolean value.
Should(String) Begins a fluent assertion on the specified string value.
Should(Exception) Begins a fluent assertion on the specified exception.
Should(ArgumentException) Begins a fluent assertion on the specified ArgumentException.
Should(ArgumentOutOfRangeException) Begins a fluent assertion on the specified ArgumentOutOfRangeException.
Should<T>(IEnumerable<T>) Begins a fluent assertion on the specified enumerable.
Should<TKey, TValue>(IReadOnlyDictionary<TKey, TValue>) Begins a fluent assertion on the specified read-only dictionary.
Should<TKey, TValue>(Dictionary<TKey, TValue>) Begins a fluent assertion on the specified dictionary.
Should<T>(Span<T>) Begins a fluent assertion on the specified span.
Should<T>(ReadOnlySpan<T>) Begins a fluent assertion on the specified read-only span.
Should(Action) Begins a fluent assertion on the specified action.
Should(Func<Task>) Begins a fluent assertion on the specified async action.
Should(Byte) Begins a fluent assertion on the specified byte value.
Should(SByte) Begins a fluent assertion on the specified sbyte value.
Should(Int16) Begins a fluent assertion on the specified short value.
Should(UInt16) Begins a fluent assertion on the specified ushort value.
Should(Int32) Begins a fluent assertion on the specified int value.
Should(UInt32) Begins a fluent assertion on the specified uint value.
Should(Int64) Begins a fluent assertion on the specified long value.
Should(UInt64) Begins a fluent assertion on the specified ulong value.
Should(IntPtr) Begins a fluent assertion on the specified nint value.
Should(UIntPtr) Begins a fluent assertion on the specified nuint value.
Should(Decimal) Begins a fluent assertion on the specified decimal value.
Should(Single) Begins a fluent assertion on the specified float value.
Should(Double) Begins a fluent assertion on the specified double value.
Should(Half) Begins a fluent assertion on the specified Half value.

Should<T>(T)

Begins a fluent assertion on the specified value.

public static ObjectAssertions<T> Should<T>(this T? value);

Type Parameters

Name Description
T The type of the value.

Parameters

Name Type Description
value T The value to assert on.

Returns

ObjectAssertions<T>

An ObjectAssertions<T> for the value.

Should(Boolean)

Begins a fluent assertion on the specified boolean value.

public static BooleanAssertions Should(this bool value);

Parameters

Name Type Description
value Boolean The boolean value to assert on.

Returns

BooleanAssertions

A BooleanAssertions for the value.

Should(String)

Begins a fluent assertion on the specified string value.

public static StringAssertions Should(this string? value);

Parameters

Name Type Description
value String The string value to assert on.

Returns

StringAssertions

A StringAssertions for the value.

Should(Exception)

Begins a fluent assertion on the specified exception.

public static ExceptionAssertions<Exception> Should(this Exception? value);

Parameters

Name Type Description
value Exception The exception to assert on.

Returns

ExceptionAssertions<Exception>

An ExceptionAssertions<T> for the exception.

Should(ArgumentException)

Begins a fluent assertion on the specified ArgumentException.

public static ExceptionAssertions<ArgumentException> Should(this ArgumentException? value);

Parameters

Name Type Description
value ArgumentException The exception to assert on.

Returns

ExceptionAssertions<ArgumentException>

An ExceptionAssertions<T> for the exception.

Should(ArgumentOutOfRangeException)

Begins a fluent assertion on the specified ArgumentOutOfRangeException.

public static ExceptionAssertions<ArgumentOutOfRangeException> Should(this ArgumentOutOfRangeException? value);

Parameters

Name Type Description
value ArgumentOutOfRangeException The exception to assert on.

Returns

ExceptionAssertions<ArgumentOutOfRangeException>

An ExceptionAssertions<T> for the exception.

Should<T>(IEnumerable<T>)

Begins a fluent assertion on the specified enumerable.

public static EnumerableAssertions<IEnumerable<T>, T> Should<T>(this IEnumerable<T>? value);

Type Parameters

Name Description
T The type of elements in the enumerable.

Parameters

Name Type Description
value IEnumerable<T> The enumerable to assert on.

Returns

EnumerableAssertions<IEnumerable<T>, T>

An EnumerableAssertions<TEnumerable, T> for the enumerable.

Should<TKey, TValue>(IReadOnlyDictionary<TKey, TValue>)

Begins a fluent assertion on the specified read-only dictionary.

public static ReadOnlyDictionaryAssertions<IReadOnlyDictionary<TKey, TValue>, TKey, TValue> Should<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> value);

Type Parameters

Name Description
TKey The type of the dictionary keys.
TValue The type of the dictionary values.

Parameters

Name Type Description
value IReadOnlyDictionary<TKey, TValue> The dictionary to assert on.

Returns

ReadOnlyDictionaryAssertions<IReadOnlyDictionary<TKey, TValue>, TKey, TValue>

A ReadOnlyDictionaryAssertions<TDictionary, TKey, TValue> for the dictionary.

Should<TKey, TValue>(Dictionary<TKey, TValue>)

Begins a fluent assertion on the specified dictionary.

public static ReadOnlyDictionaryAssertions<Dictionary<TKey, TValue>, TKey, TValue> Should<TKey, TValue>(this Dictionary<TKey, TValue> value);

Type Parameters

Name Description
TKey The type of the dictionary keys.
TValue The type of the dictionary values.

Parameters

Name Type Description
value Dictionary<TKey, TValue> The dictionary to assert on.

Returns

ReadOnlyDictionaryAssertions<Dictionary<TKey, TValue>, TKey, TValue>

A ReadOnlyDictionaryAssertions<TDictionary, TKey, TValue> for the dictionary.

Should<T>(Span<T>)

Begins a fluent assertion on the specified span.

public static ReadOnlySpanAssertions<T> Should<T>(this Span<T> value);

Type Parameters

Name Description
T The type of elements in the span.

Parameters

Name Type Description
value Span<T> The span to assert on.

Returns

ReadOnlySpanAssertions<T>

A ReadOnlySpanAssertions<T> for the span.

Should<T>(ReadOnlySpan<T>)

Begins a fluent assertion on the specified read-only span.

public static ReadOnlySpanAssertions<T> Should<T>(this ReadOnlySpan<T> value);

Type Parameters

Name Description
T The type of elements in the span.

Parameters

Name Type Description
value ReadOnlySpan<T> The span to assert on.

Returns

ReadOnlySpanAssertions<T>

A ReadOnlySpanAssertions<T> for the span.

Should(Action)

Begins a fluent assertion on the specified action.

public static ActionAssertions Should(this Action value);

Parameters

Name Type Description
value Action The action to assert on.

Returns

ActionAssertions

An ActionAssertions for the action.

Should(Func<Task>)

Begins a fluent assertion on the specified async action.

public static AsyncActionAssertions Should(this Func<Task> value);

Parameters

Name Type Description
value Func<Task> The async action to assert on.

Returns

AsyncActionAssertions

An AsyncActionAssertions for the async action.

Should(Byte)

Begins a fluent assertion on the specified byte value.

public static IntegerAssertions<Byte> Should(this Byte value);

Parameters

Name Type Description
value Byte The byte value to assert on.

Returns

IntegerAssertions<Byte>

An IntegerAssertions<T> for the value.

Should(SByte)

Begins a fluent assertion on the specified sbyte value.

public static IntegerAssertions<sbyte> Should(this sbyte value);

Parameters

Name Type Description
value SByte The sbyte value to assert on.

Returns

IntegerAssertions<SByte>

An IntegerAssertions<T> for the value.

Should(Int16)

Begins a fluent assertion on the specified short value.

public static IntegerAssertions<Int16> Should(this Int16 value);

Parameters

Name Type Description
value Int16 The short value to assert on.

Returns

IntegerAssertions<Int16>

An IntegerAssertions<T> for the value.

Should(UInt16)

Begins a fluent assertion on the specified ushort value.

public static IntegerAssertions<ushort> Should(this ushort value);

Parameters

Name Type Description
value UInt16 The ushort value to assert on.

Returns

IntegerAssertions<UInt16>

An IntegerAssertions<T> for the value.

Should(Int32)

Begins a fluent assertion on the specified int value.

public static IntegerAssertions<int> Should(this int value);

Parameters

Name Type Description
value Int32 The int value to assert on.

Returns

IntegerAssertions<Int32>

An IntegerAssertions<T> for the value.

Should(UInt32)

Begins a fluent assertion on the specified uint value.

public static IntegerAssertions<uint> Should(this uint value);

Parameters

Name Type Description
value UInt32 The uint value to assert on.

Returns

IntegerAssertions<UInt32>

An IntegerAssertions<T> for the value.

Should(Int64)

Begins a fluent assertion on the specified long value.

public static IntegerAssertions<long> Should(this long value);

Parameters

Name Type Description
value Int64 The long value to assert on.

Returns

IntegerAssertions<Int64>

An IntegerAssertions<T> for the value.

Should(UInt64)

Begins a fluent assertion on the specified ulong value.

public static IntegerAssertions<ulong> Should(this ulong value);

Parameters

Name Type Description
value UInt64 The ulong value to assert on.

Returns

IntegerAssertions<UInt64>

An IntegerAssertions<T> for the value.

Should(IntPtr)

Begins a fluent assertion on the specified nint value.

public static IntegerAssertions<nint> Should(this nint value);

Parameters

Name Type Description
value IntPtr The nint value to assert on.

Returns

IntegerAssertions<IntPtr>

An IntegerAssertions<T> for the value.

Should(UIntPtr)

Begins a fluent assertion on the specified nuint value.

public static IntegerAssertions<nuint> Should(this nuint value);

Parameters

Name Type Description
value UIntPtr The nuint value to assert on.

Returns

IntegerAssertions<UIntPtr>

An IntegerAssertions<T> for the value.

Should(Decimal)

Begins a fluent assertion on the specified decimal value.

public static DecimalAssertions Should(this decimal value);

Parameters

Name Type Description
value Decimal The decimal value to assert on.

Returns

DecimalAssertions

A DecimalAssertions for the value.

Should(Single)

Begins a fluent assertion on the specified float value.

public static FloatingPointAssertions<float> Should(this float value);

Parameters

Name Type Description
value Single The float value to assert on.

Returns

FloatingPointAssertions<Single>

A FloatingPointAssertions<T> for the value.

Should(Double)

Begins a fluent assertion on the specified double value.

public static FloatingPointAssertions<double> Should(this double value);

Parameters

Name Type Description
value Double The double value to assert on.

Returns

FloatingPointAssertions<Double>

A FloatingPointAssertions<T> for the value.

Should(Half)

Begins a fluent assertion on the specified Half value.

public static FloatingPointAssertions<Half> Should(this Half value);

Parameters

Name Type Description
value Half The Half value to assert on.

Returns

FloatingPointAssertions<Half>

A FloatingPointAssertions<T> for the value.