







Matches any value that satisfies the given predicate.
Namespace:
Moq.Protected
Assembly:
Moq (in Moq.dll) Version: 2.6.1014.1 (2.6.0.0)
Syntax
C# |
---|
public static Expression Is<TValue>( Expression<Predicate<TValue>> match ) |
Parameters
- match
- Type: Expression<(Of <(Predicate<(Of <(TValue>)>)>)>)
The predicate used to match the method argument.
Type Parameters
- TValue
- Type of the argument to check.
Remarks
Allows the specification of a predicate to perform matching
of method call arguments.
Examples
This example shows how to return the value 1 whenever the argument to the
Do method is an even number.
CopyC#
This example shows how to throw an exception if the argument to the
method is a negative number:
CopyC#

mock.Protected() .Expect("Do", ItExpr.Is<int>(i => i % 2 == 0)) .Returns(1);

mock.Protected() .Expect("GetUser", ItExpr.Is<int>(i => i < 0)) .Throws(new ArgumentException());