|
1 | 1 | package chess.domain.command; |
2 | 2 |
|
3 | 3 | import org.junit.jupiter.api.DisplayName; |
| 4 | +import org.junit.jupiter.api.Test; |
4 | 5 | import org.junit.jupiter.params.ParameterizedTest; |
5 | 6 | import org.junit.jupiter.params.provider.CsvSource; |
6 | 7 | import org.junit.jupiter.params.provider.NullSource; |
| 8 | +import org.junit.jupiter.params.provider.ValueSource; |
7 | 9 |
|
8 | 10 | import static org.assertj.core.api.Assertions.assertThat; |
9 | 11 | import static org.assertj.core.api.Assertions.assertThatThrownBy; |
10 | 12 |
|
11 | 13 | class CommandOptionsTest { |
12 | 14 |
|
13 | 15 | @ParameterizedTest |
14 | | - @CsvSource(value = {"start, 0", "end, 0", "move b2 b3, 2", "status, 0"}) |
| 16 | + @CsvSource(value = {"start", "end", "move b2 b3", "status"}) |
15 | 17 | @DisplayName("옵션이 담긴 명령어를 반환한다.") |
16 | | - void of(String text, int expected) { |
| 18 | + void of(String text) { |
17 | 19 | //when |
18 | 20 | CommandOptions commandOptions = CommandOptions.of(text); |
19 | 21 |
|
20 | 22 | //then |
21 | | - assertThat(commandOptions.getOptions()).hasSize(expected); |
| 23 | + assertThat(commandOptions).isNotNull(); |
22 | 24 | } |
23 | 25 |
|
24 | 26 | @ParameterizedTest |
@@ -85,4 +87,29 @@ void isStatus(String text, boolean expected) { |
85 | 87 | //then |
86 | 88 | assertThat(actual).isEqualTo(expected); |
87 | 89 | } |
| 90 | + |
| 91 | + @Test |
| 92 | + @DisplayName("이동 명령 관련 옵션을 반환한다.") |
| 93 | + void getMoveOptions() { |
| 94 | + //given |
| 95 | + CommandOptions commandOptions = CommandOptions.of("move b2 b3"); |
| 96 | + |
| 97 | + //when |
| 98 | + MoveOptions moveOptions = commandOptions.getMoveOptions(); |
| 99 | + |
| 100 | + //then |
| 101 | + assertThat(moveOptions).isNotNull(); |
| 102 | + } |
| 103 | + |
| 104 | + @ParameterizedTest |
| 105 | + @ValueSource(strings = {"start", "end", "status"}) |
| 106 | + @DisplayName("이동 명령이 아닌 다른 명령이 이동 관련 옵션을 반환하려고 할 경우 예외가 발생한다.") |
| 107 | + void getMoveOptions_fail(String text) { |
| 108 | + //given |
| 109 | + CommandOptions commandOptions = CommandOptions.of(text); |
| 110 | + |
| 111 | + //when //then |
| 112 | + assertThatThrownBy(commandOptions::getMoveOptions) |
| 113 | + .isInstanceOf(IndexOutOfBoundsException.class); |
| 114 | + } |
88 | 115 | } |
0 commit comments