VerifySet Method (Action(T))

Moq

Collapse image Expand Image Copy image CopyHover image
Verifies that a property was set on the mock.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
public void VerifySet(
	Action<T> setterExpression
)

Parameters

setterExpression
Type: System..::..Action<(Of <(<'T>)>)>
Expression to verify.

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);

Exceptions

Exception Condition
Moq..::..MockException The invocation was not performed on the mock.

See Also