package net.saff.bowling.test; import static net.saff.theories.assertion.api.Requirements.*; import static net.saff.theories.integration.hamcrest.api.HamcrestIntegration.*; import net.saff.theories.methods.api.DataPoint; import net.saff.theories.methods.api.Theory; import net.saff.theories.runner.api.Theories; import net.saff.theories.runner.api.TheoryContainer; import org.hamcrest.Matchers; import org.junit.runner.RunWith; @RunWith(Theories.class) public class BowlingTests extends TheoryContainer { public static Game STARTING_GAME = new Game(); public static Game NULL_GAME = null; public static Bowl THREE = new Bowl(3); public static Bowl FOUR = new Bowl(4); public static Bowl NULL_BOWL = null; @DataPoint public Bowl oneHundredBowl() { return new Bowl(100); } public static int ONE_HUNDRED = 100; public static int ZERO = 0; @Theory public void shouldBeTenFramesWithTwoRollsInEach(Game game, Bowl first, Bowl second) { assumeNotNull(game, first, second); assumeThat(game.isAtBeginning(), is(true)); assumeThat(game.getPlayers().size(), is(1)); assumeThat(first.isStrike(), is(false)); assumeThat(second.completesSpareAfter(first), is(false)); for (int frame = 0; frame < 10; frame++) { game.bowl(first); game.bowl(second); } assertThat(game.isGameOver(), is(true)); } @Theory public void maximumPinCountIsTen(Bowl bowl) { assumeNotNull(bowl); assertThat(bowl.pinCount(), matches(Matchers.lessThanOrEqualTo(10))); } @Theory public void pinCountMatchesConstructorParameter(int pinCount) { try { assertThat(new Bowl(pinCount).pinCount(), is(pinCount)); } catch (IllegalArgumentException e) { assumeNoException(e); } } }