Class: matlab.mock.TestCase
Package: matlab.mock
Define return values for method call or property access
assignOutputsWhen(testcase,behavior,A1,...,An)
assignOutputsWhen(
defines
values to return for a method called or property accessed.testcase
,behavior
,A1,...,An
)
Using the assignOutputsWhen
method is functionally
equivalent to using the matlab.mock.actions.AssignOutputs
action
with the when
method of the MethodCallBehavior
or PropertyGetBehavior
class.
For example, the following code blocks are functionally equivalent.
% Using the assignOutputsWhen method testCase.assignOutputsWhen(get(behavior.PropertyFoo),'abc'); testCase.assignOutputsWhen(withExactInputs(behavior.methodBar),1,2,3); % Using the AssignOutputs action with the when function import matlab.mock.actions.AssignOutputs; when(get(behavior.PropertyFoo),AssignOutputs('abc')); when(withExactInputs(behavior.methodBar),AssignOutputs(1,2,3));
AssignOutputs
action.
For instance, you can specify different subsequent behavior for the
same mocked object interaction.