Returns Method (TResult)

Moq

Collapse image Expand Image Copy image CopyHover image
Specifies the value to return.

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

Syntax

C#
IReturnsResult<TMock> Returns(
	TResult value
)

Parameters

value
Type: TResult
The value to return, or nullNothingnullptra null reference (Nothing in Visual Basic).

Examples

Return a true value from the method call:
CopyC#
mock.Setup(x => x.Execute("ping"))
    .Returns(true);

See Also