Hello,
How can I restrict the number of times a call of a specific Spring Mock is executed?
I have the following code:
MyOutMockObject := TMyOutMockObject.Create;
// adding MyOutMockObject some test data
FSpringMockCheckOrder.Setup.Executes(
function(const call: TCallInfo): TValue
begin
result := TValue.From<boolean>(TRUE);
call[8] := MyOutMockObject;
end).When.CheckOrder(MyOutMockObject);
MyOutMockObject2 := TMyOutMockObject.Create;
// adding MyOutMockObject2 different test data
FSpringMockCheckOrder.Setup.Executes(
function(const call: TCallInfo): TValue
begin
result := TValue.From<boolean>(TRUE);
call[8] := MyOutMockObject2;
end).When.CheckOrder(MyOutMockObject2);
At this stage, I inject FSpringMockCheckOrder in the class I want to test but the data I defined in MyOutMockObject2 is never returned, no matter how many times I call CheckOrder. The data defined in MyOutMockObject is returned all the time.
In other words, how can I limit the number of executions of a certain mock instance?
Something like:
FSpringMockCheckOrder.Setup.Executes(
function(const call: TCallInfo): TValue
begin
result := TValue.From<boolean>(TRUE);
call[8] := MyOutMockObject;
end).
(Times.Exactly(x)).When.CheckOrder(MyOutMockObject);
Many thanks
Alberto