Main Content
storeValueWhen
Class: matlab.mock.TestCase
Namespace: matlab.mock
Store value when property is set
Syntax
storeValueWhen(testcase,behavior)
Description
storeValueWhen(
specifies
that the mock should store the property value when a property is set.
If the mock is strict and the property is an abstract property of
the mock interface, the framework produces an assertion failure at
property set access. To enable the property to be set in a strict
mock, use the testcase
,behavior
)storeValueWhen
method.
Input Arguments
Examples
Alternatives
Using the storeValueWhen
method is functionally
equivalent to using the matlab.mock.actions.StoreValue
action
with the when
method of the PropertySetBehavior
class.
For example, the following code blocks are functionally equivalent.
% Using the storeValueWhen method testCase.storeValueWhen(set(behavior.PropertyFoo)); % Using the StoreValue action with the when function import matlab.mock.actions.StoreValue; when(set(behavior.PropertyFoo),StoreValue);
StoreValue
action.
For instance, you can specify different subsequent behavior for the
same mocked object interaction.Version History
Introduced in R2017a