def test_high_low_three_players_four_card_round(self): bruce = Player("Bruce") clark = Player("Clark") lex = Player("Lex") two_of_hearts = Card("Heart", 2) three_of_hearts = Card("Heart", 3) four_of_hearts = Card("Heart", 4) five_of_hearts = Card("Heart", 5) deck = Deck() deck.set_cards( [two_of_hearts, three_of_hearts, four_of_hearts, five_of_hearts]) game = HighLow([bruce, clark, lex]) game.set_deck(deck) game.deal_cards() game.play_round() self.assertEqual( len(game.get_deck().get_cards()), 1, "With four cards in the deck, after dealing to three players, one card should remain in the deck." ) self.assertFalse( bruce.has_cards(), "After playing a round with one card, there should be no card remaining." ) self.assertFalse( clark.has_cards(), "After playing a round with one card, there should be no card remaining." ) self.assertFalse( lex.has_cards(), "After playing a round with one card, there should be no card remaining." ) self.assertEqual(bruce.get_points(), 1, "Testing game result.") self.assertEqual(clark.get_points(), 0, "Testing game result.") self.assertEqual(lex.get_points(), 0, "Testing game result.")
def test_high_low_two_players_two_cards_same_value_round(self): bruce = Player("Bruce") clark = Player("Clark") two_of_hearts = Card("Heart", 2) three_of_hearts = Card("Spade", 2) deck = Deck() deck.set_cards([two_of_hearts, three_of_hearts]) game = HighLow([bruce, clark]) game.set_deck(deck) game.deal_cards() game.play_round() self.assertFalse( bruce.has_cards(), "After playing a round with one card, there should be no card remaining.\nSubmitted:" + str(bruce.get_cards())) self.assertFalse( clark.has_cards(), "After playing a round with one card, there should be no card remaining.\nSubmitted:" + str(clark.get_cards())) self.assertEqual( bruce.get_points(), 1, "Checking the result of game with 'Heart-2' and 'Spade-2' cards. The player with 'Heart-2' wins 1 point.\nSubmitted:" + str(bruce.get_points())) self.assertEqual( clark.get_points(), 0, "Checking the result of game with 'Heart-2' and 'Spade-2' cards. The player with 'Spade-2' wins 0 point.\nSubmitted:" + str(clark.get_points()))
def test_high_low_four_players_full_deck_round(self): bruce = Player("Bruce") clark = Player("Clark") lex = Player("Lex") jack = Player("Jack") players = [bruce, clark, lex, jack] game = HighLow(players) game.deal_cards() game.play_round() self.assertEqual(len(game.get_deck().get_cards()), 0, "After dealing standard deck to four players, no card should remain in the deck.") for player in players: self.assertEqual(len(player.get_cards()), 12, "Each players has 12 cards in their hands after being dealt.")
def test_high_low_two_players_two_card_round(self): bruce = Player("Bruce") clark = Player("Clark") two_of_hearts = Card("Heart", 2) three_of_hearts = Card("Heart", 3) deck = Deck() deck.set_cards([two_of_hearts, three_of_hearts]) game = HighLow([bruce, clark]) game.set_deck(deck) game.deal_cards() game.play_round() self.assertFalse(bruce.has_cards(), "After playing a round with one card, there should be no card remaining in the player's hand.\nSubmitted:"+str(bruce.get_cards())) self.assertFalse(clark.has_cards(), "After playing a round with one card, there should be no card remaining in the player's hand.\nSubmitted:"+str(clark.get_cards())) self.assertEqual(bruce.get_points(), 1, "Checking the result of game with 'Heart-2' and 'Heart-3' cards. The player with 'Heart-3' wins 1 point.\nSubmitted:"+str(bruce.get_points())) self.assertEqual(clark.get_points(), 0, "Checking the result of game with 'Heart-2' and 'Heart-3' cards. The player with 'Heart-2' wins 0 point.\nSubmitted:"+str(clark.get_points()))
def test_high_low_four_players_full_deck_round(self): bruce = Player("Bruce") clark = Player("Clark") lex = Player("Lex") jack = Player("Jack") players = [bruce, clark, lex, jack] game = HighLow(players) game.deal_cards() game.play_round() self.assertEqual( len(game.get_deck().get_cards()), 0, "After dealing standard deck to four players, no card should remain in the deck." ) for player in players: self.assertEqual( len(player.get_cards()), 12, "Each players has 12 cards in their hands after being dealt.")
def test_high_low_three_players_four_card_round(self): bruce = Player("Bruce") clark = Player("Clark") lex = Player("Lex") two_of_hearts = Card("Heart", 2) three_of_hearts = Card("Heart", 3) four_of_hearts = Card("Heart", 4) five_of_hearts = Card("Heart", 5) deck = Deck() deck.set_cards([two_of_hearts, three_of_hearts, four_of_hearts, five_of_hearts]) game = HighLow([bruce, clark, lex]) game.set_deck(deck) game.deal_cards() game.play_round() self.assertEqual(len(game.get_deck().get_cards()), 1, "With four cards in the deck, after dealing to three players, one card should remain in the deck.") self.assertFalse(bruce.has_cards(), "After playing a round with one card, there should be no card remaining.") self.assertFalse(clark.has_cards(), "After playing a round with one card, there should be no card remaining.") self.assertFalse(lex.has_cards(), "After playing a round with one card, there should be no card remaining.") self.assertEqual(bruce.get_points(), 1, "Testing game result.") self.assertEqual(clark.get_points(), 0, "Testing game result.") self.assertEqual(lex.get_points(), 0, "Testing game result.")