repeat
Class: matlab.mock.actions.AssignOutputs
Namespace: matlab.mock.actions
Repeat defining return values
Syntax
repeat(action,n)
Description
Input Arguments
Examples
Tips
If you repeat an action, and do not follow it with a call to the
then
method, the mock continues to return the repeated value. For example, consider the following mock of a bank account class.import matlab.mock.actions.AssignOutputs testCase = matlab.mock.TestCase.forInteractiveUse; [mock,behavior] = testCase.createMock('AddedProperties',"IsJointAccount");
If you repeat an action to return a property value of
true
twice, the following code, which goes on to get the property value a third and fourth time, returnstrue
all four times.when(get(behavior.IsJointAccount),AssignOutputs(true).repeat(2)) for i = 1:4 tf = mock.IsJointAccount end
But the following code returns
true
twice andfalse
twice.when(get(behavior.IsJointAccount), ... AssignOutputs(true).repeat(2).then(AssignOutputs(false))) for i = 1:4 tf = mock.IsJointAccount end
Version History
Introduced in R2017a