Class: matlab.mock.actions.DoNothing Package: matlab.mock.actions
Repeat taking no action
repeat(n,action)
example
repeat(n,action) repeats the same action n times.
n
action
expand all
Number of times to repeat the action, specified as an integer.
Example: 5
matlab.mock.actions.DoNothing
Defined action, specified as a matlab.mock.actions.DoNothing object.
Example: DoNothing
DoNothing
Create a mock for a bank account class.
testCase = matlab.mock.TestCase.forInteractiveUse; [mock,behavior] = testCase.createMock('AddedProperties',"Deposit");
Specify behavior. Use repeat for two repetitions of no action, and then allow the Deposit property to be set in the third attempt.
repeat
Deposit
import matlab.mock.actions.DoNothing import matlab.mock.actions.StoreValue when(set(behavior.Deposit),then(repeat(2,DoNothing),then(StoreValue)))
Use the mock.
for i = 1:3 mock.Deposit = 100 end
mock = Mock with properties: Deposit: []
mock = Mock with properties: Deposit: 100
You have a modified version of this example. Do you want to open this example with your edits?