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

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.aggregator.AggregateWith;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.CsvFileSource;
import org.junit.jupiter.params.provider.CsvSource;
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)); // 16x 0
}
}