







![]() |
Moq |
IMock<(Of <(T>)>)..::.Verify<(Of <(TResult>)>) Method (<(Of <(<(Of <(T, TResult>)>)>)>)) |
IMock<(Of <(T>)>) Interface Example See Also Send Feedback |
Verifies that a specific invocation matching the given
expression was performed on the mock. Use in conjuntion
with the default Loose.
Namespace:
Moq
Assembly:
Moq (in Moq.dll) Version: 2.6.1014.1 (2.6.0.0)
Syntax
C# |
---|
void Verify<TResult>( Expression<Func<T, TResult>> expression ) |
Parameters
- expression
- Type: Expression<(Of <(Func<(Of <(T, TResult>)>)>)>)
Expression to verify.
Type Parameters
- TResult
- Type of return value from the expression.
Examples
This example assumes that the mock has been used,
and later we want to verify that a given invocation
with specific parameters was performed:
CopyC#

var mock = new Mock<IWarehouse>(); // exercise mock //... // Will throw if the test code didn't call HasInventory. mock.Verify(warehouse => warehouse.HasInventory(TALISKER, 50));
Exceptions
Exception | Condition |
---|---|
Moq..::.MockException | The invocation was not performed on the mock. |