@Test public void checkAllScores() { TennisGame game = new TennisGame("player1", "player2"); int highestScore = Math.max(this.player1Score, this.player2Score); for (int i = 0; i < highestScore; i++) { if (i < this.player1Score) game.wonPoint("player1"); if (i < this.player2Score) game.wonPoint("player2"); } Assert.assertEquals(this.expectedScore, game.getScore()); }
@Test public void realisticGame() { TennisGame game = new TennisGame("player1", "player2"); String[] points = {"player1", "player1", "player2", "player2", "player1", "player1"}; String[] expected_scores = {"Fifteen-Love", "Thirty-Love", "Thirty-Fifteen", "Thirty-All", "Forty-Thirty", "Win for player1"}; for (int i = 0; i < 6; i++) { game.wonPoint(points[i]); Assert.assertEquals(expected_scores[i], game.getScore()); } }