Specifies a setup on the mocked type for a call to to a property getter.

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

Syntax

C#
public ISetupGetter<T, TProperty> SetupGet<TProperty>(
	Expression<Func<T, TProperty>> expression
)

Parameters

expression
Type: Expression<(Of <(Func<(Of <(T, TProperty>)>)>)>)
Lambda expression that specifies the property getter.

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 getter, the latest one wins and is the one that will be executed.

Examples

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

See Also