package de.edu.hsfulda.ciip.tdd; import static org.junit.Assert.*; import org.hamcrest.CoreMatchers; import org.junit.Test; public class BowlingCalculatorTest { private final BownlingCalculator bownlingCalculator = new BownlingCalculator(); @Test public void returnsZeroWhenNoPinIsHit() { // arrange String listOfThrows = "-- -- -- -- -- -- -- -- -- --"; int expectedValue = 0; // act int calculatedResult = bownlingCalculator.evaluate(listOfThrows); // assert assertThat("calculated value", calculatedResult, CoreMatchers.equalTo(expectedValue)); } @Test public void createsSumOfAllIncompleteFrames() { // arrange String listOfThrows = "11 22 33 44 54 63 72 81 -9 --"; int expectedValue = 65; // act int calculatedResult = bownlingCalculator.evaluate(listOfThrows); // assert assertThat("calculated value", calculatedResult, CoreMatchers.equalTo(expectedValue)); } @Test public void throwAfterSpareCountsTwice() { // arrange String listOfThrows = "1/ 11 -- -- -- -- -- -- -- --"; int expectedValue = 13; // act int calculatedResult = bownlingCalculator.evaluate(listOfThrows); // assert assertThat("calculated value", calculatedResult, CoreMatchers.equalTo(expectedValue)); } @Test public void twoThrowsAfterStrikeCountTwice() { // arrange String listOfThrows = "X 12 11 -- -- -- -- -- -- --"; int expectedValue = 18; // act int calculatedResult = bownlingCalculator.evaluate(listOfThrows); // assert assertThat("calculated value", calculatedResult, CoreMatchers.equalTo(expectedValue)); } }