package de.edu.hsfulda.ccip.tdd.purefunction.parameterized; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; import static org.junit.jupiter.params.provider.Arguments.arguments; import java.util.stream.Stream; import org.hamcrest.Matcher; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import de.edu.hsfulda.ccip.tdd.purefunction.BowlingCalculator; public class BowlingCalculatorParameterized_1_SourceMethodTest { static Stream sourceMethod() { // arrange return Stream.of(// arguments("worst game", "-- -- -- -- -- -- -- -- -- --", equalTo(0)), arguments("incomplete frames", "-1 23 -4 5- -6 -7 8- 9- -- --", equalTo(45)), arguments("spares","-- -- 3/ -- 7/ -- -- -- -- --" , equalTo(20)) // ); } @ParameterizedTest(name = "#{index} - game type {0}") @MethodSource("sourceMethod") void testStreamSouce(String gameType, String rolls, Matcher expectedResult) { // act int score = new BowlingCalculator().score(rolls); //assert assertThat(rolls, score, expectedResult); } }