IsNull(TValue) Method

Moq

Collapse image Expand Image Copy image CopyHover image
Matches a null value of the given TValue type.

Namespace: Moq.Protected
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public static Expression IsNull<TValue>()

Type Parameters

TValue
Type of the value.

Remarks

Required for protected mocks as the null value cannot be used directly as it prevents proper method overload selection.

Examples

CopyC#
// Throws an exception for a call to Remove with a null string value.
mock.Protected()
    .Setup("Remove", ItExpr.IsNull<string>())
    .Throws(new InvalidOperationException());

See Also