Specifies a setup on the mocked type for a call to to a property setter, regardless of its value.

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

Syntax

C#
public static ISetupSetter<T, TProperty> SetupSet<T, TProperty>(
	Mock<T> mock,
	Expression<Func<T, TProperty>> expression
)
where T : class

Parameters

mock
Type: Moq..::.Mock<(Of <(T>)>)
The target mock for the setup.
expression
Type: Expression<(Of <(Func<(Of <(T, TProperty>)>)>)>)
Lambda expression that specifies the property setter.

Type Parameters

T
Type of the mock.
TProperty
Type of the property. Typically omitted as it can be inferred from the expression.

Remarks

If more than one setup is set for the same property setter, the latest one wins and is the one that will be executed.

Examples

CopyC#
mock.SetupSet(x => x.Suspended);

See Also