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
속성이 두 번 설정되도록 한 후 예외를 발생시킵니다.
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 명령 창에 입력하십시오. 웹 브라우저는 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)