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

  1. package de.edu.hsfulda.ciip.tdd;
  2. import static org.junit.Assert.*;
  3. import org.hamcrest.CoreMatchers;
  4. import org.junit.Test;
  5. public class BowlingCalculatorTest {
  6. private final BownlingCalculator bownlingCalculator = new BownlingCalculator();
  7. @Test
  8. public void returnsZeroWhenNoPinIsHit() {
  9. // arrange
  10. String listOfThrows = "-- -- -- -- -- -- -- -- -- --";
  11. int expectedValue = 0;
  12. // act
  13. int calculatedResult = bownlingCalculator.evaluate(listOfThrows);
  14. // assert
  15. assertThat("calculated value", calculatedResult, CoreMatchers.equalTo(expectedValue));
  16. }
  17. @Test
  18. public void createsSumOfAllIncompleteFrames() {
  19. // arrange
  20. String listOfThrows = "11 22 33 44 54 63 72 81 -9 --";
  21. int expectedValue = 65;
  22. // act
  23. int calculatedResult = bownlingCalculator.evaluate(listOfThrows);
  24. // assert
  25. assertThat("calculated value", calculatedResult, CoreMatchers.equalTo(expectedValue));
  26. }
  27. @Test
  28. public void throwAfterSpareCountsTwice() {
  29. // arrange
  30. String listOfThrows = "1/ 11 -- -- -- -- -- -- -- --";
  31. int expectedValue = 13;
  32. // act
  33. int calculatedResult = bownlingCalculator.evaluate(listOfThrows);
  34. // assert
  35. assertThat("calculated value", calculatedResult, CoreMatchers.equalTo(expectedValue));
  36. }
  37. @Test
  38. public void twoThrowsAfterStrikeCountTwice() {
  39. // arrange
  40. String listOfThrows = "X 12 11 -- -- -- -- -- -- --";
  41. int expectedValue = 18;
  42. // act
  43. int calculatedResult = bownlingCalculator.evaluate(listOfThrows);
  44. // assert
  45. assertThat("calculated value", calculatedResult, CoreMatchers.equalTo(expectedValue));
  46. }
  47. }