From 6ff9ba2ed9df8c7fd5440beffe768ed6ba6553e1 Mon Sep 17 00:00:00 2001 From: Thomas Papendieck Date: Wed, 2 Dec 2020 09:30:23 +0100 Subject: [PATCH] variant 1 --- ...latorParameterized_1_SourceMethodTest.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/test/java/de/edu/hsfulda/ccip/tdd/purefunction/parameterized/BowlingCalculatorParameterized_1_SourceMethodTest.java diff --git a/src/test/java/de/edu/hsfulda/ccip/tdd/purefunction/parameterized/BowlingCalculatorParameterized_1_SourceMethodTest.java b/src/test/java/de/edu/hsfulda/ccip/tdd/purefunction/parameterized/BowlingCalculatorParameterized_1_SourceMethodTest.java new file mode 100644 index 0000000..bda6ab3 --- /dev/null +++ b/src/test/java/de/edu/hsfulda/ccip/tdd/purefunction/parameterized/BowlingCalculatorParameterized_1_SourceMethodTest.java @@ -0,0 +1,37 @@ +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); + } + +}