コード例 #1
0
 public void testKnockDownMoreThanThereAre() throws InvalidPinsException {
   game.roll(5);
   try {
     game.roll(6);
     fail("Should not have been able to roll 5,6");
   } catch (InvalidPinsException expected) {
   }
 }
コード例 #2
0
 public void testSpareWithPinsStanding() throws Exception {
   assertEquals(10, game.pinsStanding());
   game.roll(4);
   assertEquals(6, game.pinsStanding());
   game.roll(6);
   assertEquals(10, game.pinsStanding());
   game.roll(5);
   assertEquals(5, game.pinsStanding());
 }
コード例 #3
0
 public void testAlternatiing() throws Exception {
   for (int i = 0; i < 5; i++) {
     game.roll(10);
     game.roll(4);
     game.roll(6);
   }
   game.roll(10);
   assertEquals(200, game.score());
 }
コード例 #4
0
 public void testStrikeWithInvalidBonusInLastFrame() throws Exception {
   rollMany(10, 10);
   game.roll(6);
   assertEquals(4, game.pinsStanding());
   try {
     game.roll(6);
     fail("Rolled 12 in bonus frame");
   } catch (InvalidPinsException expected) {
   }
 }
コード例 #5
0
ファイル: GameTest.java プロジェクト: Boram-Jeong/BowlingGame
  @Test
  public void oneStrikeGame() {
    game.roll(10);
    game.roll(3);
    game.roll(4);

    for (int frameIndex = 0; frameIndex < 16; frameIndex++) {
      game.roll(0);
    }

    assertEquals(24, game.getScore());
  }
コード例 #6
0
ファイル: GameTest.java プロジェクト: Boram-Jeong/BowlingGame
  @Test
  public void oneSpareGame() {
    game.roll(5);
    game.roll(5);
    game.roll(3);

    for (int frameIndex = 0; frameIndex < 17; frameIndex++) {
      game.roll(0);
    }

    assertEquals(16, game.getScore());
  }
コード例 #7
0
  public void testThreesWithFrameCountingPinsStanding() throws Exception {
    assertEquals(0, game.finishedFrames());

    for (int frame = 1; frame <= 10; frame++) {
      assertEquals(10, game.pinsStanding());
      game.roll(3);
      assertEquals(7, game.pinsStanding());
      game.roll(3);
      assertEquals(10, game.pinsStanding());
      assertEquals(frame, game.finishedFrames());
      assertEquals(frame, game.scoredFrames());
    }
    assertEquals(60, game.score());
  }
コード例 #8
0
  public void testPerfectWithPinsStanding() throws Exception {
    for (int frame = 1; frame <= 9; frame++) {
      assertEquals(10, game.pinsStanding());
      game.roll(10);
    }

    assertEquals(10, game.pinsStanding());
    game.roll(10);
    assertEquals(10, game.pinsStanding());
    game.roll(10);
    assertEquals(10, game.pinsStanding());
    game.roll(10);
    assertEquals(300, game.score());
  }
コード例 #9
0
ファイル: GameTest.java プロジェクト: shoutaro15/TD3
 @Test
 public void testOneSpare() throws Exception {
   rollSpare();
   g.roll(3);
   rollMany(17, 0);
   assertEquals(16, g.score());
 }
コード例 #10
0
ファイル: GameTest.java プロジェクト: shoutaro15/TD3
 @Test
 public void testOneStrike() throws Exception {
   rollStrike();
   g.roll(3);
   g.roll(4);
   rollMany(16, 0);
   assertEquals(24, g.score());
 }
コード例 #11
0
ファイル: GameTest.java プロジェクト: Boram-Jeong/BowlingGame
  @Test
  public void testPerfectGame() {
    for (int frameIndex = 0; frameIndex < 12; frameIndex++) {
      game.roll(10);
    }

    assertEquals(300, game.getScore());
  }
コード例 #12
0
ファイル: GameTest.java プロジェクト: Boram-Jeong/BowlingGame
  @Test
  public void perfectGame() {

    for (int frameIndex = 0; frameIndex < 20; frameIndex++) {
      game.roll(1);
    }

    assertEquals(20, game.getScore());
  }
コード例 #13
0
ファイル: GameTest.java プロジェクト: Boram-Jeong/BowlingGame
  @Test
  public void allGutterGame() {

    for (int frameIndex = 0; frameIndex < 20; frameIndex++) {
      game.roll(0);
    }

    assertEquals(0, game.getScore());
  }
