Class: matlab.mock.actions.DoNothing Package: matlab.mock.actions
Repeat taking no action
repeat(action,n)
example
repeat(action,n) repeats the same action n times. You can specify the input arguments in any order. That is, repeat(action,n) and repeat(n,action) both repeat the action n times.
action
n
repeat(n,action)
expand all
matlab.mock.actions.DoNothing
Defined action, specified as a matlab.mock.actions.DoNothing object.
Example: action = DoNothing
action = DoNothing
Number of times to repeat the action, specified as an integer.
Example: 5
5
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), ... DoNothing().repeat(2).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?