%% Assign Repeating Outputs to Mock
% Create a mock for a bank account class.

testCase = matlab.mock.TestCase.forInteractiveUse;
[mock,behavior] = testCase.createMock('AddedMethods',"isOpen");

% Specify behavior.

import matlab.mock.actions.AssignOutputs
when(withExactInputs(behavior.isOpen), ...
    AssignOutputs(true).repeat(2).then(AssignOutputs(false)))

% Use the mock.

for i = 1:3
    isAccountOpen = mock.isOpen
end

% Copyright 2012 The MathWorks, Inc.