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.
|
|
package de.edu.hsfulda.ccip.tdd.purefunction;
import static org.junit.Assert.assertThat; import static org.junit.jupiter.api.Assertions.*;
import org.hamcrest.CoreMatchers; import org.junit.Assert; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test;
class BowlingCalculatorTest {
private BowlingCalculator bowlingCalculator;
@BeforeEach void setUp() throws Exception { bowlingCalculator = new BowlingCalculator(); }
@Test void resultOfWorstGameIsZero() { // arrange
String rolls = "-- -- -- -- -- -- -- -- -- --"; int expectedScore = 0; // act
int score = bowlingCalculator.score(rolls); // assert
assertThat("score", score, CoreMatchers.equalTo(expectedScore)); }
@Test void addUpSingleRollInIncompleteFrames() { // arrange
String rolls = "-1 23 -4 5- -6 -7 8- 9- -- --"; int expectedScore = 45; // act
int score = bowlingCalculator.score(rolls); // assert
assertThat("score", score, CoreMatchers.equalTo(expectedScore)); }
@Test void frameWithSpareCounts10() { // arrange
String rolls = "-- -- 3/ -- 7/ -- -- -- -- --"; int expectedScore = 20; // act
int score = bowlingCalculator.score(rolls); // assert
assertThat("score", score, CoreMatchers.equalTo(expectedScore)); } @Test void frameWithSpareAddsNextRollTwice() { // arrange
String rolls = "-- -- 3/ 2- 7/ 8- -- -- -- --"; int expectedScore = 40; // act
int score = bowlingCalculator.score(rolls); // assert
assertThat("score", score, CoreMatchers.equalTo(expectedScore)); }
@Test void frameWithStrikeCounts10() { // arrange
String rolls = "-- -- X -- X -- -- -- -- --"; int expectedScore = 20; // act
int score = bowlingCalculator.score(rolls); // assert
assertThat("score", score, CoreMatchers.equalTo(expectedScore)); } @Test void frameWithStrikeAddsNextRollTwice() { // arrange
String rolls = "-- -- X 2- X 8- -- -- -- --"; int expectedScore = 40; // act
int score = bowlingCalculator.score(rolls); // assert
assertThat("score", score, CoreMatchers.equalTo(expectedScore)); }@Test void frameWithStrikeAddsSecondNextRollTwice() { // arrange
String rolls = "-- -- X -2 X -8 -- -- -- --"; int expectedScore = 40; // act
int score = bowlingCalculator.score(rolls); // assert
assertThat("score", score, CoreMatchers.equalTo(expectedScore)); } }
|