Beispiel #1
0
    def test_winner_player_two(self):
        set_ = Set("player 1", "player 2")
        for _games in range(self.GAMES_TO_WIN_SET):
            for _ in range(self.POINTS_TO_WIN_GAME):
                set_.point_won_by("player 2")

        self.assertEqual(set_.winner(), "player 2")
Beispiel #2
0
 def test_score_grows(self):
     set = Set()
     self.assertEqual("0", set.firstScore())
     set.firstScores()
     self.assertEqual("15", set.firstScore())
     self.assertEqual("0", set.secondScore())
     set.secondScores()
     self.assertEqual("15", set.secondScore())
Beispiel #3
0
 def test_deuce_requires_2_more_than_one_ball_to_win(self):
     set = Set()
     set.firstScores(3)
     set.secondScores(3)
     set.secondScores()
     self.assertEqual(None, set.winner())
     set.secondScores()
     self.assertEqual(2, set.winner())
Beispiel #4
0
 def test_player_can_return_to_deuce_by_scoring_against_the_others_advantage(self):
     set = Set()
     set.firstScores(3)
     set.secondScores(3)
     self.assertEqual(None, set.winner())
     set.firstScores()
     set.secondScores()
     set.firstScores()
     set.secondScores()
     self.assertEqual(None, set.winner())
     self.assertEqual("40", set.firstScore())
     self.assertEqual("40", set.secondScore())
Beispiel #5
0
    def test_tie_is_broken_by_player_two(self):
        set_ = Set("player 1", "player 2")
        for _games in range(6):
            for _ in range(self.POINTS_TO_WIN_GAME):
                set_.point_won_by("player 1")

        for _games in range(6):
            for _ in range(self.POINTS_TO_WIN_GAME):
                set_.point_won_by("player 2")

        # Final game is a tie-breaker
        for _ in range(self.POINTS_TO_WIN_TIE_BREAKER):
            set_.point_won_by("player 2")

        self.assertEqual(set_.winner(), "player 2")
Beispiel #6
0
 def test_player_2_win_when_scores_at_40(self):
     set = Set()
     set.secondScores(3)
     self.assertEqual(None, set.winner())
     set.secondScores()
     self.assertEqual(2, set.winner())
Beispiel #7
0
 def test_player_1_win_when_scores_at_40(self):
     set = Set()
     set.firstScores(3)
     self.assertEqual(None, set.winner())
     set.firstScores()
     self.assertEqual(1, set.winner())
Beispiel #8
0
    def test_no_winner_if_one_game_won(self):
        set_ = Set("player 1", "player 2")
        for _ in range(self.POINTS_TO_WIN_GAME):
            set_.point_won_by("player 1")

        self.assertIsNone(set_.winner())
Beispiel #9
0
    def test_no_initial_winner(self):
        set_ = Set("player 1", "player 2")

        self.assertIsNone(set_.winner())
Beispiel #10
0
    def test_score_when_player_two_wins_a_game(self):
        set_ = Set("player 1", "player 2")
        for _ in range(self.POINTS_TO_WIN_GAME):
            set_.point_won_by("player 2")

        self.assertEqual(set_.score(), "0-1")
Beispiel #11
0
    def test_score_when_no_games_won(self):
        set_ = Set("player 1", "player 2")
        set_.point_won_by("player 1")

        self.assertEqual(set_.score(), "0-0")
Beispiel #12
0
    def test_initial_set_score(self):
        set_ = Set("player 1", "player 2")

        self.assertEqual(set_.score(), "0-0")
Beispiel #13
0
 def setUp(self):
     self.set: Set = Set("Charlotte", "Annabelle")