@Test
 public void bothPlayerDrawWithFifteenShouldReturnFifteenAll() throws Exception {
   tennisGame.playerScore(15, 0);
   tennisGame.playerScore(0, 15);
   String score = tennisGame.getScore();
   assertEquals("Fifteen all", score);
 }
Example #2
0
  @Test
  public void testCalculateScore() {

    TennisGame game = new TennisGame("h", "l", "211212121");
    assertEquals("30:30", game.scoreAt(4));
    assertEquals("40:30", game.scoreAt(5));
    assertEquals("Deuce", game.scoreAt(6));

    TennisGame game2 = new TennisGame("h", "l", "22222121");
    assertEquals("l Wins", game2.scoreAt(4));

    TennisGame game3 = new TennisGame("h", "l", "2121212122");
    assertEquals("Advantage:l", game3.scoreAt(9));
  }
 @Test
 public void playerBWinOneBallAfterDeuceShouldReturnAdvantagePlayerB() throws Exception {
   tennisGame.playerScore(40, 50);
   String score = tennisGame.getScore();
   assertEquals("Advantage Player B", score);
 }
 @Test
 public void playerBWinFirstFourBallShouldReturnWinForPlayerB() throws Exception {
   tennisGame.playerScore(0, 50);
   String score = tennisGame.getScore();
   assertEquals("Win For Player B", score);
 }
 @Test
 public void bothPlayerDrawWithFortyShouldReturnDuce() throws Exception {
   tennisGame.playerScore(40, 40);
   String score = tennisGame.getScore();
   assertEquals("Deuce", score);
 }
 @Test
 public void playerAWinFirstThreeBallShouldReturnFortyLove() throws Exception {
   tennisGame.playerScore(40, 0);
   String score = tennisGame.getScore();
   assertEquals("Forty Love", score);
 }
 @Test
 public void playerBWinInFirstBallShouldReturnLoveFifteen() throws Exception {
   tennisGame.playerScore(0, 15);
   String score = tennisGame.getScore();
   assertEquals("Love Fifteen", score);
 }
 @Test
 public void playerAWinFirstBallShouldReturnFifteenLove() throws Exception {
   tennisGame.playerScore(15, 0);
   String score = tennisGame.getScore();
   assertEquals("Fifteen Love", score);
 }
 @Test
 public void newGameShouldReturnLoveAll() throws Exception {
   String score = tennisGame.getScore();
   assertEquals("Love all", score);
 }
 @Test
 public void WatchTheScoreOfTheBeginingOfTheGameExpectedLoveAllAsResult() {
   TennisGame gameTest = new TennisGame();
   assertEquals(gameTest.getScore(), TennisGame.LOVE_ALL);
 }
 @Test
 public void WatchTheScoreAfterSecondPointAndTheTwoPlayerScoredServerThanReceiver() {
   TennisGame gameTest = new TennisGame();
   gameTest.BothPlayerScoredAPointServerThanReceiver();
   assertEquals(gameTest.getScore(), TennisGame.FIFTEEN_ALL);
 }
 @Test
 public void WatchTheScoreAfterOnePointForTheReceiverOnTheFirstPointOfTheSet() {
   TennisGame gameTest = new TennisGame();
   gameTest.ReceiverScoredAPoint();
   assertEquals(gameTest.getScore(), TennisGame.LOVE_FIFTEEN);
 }