コード例 #1
0
 def test_hand_add_card_ace_counter(self):
     hand1 = player.Hand()
     hand1.add_card(deck_of_cards.Card('Hearts', 'Ace'))
     hand1.add_card(deck_of_cards.Card('Spades', 'Ace'))
     hand1.add_card(deck_of_cards.Card('Clubs', 'Ace'))
     result = hand1.aces
     self.assertEqual(result, 3)
コード例 #2
0
 def test_hand_adjust_for_ace(self):
     hand1 = player.Hand()
     hand1.add_card(deck_of_cards.Card('Diamonds', 'Ace'))
     hand1.add_card(deck_of_cards.Card('Spades', 'Ace'))
     hand1.adjust_for_ace()
     result = hand1.value
     self.assertEqual(result, 12)
コード例 #3
0
 def test_hand_adjust_for_ace_with_value_above_21_and_aces(self):
     hand1 = player.Hand()
     hand1.add_card(deck_of_cards.Card('Diamonds', 'Ace'))
     hand1.add_card(deck_of_cards.Card('Spades', 'Ace'))
     aces_pre_adjustment = hand1.aces
     hand1.adjust_for_ace()
     result = (hand1.value == 12 and aces_pre_adjustment != hand1.aces)
     self.assertTrue(result)
コード例 #4
0
 def test_hand_adjust_for_ace_with_value_under_21(self):
     hand1 = player.Hand()
     hand1.add_card(deck_of_cards.Card('Diamonds', 'Ace'))
     hand1.add_card(deck_of_cards.Card('Spades', 'Four'))
     value_pre_adjustment = hand1.value
     aces_pre_adjustment = hand1.aces
     hand1.adjust_for_ace()
     result = (value_pre_adjustment == hand1.value
               and aces_pre_adjustment == hand1.aces)
     self.assertTrue(result)
コード例 #5
0
 def test_hand_adjust_for_ace_with_value_above_21_no_ace(self):
     hand1 = player.Hand()
     hand1.add_card(deck_of_cards.Card('Diamonds', 'King'))
     hand1.add_card(deck_of_cards.Card('Spades', 'Queen'))
     hand1.add_card(deck_of_cards.Card('Spades', 'Seven'))
     value_pre_adjustment = hand1.value
     aces_pre_adjustment = hand1.aces
     hand1.adjust_for_ace()
     result = (value_pre_adjustment == hand1.value
               and aces_pre_adjustment == hand1.aces)
     self.assertTrue(result)
コード例 #6
0
 def test_hand_add_card(self):
     hand1 = player.Hand()
     hand2 = player.Hand()
     card = deck_of_cards.Card('Hearts', 'Ace')
     hand2.add_card(card)
     result = hand1.cards == hand2.cards
     self.assertFalse(result)
コード例 #7
0
 def test_hand_add_card_value_counter(self):
     hand1 = player.Hand()
     hand1.add_card(deck_of_cards.Card('Hearts', 'Ace'))
     hand1.add_card(deck_of_cards.Card('Spades', 'King'))
     result = hand1.value
     self.assertEqual(result, 21)
コード例 #8
0
 def test_hand_add_card_not_ace(self):
     hand1 = player.Hand()
     card = deck_of_cards.Card('Hearts', 'Four')
     hand1.add_card(card)
     result = hand1.aces == 0
     self.assertTrue(result)
コード例 #9
0
 def test_card_str(self):
     card = deck_of_cards.Card('Hearts', 'Ace')
     result = str(card)
     self.assertEqual(result, 'Ace of Hearts')