







![]() |
Moq |
IMock<(Of <(T>)>)..::.VerifySet<(Of <(TProperty>)>) Method (<(Of <(<(Of <(T, TProperty>)>)>)>), TProperty) |
IMock<(Of <(T>)>) Interface Example See Also Send Feedback |
Verifies that a property has been set on the mock to the given value.
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 VerifySet<TProperty>( Expression<Func<T, TProperty>> expression, TProperty value ) |
Parameters
- expression
- Type: Expression<(Of <(Func<(Of <(T, TProperty>)>)>)>)
Expression to verify.
- value
- Type: TProperty
The value that should have been set on the property.
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 invocation
with specific parameters was performed:
CopyC#

var mock = new Mock<IWarehouse>(); // exercise mock //... // Will throw if the test code didn't set the IsClosed property to true mock.VerifySet(warehouse => warehouse.IsClosed, true);
Exceptions
Exception | Condition |
---|---|
Moq..::.MockException | The invocation was not performed on the mock. |