コード例 #1
0
  @Test
  public void getThePlayersSymbol() {
    PromptSpy prompt = new PromptSpy(new StringReader(""));
    HumanPlayer player = new HumanPlayer(X, prompt);

    assertThat(player.getSymbol(), is(X));
  }
コード例 #2
0
  @Test
  public void humanPlayerIsReady() {
    PromptSpy prompt = new PromptSpy(new StringReader("1\n"));
    HumanPlayer player = new HumanPlayer(X, prompt);
    Board board = new Board(X, VACANT, X, O, X, O, X, O, VACANT);

    assertThat(player.isReady(), is(true));
  }
コード例 #3
0
  @Test
  public void playerProvidesPromptWithNextMove() throws IOException {
    PromptSpy prompt = new PromptSpy(new StringReader("1\n"));
    HumanPlayer player = new HumanPlayer(X, prompt);
    Board board = new Board(X, VACANT, X, O, X, O, X, O, VACANT);

    assertThat(player.chooseNextMoveFrom(board), is(1));
  }