returnStoredValueWhen
Class: matlab.mock.TestCase
Namespace: matlab.mock
Return stored value when property is accessed
Syntax
returnStoredValueWhen(testcase,behavior)
Description
returnStoredValueWhen(
specifies
that the mock returns the stored property value when a property is
accessed. If the mock is strict and the property is an abstract property
of the mock interface, the framework produces an assertion failure
when it accesses a property. To enable access to the property in a
strict mock, use the testcase
,behavior
)returnStoredValueWhen
method.
Input Arguments
Examples
Alternatives
Using the returnStoredValueWhen
method is functionally
equivalent to using the matlab.mock.actions.ReturnStoredValue
action
with the when
method of the PropertyGetBehavior
class.
For example, the following code blocks are functionally equivalent.
% Using the returnStoredValueWhen method testCase.returnStoredValueWhen(get(behavior.PropertyFoo)); % Using the ReturnStoredValue action with the when function import matlab.mock.actions.ReturnStoredValue; when(get(behavior.PropertyFoo),ReturnStoredValue);
ReturnStoredValue
action.
For instance, you can specify different subsequent behavior for the
same mocked object interaction.Version History
Introduced in R2017a