Verifies that a property was set on the mock, specifying
a failure message.
Namespace:
MoqAssembly: Moq (in Moq.dll) Version: 4.0.812.4 (4.0.0.0)
Syntax
| C# |
|---|
public void VerifySet( Action<T> setterExpression, string failMessage ) |
Parameters
- setterExpression
- Type: Action<(Of <(T>)>)
Expression to verify.
- failMessage
- Type: String
Message to show if verification fails.
Examples
This example assumes that the mock has been used,
and later we want to verify that a given property
was set on it:
CopyC#
var mock = new Mock<IWarehouse>(); // exercise mock //... // Will throw if the test code didn't set the IsClosed property. mock.VerifySet(warehouse => warehouse.IsClosed = true, "Warehouse should always be closed after the action");
Exceptions
| Exception | Condition |
|---|---|
| Moq..::.MockException | The invocation was not performed on the mock. |