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.
37 lines
1.2 KiB
37 lines
1.2 KiB
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<Arguments> 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<Integer> expectedResult) {
|
|
// act
|
|
int score = new BowlingCalculator().score(rolls);
|
|
//assert
|
|
assertThat(rolls, score, expectedResult);
|
|
}
|
|
|
|
}
|