def test_get_score(self, p1Points, p2Points, score, p1Name, p2Name): game = TennisGame(p1Name, p2Name) for i in range(p1Points): game.won_point(p1Name) for i in range(p2Points): game.won_point(p2Name) assert score == game.score()
def play_game(p1Points, p2Points, p1Name, p2Name): game = TennisGame(p1Name, p2Name) for i in range(max(p1Points, p2Points)): if i < p1Points: game.won_point(p1Name) if i < p2Points: game.won_point(p2Name) return game
def test_Score(self): for testcase in test_cases: (p1Points, p2Points, score, p1Name, p2Name) = testcase game = TennisGame(p1Name, p2Name) for i in range(p1Points): game.won_point(p1Name) for i in range(p2Points): game.won_point(p2Name) self.assertEquals(score, game.score())
def when_score_is_forty_love_and_p1_score_then_game_is_over_test(): tennis = TennisGame(Score.FORTY, Score.LOVE) tennis.score_player(1) assert tennis.is_over
def when_score_is_thirty_love_and_p1_score_then_game_is_not_over_test(): tennis = TennisGame(Score.THIRTY, Score.LOVE) tennis.score_player(1) assert not tennis.is_over
def when_score_is_love_all_then_game_is_not_over_test(): tennis = TennisGame() assert not tennis.is_over
def when_score_is_forty_all_and_p1_score_then_game_is_not_over_test(): tennis = TennisGame(Score.FORTY, Score.FORTY) tennis.score_player(1) assert not tennis.is_over
def when_score_is_love_all_and_p1_score_then_score_is_fifteen_love_test(): tennis = TennisGame() tennis.score_player(1) assert tennis.score == (Score.FIFTEEN, Score.LOVE)
def when_score_is_love_forty_and_p2_score_then_game_is_over_test(): tennis = TennisGame(Score.LOVE, Score.FORTY) tennis.score_player(2) assert tennis.is_over
def when_score_is_love_all_and_p1_score_then_game_is_not_over_test(): tennis = TennisGame() tennis.score_player(1) assert not tennis.is_over
def setUp(self): self.game = TennisGame()