%% Define Behavior with PropertyGetBehavior Object
% Create a mock for a person class with a Name property.

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

% Create a PropertyGetBehavior and set up the behavior. The mock returns "David" when you get the value of the Name property.

getBehavior = get(behavior.Name);
testCase.assignOutputsWhen(getBehavior,"David")

% Alternatively, you can create the PropertyGetBehavior object implicitly with the behavior definition.

testCase.assignOutputsWhen(get(behavior.Name),"David")

% Access the Name property.

name = mock.Name

% Copyright 2012 The MathWorks, Inc.