Verifies that a property was read on the mock, specifying a failure
error message.
Namespace:
MoqAssembly: Moq (in Moq.dll) Version: 4.0.812.4 (4.0.0.0)
Syntax
| C# |
|---|
public void VerifyGet<TProperty>( Expression<Func<T, TProperty>> expression, string failMessage ) |
Parameters
- expression
- Type: Expression<(Of <(Func<(Of <(T, TProperty>)>)>)>)
Expression to verify.
- failMessage
- Type: String
Message to show if verification fails.
Type Parameters
- TProperty
- Type of the property to verify. Typically omitted as it can be inferred from the expression's return type.
Examples
This example assumes that the mock has been used,
and later we want to verify that a given property
was retrieved from it:
CopyC#
var mock = new Mock<IWarehouse>(); // exercise mock //... // Will throw if the test code didn't retrieve the IsClosed property. mock.VerifyGet(warehouse => warehouse.IsClosed);
Exceptions
| Exception | Condition |
|---|---|
| Moq..::.MockException | The invocation was not performed on the mock. |