|
|
@ -176,23 +176,25 @@ public class PlayerTest { |
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
|
@MethodSource("checkChooseMethodData") |
|
|
|
void checkChoose(String testName, String input, int expectedResult) { |
|
|
|
void checkChoose(String testName, String input,ArrayList<Integer> usableFiugres, int expectedResult) { |
|
|
|
System.setIn(new ByteArrayInputStream(input.getBytes())); |
|
|
|
int calculatedResult = p.choose(); |
|
|
|
int calculatedResult = p.choose(usableFiugres); |
|
|
|
assertThat(calculatedResult).describedAs(testName).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) |
|
|
|
Arguments.of("Figure 1 choosen", "1\n", new ArrayList<>(Arrays.asList(1,2,3,4)), 1), |
|
|
|
Arguments.of("Figure 2 choosen", "2\n", new ArrayList<>(Arrays.asList(1,2,3,4)), 2), |
|
|
|
Arguments.of("Figure 3 choosen", "3\n", new ArrayList<>(Arrays.asList(1,2,3,4)),3), |
|
|
|
Arguments.of("Figure 4 choosen", "4\n", new ArrayList<>(Arrays.asList(1,2,3,4)),4), |
|
|
|
Arguments.of("Index out of bounds choosen", "16\n",new ArrayList<>(Arrays.asList(1,2,3,4)), -1), |
|
|
|
Arguments.of("Index out of bounds choosen", "-2\n",new ArrayList<>(Arrays.asList(1,2,3,4)), -1), |
|
|
|
Arguments.of("Input a letter or char", "g\n",new ArrayList<>(Arrays.asList(1,2,3,4)), -1), |
|
|
|
Arguments.of("Input a empty string", "\n",new ArrayList<>(Arrays.asList(1,2,3,4)), -1), |
|
|
|
Arguments.of("Input a special character", "&\n",new ArrayList<>(Arrays.asList(1,2,3,4)), -1), |
|
|
|
Arguments.of("Only one Figure available", "1\n", new ArrayList<>(Arrays.asList(1)),1), |
|
|
|
Arguments.of("Figure not available", "4\n", new ArrayList<>(Arrays.asList(1,2)),-1) |
|
|
|
); |
|
|
|
} |
|
|
|
} |