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

4 years ago
  1. package de.edu.hsfulda.ccip.tdd.purefunction.parameterized;
  2. import static org.hamcrest.CoreMatchers.equalTo;
  3. import static org.junit.Assert.assertThat;
  4. import static org.junit.jupiter.params.provider.Arguments.arguments;
  5. import java.util.stream.Stream;
  6. import org.hamcrest.Matcher;
  7. import org.junit.jupiter.params.ParameterizedTest;
  8. import org.junit.jupiter.params.provider.Arguments;
  9. import org.junit.jupiter.params.provider.MethodSource;
  10. import de.edu.hsfulda.ccip.tdd.purefunction.BowlingCalculator;
  11. public class BowlingCalculatorParameterized_1_SourceMethodTest {
  12. static Stream<Arguments> sourceMethod() {
  13. // arrange
  14. return Stream.of(//
  15. arguments("worst game", "-- -- -- -- -- -- -- -- -- --", equalTo(0)),
  16. arguments("incomplete frames", "-1 23 -4 5- -6 -7 8- 9- -- --", equalTo(45)),
  17. arguments("spares","-- -- 3/ -- 7/ -- -- -- -- --" , equalTo(20))
  18. //
  19. );
  20. }
  21. @ParameterizedTest(name = "#{index} - game type {0}")
  22. @MethodSource("sourceMethod")
  23. void testStreamSouce(String gameType, String rolls, Matcher<Integer> expectedResult) {
  24. // act
  25. int score = new BowlingCalculator().score(rolls);
  26. //assert
  27. assertThat(rolls, score, expectedResult);
  28. }
  29. }