repeat
クラス: matlab.mock.actions.StoreValue
名前空間: matlab.mock.actions
プロパティ値の格納の繰り返し
構文
repeat(action,n)
説明
repeat(
は同じアクションを action
,n
)n
回繰り返します。入力引数を任意の順序で指定できます。つまり、repeat(action,n)
および repeat(n,action)
はどちらもアクションを n
回繰り返します。
入力引数
action
— 定義済みのアクション
matlab.mock.actions.StoreValue
のインスタンス
定義済みのアクション。matlab.mock.actions.StoreValue
のインスタンスとして指定します。
n
— アクションを繰り返す回数
整数
アクションを繰り返す回数。整数として指定します。
例: 5
例
プロパティ値の格納の繰り返し
銀行口座クラスのモックを作成します。
testCase = matlab.mock.TestCase.forInteractiveUse; [mock,behavior] = testCase.createMock('AddedProperties',"IsOpen");
動作を指定します。IsOpen
プロパティを 2 回設定できるようにし、例外をスローします。
import matlab.mock.actions.StoreValue import matlab.mock.actions.ThrowException when(set(behavior.IsOpen),StoreValue().repeat(2).then(ThrowException( ... MException('Account:setValue:tooMany','Value set too many times.'))))
モックを使用します。
for i = 1:3 mock.IsOpen = i end
mock =
Mock with properties:
IsOpen: 1
mock =
Mock with properties:
IsOpen: 2
Error using matlab.mock.internal.MockContext/createMockObject/mockPropertySetCallback (line 429)
Value set too many times.
バージョン履歴
R2017a で導入
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)