%% Repeat Taking No Action
% 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.

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

% Copyright 2019 The MathWorks, Inc.