@Test public void gettingAStrike() { g.roll(10); g.roll(3); g.roll(6); rollMany(17, 0); assertThat(g.score(), equalTo(28)); }
@Test public void gettingASpare() { rollASpare(); g.roll(3); rollMany(17, 0); assertThat(g.score(), equalTo(16)); }
private void rollASpare() { g.roll(5); g.roll(5); }
private void rollMany(int n, int pins) { for (int i = 0; i < n; i++) { g.roll(pins); } }
@Test public void perfectGame() { rollMany(12, 10); assertThat(g.score(), equalTo(300)); }
@Test public void hittingOnlyOnePinInEveryFrame() { rollMany(20, 1); assertThat(g.score(), equalTo(20)); }
@Test public void gutterGame() { rollMany(20, 0); assertThat(g.score(), equalTo(0)); }