コード例 #14
0
 public void testSpareWithFrameCounting() throws Exception {
   assertEquals(0, game.scoredFrames());
   game.roll(4);
   assertEquals("4", arrayAsString(game.rollsForFrame(1)));
   game.roll(6);
   assertEquals(1, game.finishedFrames());
   assertEquals(0, game.scoredFrames()); // cant score it yet
   assertEquals("4 6", arrayAsString(game.rollsForFrame(1)));
   game.roll(5);
   assertEquals(1, game.scoredFrames()); // can score it now
   game.roll(3);
   assertEquals(2, game.finishedFrames());
   assertEquals(2, game.scoredFrames()); // score right away
   rollMany(16, 0);
   assertEquals(10, game.finishedFrames());
   assertTrue(game.gameOver());
   assertEquals(10, game.scoredFrames());
   assertEquals(23, game.score());
 }
コード例 #15
0
  public void testPerfectWithFrameCounting() throws Exception {
    for (int frame = 1; frame <= 9; frame++) {
      game.roll(10);
      assertEquals(frame, game.finishedFrames());
    }

    assertEquals(7, game.scoredFrames());
    game.roll(10);
    assertEquals(9, game.finishedFrames()); // done with 9
    assertEquals(8, game.scoredFrames());
    assertEquals("10", arrayAsString(game.rollsForFrame(10)));
    game.roll(10); // still done with 9
    assertEquals(9, game.finishedFrames());
    assertEquals(9, game.scoredFrames());
    assertEquals("10 10", arrayAsString(game.rollsForFrame(10)));
    game.roll(10); // finally, done with 9
    assertEquals(10, game.finishedFrames());
    assertEquals(10, game.scoredFrames());
    assertEquals(300, game.score());
    assertEquals("10 10 10", arrayAsString(game.rollsForFrame(10)));
  }
コード例 #16
0
  public void testSpareAtEndWithFrameCounting() throws Exception {
    rollMany(18, 4);
    assertEquals(9, game.finishedFrames());
    assertEquals(9, game.scoredFrames());
    assertEquals(72, game.scoreForFrame(9));

    game.roll(7);
    assertEquals(9, game.finishedFrames());
    assertEquals(9, game.scoredFrames());

    assertEquals(3, game.pinsStanding());
    game.roll(3); // complete the spare
    assertEquals(9, game.finishedFrames());
    assertEquals(9, game.scoredFrames());

    assertEquals(10, game.pinsStanding());
    game.roll(6); // get an extra 6 pins, finishing the frame and game
    assertEquals(10, game.finishedFrames());
    assertEquals(10, game.scoredFrames());

    assertEquals(72 + 10 + 6, game.score());
  }
コード例 #17
0
 public void testStrikeWithFrameCounting() throws Exception {
   game.roll(10);
   assertEquals(1, game.finishedFrames());
   assertEquals(0, game.scoredFrames());
   assertEquals(10, game.pinsStanding());
   game.roll(5);
   assertEquals(1, game.finishedFrames());
   assertEquals(0, game.scoredFrames());
   game.roll(3);
   assertEquals(2, game.finishedFrames());
   assertEquals(2, game.scoredFrames());
   // that roll scored frames 1 and 2
   game.roll(2);
   assertEquals(2, game.finishedFrames());
   game.roll(1);
   assertEquals(3, game.finishedFrames());
   assertEquals(3, game.scoredFrames());
   rollMany(14, 0);
   assertEquals(10, game.finishedFrames());
   assertEquals(10, game.scoredFrames());
   assertEquals(29, game.score());
   assertEquals("10", arrayAsString(game.rollsForFrame(1)));
   assertEquals("5 3", arrayAsString(game.rollsForFrame(2)));
 }
コード例 #18
0
ファイル: GameTest.java プロジェクト: shoutaro15/TD3
 private void rollMany(int n, int pins) {
   for (int i = 0; i < n; i++) g.roll(pins);
 }
コード例 #19
0
ファイル: GameTest.java プロジェクト: shoutaro15/TD3
 private void rollStrike() {
   g.roll(10);
 }
コード例 #20
0
ファイル: GameTest.java プロジェクト: shoutaro15/TD3
 private void rollSpare() {
   g.roll(5);
   g.roll(5);
 }
コード例 #21
0
 private void rollMany(int count, int roll) throws InvalidPinsException {
   for (int i = 0; i < count; i++) game.roll(roll);
 }