package kevin.lawrence.bowling;

import static org.hamcrest.Matchers.*;
import static org.hamcrest.MatcherAssert.*;

import java.util.Iterator;

import org.junit.Before;
import org.junit.Test;

public class LastFrameTest {
  private Game game;
  private Frame lastFrame;

  @Before
  public void createGameWithNineFramesOfGutterBalls() {
    game = new Game();
    
    for(int i = 0; i < 9; i++) {
      game.bowl(0);
      game.bowl(0);
    }
    
    lastFrame = game.getLastFrame();
  }

  @Test
  public void theLastFrameRequiresThreeBallsIfItIsStrike() {
    game.bowl(10);
    game.bowl(2);    
    assertThat(game.isGameOver(), is(false));

    game.bowl(3);    
    assertThat(game.isGameOver(), is(true));
  }

  @Test
  public void shouldShowTheExtraBallsIfLastFrameIsStrike() {
    game.bowl(10);
    game.bowl(2);    
    game.bowl(3);    

    assertThat(lastFrame.getFirstBall(), is("X"));
    assertThat(lastFrame.getSecondBall(), is("2"));
    assertThat(lastFrame.getThirdBall(), is("3"));
  }

}
