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.

61 lines
1.5 KiB

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));
}
}