SetupSet(TProperty) Method (Action(T))

Moq

Collapse image Expand Image Copy image CopyHover image
Specifies a setup on the mocked type for a call to to a property setter.

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

Syntax

C#
public ISetupSetter<T, TProperty> SetupSet<TProperty>(
	Action<T> setterExpression
)

Parameters

setterExpression
Type: System..::..Action<(Of <(<'T>)>)>
The Lambda expression that sets a property to a value.

Type Parameters

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.

This overloads allows the use of a callback already typed for the property type.

Examples

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

See Also