







![]() |
Moq |
IReturnsGetter<(Of <(TProperty>)>)..::.Returns Method (<(Of <(TProperty>)>)) |
IReturnsGetter<(Of <(TProperty>)>) Interface Example See Also Send Feedback |
Specifies a function that will calculate the value to return for the property.
Namespace:
Moq.Language
Assembly:
Moq (in Moq.dll) Version: 2.6.1014.1 (2.6.0.0)
Syntax
C# |
---|
IReturnsResult Returns( Func<TProperty> valueFunction ) |
Parameters
- valueFunction
- Type: Func<(Of <(TProperty>)>)
The function that will calculate the return value.
Examples
Return a calculated value when the property is retrieved:
CopyC#
The lambda expression to retrieve the return value is lazy-executed,
meaning that its value may change depending on the moment the property
is retrieved and the value the returnValues array has at
that moment.

mock.ExpectGet(x => x.Suspended)
.Returns(() => returnValues[0]);