%% Repeat Return of Stored Property Value
% Create a strict mock for a bank account class.

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

% Specify behavior. Return the stored property value, which is empty by default, twice and then assign an output of false.

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

% Use the mock.

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

% Copyright 2012 The MathWorks, Inc.