classdef MyClass properties (GetAccess=public, SetAccess=protected) prop1; end methods function this = answer() end end end
this is the mock decleration:
testCase = matlab.mock.TestCase.forInteractiveUse; [mock,behav] = testCase.createMock(?MyClass); % this would obciously throw an exception because the property set method is protected mock.prop1 = ""; You cannot set the read-only property 'prop1' of MyClassMock. % this throws an exception because the behavior object doesn't have this property p = behav.prop1; No appropriate method, property, or field 'prop1' for class 'matlab.mock.classes.MyClassBehavior'.
testCase = matlab.mock.TestCase.forInteractiveUse; [MyClassMock, behaviour] = createMock(testCase, 'AddedProperties', "prop1", 'AddedMethods', "answer") testCase.assignOutputsWhen(get(behaviour.prop1), 'abc') p = MyClassMock.prop1
It's not ideal but I don't think there's any other option at this time. You can still test for access violations this way:
import matlab.mock.actions.ThrowException when(set(behaviour.prop1),... ThrowException(MException('MATLAB:class:SetProhibited',... 'You cannot set the read-only property ''prop1'' of MyClass.')))
Creating a mock from a meta-class only works for classes with abstract properties and methods.
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.