Class org.as2lib.test.mock.support.DefaultMethodBehavior

org.as2lib.core.BasicClass
   +--org.as2lib.test.mock.support.DefaultMethodBehavior

Implemented Interfaces

MethodBehavior

Description

DefaultMethodBehavior stores the expected and actual behaviors of one method and verifies the expectation against the actual method calls.

Method Index

new DefaultMethodBehavior()

addActualMethodCall(), addMethodResponse(), expectsAnotherMethodCall(), getExpectedMethodCall(), response(), setArgumentsMatcher(), verify()

Inherited from BasicClass

toString()

Constructor Detail

DefaultMethodBehavior

public function DefaultMethodBehavior(expectedMethodCall:MethodCall)

Constructs a new DefaultMethodBehavior instance with the passed-in methodCall.

A expectedMethodCall of value null means that this behavior expects no actual method calls.

Parameters

expectedMethodCallthe expected method call this behavior registers expectations, actual calls and responses for

Method Detail

getExpectedMethodCall

public function getExpectedMethodCall(Void):MethodCall

Returns the expected method call.

Return

the expected method call

Specified By

getExpectedMethodCall() in org.as2lib.test.mock.MethodBehavior

addActualMethodCall

public function addActualMethodCall(actualMethodCall:MethodCall):Void

Adds an actual method call.

The method call is added if it is not null and if it matches the expected method call.

Parameters

actualMethodCallthe new actual method call to add

Throws

IllegalArgumentExceptionif the passed-in methodCall is null
AssertionFailedErrorif no method call was expected or if the actualMethodCall does not match the expected method call or if the total maximum call count has been exceeded

Specified By

addActualMethodCall() in org.as2lib.test.mock.MethodBehavior

addMethodResponse

public function addMethodResponse(methodResponse:MethodResponse, methodCallRange:MethodCallRange):Void

Adds the new methodResponse together with the methodCallRange that indicates when and how often the response shall take place.

If you set no response, the behavior expects exactly one method call.

Parameters

methodResponsethe response to do a given number of times
methodCallRangethe range that indicates how often the response can take place

Throws

IllegalStateExceptionif the expected method call is null

Specified By

addMethodResponse() in org.as2lib.test.mock.MethodBehavior

setArgumentsMatcher

public function setArgumentsMatcher(argumentsMatcher:ArgumentsMatcher):Void

Sets the passed-in argumentsMatcher for the expected method call.

Parameters

argumentsMatcherthe arguments matcher for the expected method call

Specified By

setArgumentsMatcher() in org.as2lib.test.mock.MethodBehavior

expectsAnotherMethodCall

public function expectsAnotherMethodCall(Void):Boolean

Checks whether this behavior expects another method call.

Return

true if a further method call is expected else false

Specified By

expectsAnotherMethodCall() in org.as2lib.test.mock.MethodBehavior

response

public function response(Void)

Responses depending on the current number of actual method calls.

Return

the response's return value

Specified By

response() in org.as2lib.test.mock.MethodBehavior

verify

public function verify(Void):Void

Verifies that the expactations have been met.

Throws

AssertionFailedErrorif the verification fails

Specified By

verify() in org.as2lib.test.mock.MethodBehavior