|
|
@ -177,17 +177,28 @@ public class PlayerTest { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void checkChooseMethod() { |
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
|
@MethodSource("checkChooseMethodData") |
|
|
|
void checkChoose(String testName, String input, int expectedResult) { |
|
|
|
InputStream stdin = System.in; |
|
|
|
System.setIn(new ByteArrayInputStream("0\n".getBytes())); |
|
|
|
System.setIn(new ByteArrayInputStream(input.getBytes())); |
|
|
|
|
|
|
|
int calculatedResult = p.choose(); |
|
|
|
|
|
|
|
System.setIn(stdin); |
|
|
|
assertThat(calculatedResult).describedAs(testName).isEqualTo(expectedResult); |
|
|
|
} |
|
|
|
|
|
|
|
int expectedResult = 0; |
|
|
|
assertThat(calculatedResult).describedAs("Choose one Figure").isEqualTo(expectedResult); |
|
|
|
static Stream<Arguments> checkChooseMethodData() { |
|
|
|
return Stream.of( |
|
|
|
Arguments.of("Figure 1 choosen", "1\n", 1), |
|
|
|
Arguments.of("Figure 2 choosen", "2\n", 2), |
|
|
|
Arguments.of("Figure 3 choosen", "3\n", 3), |
|
|
|
Arguments.of("Figure 4 choosen", "4\n", 4), |
|
|
|
Arguments.of("Index out of bounds choosen", "16\n", -1), |
|
|
|
Arguments.of("Index out of bounds choosen", "-2\n", -1), |
|
|
|
Arguments.of("Input a letter or char", "g\n", -1), |
|
|
|
Arguments.of("Input a empty string", "\n", -1), |
|
|
|
Arguments.of("Input a special character", "&\n", -1) |
|
|
|
); |
|
|
|
} |
|
|
|
} |