%% Specify Mock Property Access Behavior
% Create a mock for a person class.  The mock has one property, Name.

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

% Set up the behavior.  When the property is accessed, return the value "David".

import matlab.mock.actions.AssignOutputs
when(get(behavior.Name),AssignOutputs("David"))

% Access the property.

name = mock.Name

% Copyright 2012 The MathWorks, Inc.