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.1 KiB

  1. import org.junit.jupiter.api.BeforeEach;
  2. import org.junit.jupiter.api.DisplayName;
  3. import org.junit.jupiter.api.Test;
  4. import org.junit.jupiter.params.ParameterizedTest;
  5. import org.junit.jupiter.params.aggregator.AggregateWith;
  6. import org.junit.jupiter.params.provider.Arguments;
  7. import org.junit.jupiter.params.provider.CsvFileSource;
  8. import org.junit.jupiter.params.provider.CsvSource;
  9. import org.junit.jupiter.params.provider.MethodSource;
  10. import java.util.stream.Stream;
  11. import static org.junit.jupiter.api.Assertions.assertEquals;
  12. public class BowlingCalculatorTest {
  13. @ParameterizedTest(name = "[{index}] {0} scores {2}")
  14. @MethodSource("playerResults")
  15. void test(String testName, String playerResult, int expectedScore) {
  16. BowlingGameCalculator bgc = new BowlingGameCalculator();
  17. int calculatedScore = bgc.score(playerResult);
  18. assertEquals(expectedScore, calculatedScore, String.format("%s: %s", testName, playerResult));
  19. }
  20. private static Stream<Arguments> playerResults() {
  21. return Stream.of(Arguments.of("worst game", "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0", 0)); // 16x 0
  22. }
  23. }