Skip to content

ShouldExtensions.Should Method ​

Overloads ​

NameDescription
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>(IReadOnlySet<T>)Begins a fluent assertion on the specified read-only set.
Should<T>(HashSet<T>)Begins a fluent assertion on the specified hash set.
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(TimeSpan)Begins a fluent assertion on the specified TimeSpan value.
Should(DateTimeOffset)Begins a fluent assertion on the specified DateTimeOffset value.
Should(DateOnly)Begins a fluent assertion on the specified DateOnly 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.

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

View source

Type Parameters ​

NameDescription
TThe type of the value.

Parameters ​

NameTypeDescription
valueTThe value to assert on.

Returns ​

ObjectAssertions<T>

An ObjectAssertions<T> for the value.

Should(Boolean) ​

Begins a fluent assertion on the specified boolean value.

c#
public static BooleanAssertions Should(this bool value);

View source

Parameters ​

NameTypeDescription
valueBooleanThe boolean value to assert on.

Returns ​

BooleanAssertions

A BooleanAssertions for the value.

Should(String) ​

Begins a fluent assertion on the specified string value.

c#
public static StringAssertions Should(this string? value);

View source

Parameters ​

NameTypeDescription
valueStringThe string value to assert on.

Returns ​

StringAssertions

A StringAssertions for the value.

Should(Exception) ​

Begins a fluent assertion on the specified exception.

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

View source

Parameters ​

NameTypeDescription
valueExceptionThe exception to assert on.

Returns ​

ExceptionAssertions<Exception>

An ExceptionAssertions<T> for the exception.

Should(ArgumentException) ​

Begins a fluent assertion on the specified ArgumentException.

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

View source

Parameters ​

NameTypeDescription
valueArgumentExceptionThe exception to assert on.

Returns ​

ExceptionAssertions<ArgumentException>

An ExceptionAssertions<T> for the exception.

Should(ArgumentOutOfRangeException) ​

Begins a fluent assertion on the specified ArgumentOutOfRangeException.

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

View source

Parameters ​

NameTypeDescription
valueArgumentOutOfRangeExceptionThe 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.

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

View source

Type Parameters ​

NameDescription
TThe type of elements in the enumerable.

Parameters ​

NameTypeDescription
valueIEnumerable<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.

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

View source

Type Parameters ​

NameDescription
TKeyThe type of the dictionary keys.
TValueThe type of the dictionary values.

Parameters ​

NameTypeDescription
valueIReadOnlyDictionary<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.

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

View source

Type Parameters ​

NameDescription
TKeyThe type of the dictionary keys.
TValueThe type of the dictionary values.

Parameters ​

NameTypeDescription
valueDictionary<TKey, TValue>The dictionary to assert on.

Returns ​

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

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

Should<T>(IReadOnlySet<T>) ​

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

c#
public static ReadOnlySetAssertions<IReadOnlySet<T>, T> Should<T>(this IReadOnlySet<T> value);

View source

Type Parameters ​

NameDescription
TThe type of elements in the set.

Parameters ​

NameTypeDescription
valueIReadOnlySet<T>The set to assert on.

Returns ​

ReadOnlySetAssertions<IReadOnlySet<T>, T>

A ReadOnlySetAssertions<TSet, T> for the set.

Should<T>(HashSet<T>) ​

Begins a fluent assertion on the specified hash set.

c#
public static ReadOnlySetAssertions<HashSet<T>, T> Should<T>(this HashSet<T> value);

View source

Type Parameters ​

NameDescription
TThe type of elements in the set.

Parameters ​

NameTypeDescription
valueHashSet<T>The set to assert on.

Returns ​

ReadOnlySetAssertions<HashSet<T>, T>

A ReadOnlySetAssertions<TSet, T> for the set.

Should<T>(Span<T>) ​

Begins a fluent assertion on the specified span.

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

View source

Type Parameters ​

NameDescription
TThe type of elements in the span.

Parameters ​

NameTypeDescription
valueSpan<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.

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

View source

Type Parameters ​

NameDescription
TThe type of elements in the span.

Parameters ​

NameTypeDescription
valueReadOnlySpan<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.

c#
public static ActionAssertions Should(this Action value);

View source

Parameters ​

NameTypeDescription
valueActionThe action to assert on.

Returns ​

ActionAssertions

An ActionAssertions for the action.

Should(Func<Task>) ​

Begins a fluent assertion on the specified async action.

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

View source

Parameters ​

NameTypeDescription
valueFunc<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.

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

View source

Parameters ​

NameTypeDescription
valueByteThe 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.

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

View source

Parameters ​

NameTypeDescription
valueSByteThe 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.

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

View source

Parameters ​

NameTypeDescription
valueInt16The 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.

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

View source

Parameters ​

NameTypeDescription
valueUInt16The 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.

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

View source

Parameters ​

NameTypeDescription
valueInt32The 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.

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

View source

Parameters ​

NameTypeDescription
valueUInt32The 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.

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

View source

Parameters ​

NameTypeDescription
valueInt64The 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.

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

View source

Parameters ​

NameTypeDescription
valueUInt64The 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.

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

View source

Parameters ​

NameTypeDescription
valueIntPtrThe 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.

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

View source

Parameters ​

NameTypeDescription
valueUIntPtrThe 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.

c#
public static DecimalAssertions Should(this decimal value);

View source

Parameters ​

NameTypeDescription
valueDecimalThe decimal value to assert on.

Returns ​

DecimalAssertions

A DecimalAssertions for the value.

Should(TimeSpan) ​

Begins a fluent assertion on the specified TimeSpan value.

c#
public static TimeSpanAssertions Should(this TimeSpan value);

View source

Parameters ​

NameTypeDescription
valueTimeSpanThe TimeSpan value to assert on.

Returns ​

TimeSpanAssertions

A TimeSpanAssertions for the value.

Should(DateTimeOffset) ​

Begins a fluent assertion on the specified DateTimeOffset value.

c#
public static DateTimeOffsetAssertions Should(this DateTimeOffset value);

View source

Parameters ​

NameTypeDescription
valueDateTimeOffsetThe DateTimeOffset value to assert on.

Returns ​

DateTimeOffsetAssertions

A DateTimeOffsetAssertions for the value.

Should(DateOnly) ​

Begins a fluent assertion on the specified DateOnly value.

c#
public static DateOnlyAssertions Should(this DateOnly value);

View source

Parameters ​

NameTypeDescription
valueDateOnlyThe DateOnly value to assert on.

Returns ​

DateOnlyAssertions

A DateOnlyAssertions for the value.

Should(Single) ​

Begins a fluent assertion on the specified float value.

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

View source

Parameters ​

NameTypeDescription
valueSingleThe 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.

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

View source

Parameters ​

NameTypeDescription
valueDoubleThe 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.

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

View source

Parameters ​

NameTypeDescription
valueHalfThe Half value to assert on.

Returns ​

FloatingPointAssertions<Half>

A FloatingPointAssertions<T> for the value.