get
クラス: matlab.mock.PropertyBehavior
名前空間: matlab.mock
モック プロパティの get 動作を定義するためのオブジェクトの作成
構文
getBehavior = get(behavior)
説明
getBehavior = get(
は、モック プロパティの get 動作を定義するための behavior
)PropertyGetBehavior
オブジェクトを作成します。通常は、モックの動作の定義時に、get
メソッドを使用して PropertyGetBehavior
を暗黙的に作成します。
入力引数
behavior
— モックの動作
matlab.mock.PropertyBehavior
インスタンス
モックの動作。matlab.mock.PropertyBehavior
インスタンスとして指定します。matlab.mock.PropertyBehavior
のインスタンスを作成するには、behavior オブジェクトのプロパティにアクセスします。
例: myMockBehavior.MyProperty
例
PropertyGetBehavior
オブジェクトを使用して動作を定義
Name
プロパティを使用して個人クラスのモックを作成します。
testCase = matlab.mock.TestCase.forInteractiveUse; [mock,behavior] = testCase.createMock('AddedProperties',"Name");
PropertyGetBehavior
を作成して、動作を設定します。Name
プロパティの値を取得すると、モックは "David"
を返します。
getBehavior = get(behavior.Name);
testCase.assignOutputsWhen(getBehavior,"David")
また、動作の定義を使用して PropertyGetBehavior
オブジェクトを暗黙的に作成することもできます。
testCase.assignOutputsWhen(get(behavior.Name),"David")
Name
プロパティにアクセスします。
name = mock.Name
name = "David"
バージョン履歴
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)