-
Notifications
You must be signed in to change notification settings - Fork 3
Expectation
Mark Abbott edited this page Apr 13, 2015
·
5 revisions
The Expectation class is used to set Expectations on Mock objects.
An expectation is a requirement for a method, procedure or function of a Mocked object to be called a given number of times, or within a range of values. If the number of times a method, procedure or function is called does not match the expectation, an assertion is raised and trapped by the OEUnit test framework.
Note that all conditions on the expectation are treated as 'AND' conditions, and all properties must be satisfied before the expectation can be met.
Do not create Expectation objects manually. Create them using the Expected
method on a Mock object.
-
VOID
CalledAtLeast(INPUT numCalls AS INTEGER) - This method validates the number of times the method, function or procedure is called is more than or equal the value of the numCalls parameter.
- Parameter: numCalls (INTEGER) - The number of times the call count should be validated against.
-
VOID
CalledAtMost(INPUT numCalls AS INTEGER) - This method validates the number of times the method, function or procedure is called is less than or equal to the value of the numCalls parameter.
- Parameter: numCalls (INTEGER) - The number of times the call count should be validated against.
-
VOID
CalledAtExactly(INPUT numCalls AS INTEGER) - This method validates the number of times the method, function or procedure is called is exactly the value of the numCalls parameter.
- Parameter: numCalls (INTEGER) - The number of times the call count should be validated against.
-
VOID
CalledOnlyOnce() - This method validates the number of times the method, function or procedure is is called is exactly once.
-
VOID
NeverCalled() - This method validates that the method, function or procedure is never called.
-
VOID
WithParameterValue(INPUT ParamName AS CHARACTER, INPUT ParamValue AS CHARACTER, INPUT Equal AS LOGICAL) - This method specifies a method, function or procedure parameter value that should, or should not (dependent on the Equal parameter), be encountered for calls to the method, function or procedure to be counted towards the overall expectation.
- Parameter: ParamName (CHARACTER) - The name of the parameter to specify the value for. If a value for the parameter has already been specified, the value will be overwritten.
- Parameter: ParamValue (CHARACTER) - The value of the parameter which should, or should not, be encountered.
- Parameter: Equal (LOGICAL) - When
TRUE
, indicates that the value of the parameter should match the value specified in ParamValue in order for it to be counted. When notTRUE
, indicates that the value of the parameter should not match the value specified in ParamValue in order for it to be counted. -
VOID
WithParameterValue(INPUT ParamName AS CHARACTER, INPUT ParamValue AS CHARACTER) - This method specifies a method, function or procedure parameter value that should be encountered for calls to the method, function or procedure to be counted towards the overall expectation.
- Parameter: ParamName (CHARACTER) - The name of the parameter to specify the value for. If a value for the parameter has already been specified, the value will be overwritten.
- Parameter: ParamValue (CHARACTER) - The value of the parameter which should be encountered.
-
VOID
WithParameterValueNot(INPUT ParamName AS CHARACTER, INPUT ParamValue AS CHARACTER) - This method specifies a method, function or procedure parameter value that should not be encountered for calls to the method, function or procedure to be counted towards the overall expectation.
- Parameter: ParamName (CHARACTER) - The name of the parameter to specify the value for. If a value for the parameter has already been specified, the value will be overwritten.
- Parameter: ParamValue (CHARACTER) - The value of the parameter which should not be encountered.