You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1.3 KiB

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class BowlingCalculatorTest {
@ParameterizedTest(name = "[{index}] {0} scores {2}")
@MethodSource("playerResults")
void test(String testName, String playerResult, int expectedScore) {
BowlingGameCalculator bgc = new BowlingGameCalculator();
int calculatedScore = bgc.score(playerResult);
assertEquals(expectedScore, calculatedScore, String.format("%s: %s", testName, playerResult));
}
private static Stream<Arguments> playerResults() {
return Stream.of(
Arguments.of("worst game", "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0", 0), // 20x 0
Arguments.of("some incomplete frames", "0,1,2,3,0,0,4,0,0,5,0,0,6,0,0,0,0,0,0,0", 21),
Arguments.of("some other incomplete frames", "9- 9- 9- 9- 9- 9- 9- 9- 9- 9-", 90),
Arguments.of("roll after spare counts twice", "0,0 ,0,/ ,1,0 ,0,0,0,0,0,0,0,0,0,0,0,0,0,0", 12), // Wurf nach Spare (/) zählt doppelt
Arguments.of("spare counts 10", "5/ 5/ 5/ 5/ 5/ 5/ 5/ 5/ 5/ 5/5", 150)
);
}
}