|
|
@ -6,6 +6,7 @@ import org.junit.jupiter.params.ParameterizedTest; |
|
|
|
import org.junit.jupiter.params.provider.Arguments; |
|
|
|
import org.junit.jupiter.params.provider.MethodSource; |
|
|
|
|
|
|
|
import java.io.ByteArrayInputStream; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Collection; |
|
|
@ -172,4 +173,26 @@ public class PlayerTest { |
|
|
|
false) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
|
@MethodSource("checkChooseMethodData") |
|
|
|
void checkChoose(String testName, String input, int expectedResult) { |
|
|
|
System.setIn(new ByteArrayInputStream(input.getBytes())); |
|
|
|
int calculatedResult = p.choose(); |
|
|
|
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) |
|
|
|
); |
|
|
|
} |
|
|
|
} |