ExpectSet(TProperty) Method (((T, TProperty)), TProperty)

Moq 2.6

Sets an expectation on the mocked type for a call to to a property setter with a specific value.

Namespace:  Moq
Assembly:  Moq (in Moq.dll) Version: 2.6.1014.1 (2.6.0.0)

Syntax

C#
IExpectSetter<TProperty> ExpectSet<TProperty>(
	Expression<Func<T, TProperty>> expression,
	TProperty value
)

Parameters

expression
Type: Expression<(Of <(Func<(Of <(T, TProperty>)>)>)>)
Lambda expression that specifies the expected property setter.
value
Type: TProperty
The value expected to be set for the property.

Type Parameters

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

Remarks

More than one expectation can be set for the setter with different values.

Examples

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

See Also