IMethodOptions

Allows to define what would happen when a method is called.

Summary
Allows to define what would happen when a method is called.
Sets the return value when the method is called.
Throws the specified exception when the method is called.
Ignores the arguments for this method.
Allows to get the <Interfaces.IRepeat> instance that would allow to set the expected number of times that this method will occur.
Sets the contraints on this method parameters.
Sets a callback delegate to be called when this method is called.
Set an action to run when the expectation is matched.
Call the original method on the class, bypassing the mocking layers.
Call the original method on the class, optionally bypassing the mocking layers.
Use the property as a normal property, so you can use it to save/load values without having to specify expectations for it.

Functions and Properties

Return

IMethodOptions Return(object objToReturn)

Sets the return value when the method is called.

Throw

IMethodOptions Throw(Exception exception)

Throws the specified exception when the method is called.

IgnoreArguments

IMethodOptions IgnoreArguments()

Ignores the arguments for this method.  Any arguments are considered fine for this method.

Repeat

IRepeat Repeat { get }

Allows to get the <Interfaces.IRepeat> instance that would allow to set the expected number of times that this method will occur.

Constraints

IMethodOptions Constraints(params AbstractConstraint[] constraints)

Sets the contraints on this method parameters.  The number of the constraints must be equal to the number of method arguments.

Callback

IMethodOptions Callback(Delegate callback)

Sets a callback delegate to be called when this method is called.

Important

The callback must have the same signature as the last method call but its return value must be a boolean.  The callback will be called with the same parameters as the method and the method will be accepted if the delegate return a positive value.  Note: The callback may be called several times

Do

IMethodOptions Do(Delegate action)

Set an action to run when the expectation is matched.

Important

The action’s delegate must have the same signature as the last methdo call, and its return value must be assignable to the last method call return value.

Note

This method is only called once, after the method call was match to the expectation.

CallOriginalMethod

void CallOriginalMethod()

Call the original method on the class, bypassing the mocking layers.

Important

Can only be used on a method that has an implementation.  If you try that on an interface method or an abstract method, you’ll get an exception.

CallOriginalMethod

IMethodOptions CallOriginalMethod(OriginalCallOptions options)

Call the original method on the class, optionally bypassing the mocking layers.

Important

Can only be used on a method that has an implementation.  If you try that on an interface method or an abstract method, you’ll get an exception.

PropertyBehavior

IMethodOptions PropertyBehavior()

Use the property as a normal property, so you can use it to save/load values without having to specify expectations for it.

Note

This can be called only when the last call is a getter or setter.

GetEventRaiser

IEventRaiser GetEventRaiser()

OutRef

IMethodOptions OutRef(params object[] parameters)

Message

IMethodOptions Message(string documentationMessage)
IMethodOptions Return(object objToReturn)
Sets the return value when the method is called.
IMethodOptions Throw(Exception exception)
Throws the specified exception when the method is called.
IMethodOptions IgnoreArguments()
Ignores the arguments for this method.
IRepeat Repeat { get }
Allows to get the Interfaces.IRepeat instance that would allow to set the expected number of times that this method will occur.
IMethodOptions Constraints(params AbstractConstraint[] constraints)
Sets the contraints on this method parameters.
IMethodOptions Callback(Delegate callback)
Sets a callback delegate to be called when this method is called.
IMethodOptions Do(Delegate action)
Set an action to run when the expectation is matched.
void CallOriginalMethod()
Call the original method on the class, bypassing the mocking layers.
IMethodOptions PropertyBehavior()
Use the property as a normal property, so you can use it to save/load values without having to specify expectations for it.
IEventRaiser GetEventRaiser()
IMethodOptions OutRef(params object[] parameters)
IMethodOptions Message(string documentationMessage)