def test_is_end_game_returns_correctly_when_one_is_empty(self): new_game = CardGame() new_deck = [ Card(CardType.Clubs, CardValue.Ace), Card(CardType.Diamonds, CardValue.Ace) ] new_game.set_decks([], new_deck) self.assertEqual(2, new_game.is_end_game()) new_game.set_decks(new_deck, []) self.assertEqual(1, new_game.is_end_game())
def test_get_loses_a_play(self): card_game = CardGame() deck1 = [Card(CardType.Clubs, CardValue.Ace)] deck2 = [Card(CardType.Clubs, CardValue.Queen)] card_game.set_decks(deck1, deck2) card_game.play() self.assertEqual(2, len(card_game.player1_deck)) self.assertEqual(0, len(card_game.player2_deck)) self.assertEqual(1, card_game.is_end_game())
def test_loses_while_the_draw(self): card_game = CardGame() deck1 = [ Card(CardType.Clubs, CardValue.Ace), Card(CardType.Clubs, CardValue.Queen), Card(CardType.Clubs, CardValue.King) ] deck2 = [ Card(CardType.Diamonds, CardValue.Ace), Card(CardType.Diamonds, CardValue.Queen) ] card_game.set_decks(deck1, deck2) card_game.play() self.assertEqual(1, card_game.is_end_game())
def test_play_first_card_win(self): card_game = CardGame() deck1 = [ Card(CardType.Clubs, CardValue.Ace), Card(CardType.Diamonds, CardValue.Ace) ] deck2 = [ Card(CardType.Clubs, CardValue.Queen), Card(CardType.Diamonds, CardValue.Queen) ] card_game.set_decks(deck1, deck2) card_game.play() self.assertEqual(3, len(card_game.player1_deck)) self.assertEqual(1, len(card_game.player2_deck))
def test_play_second_card_win(self): card_game = CardGame() deck1 = [ Card(CardType.Clubs, CardValue.Ace), Card(CardType.Diamonds, CardValue.Ace), Card(CardType.Hearts, CardValue.Ace), Card(CardType.Spades, CardValue.Ace), Card(CardType.Spades, CardValue.King), Card(CardType.Spades, CardValue.Queen) ] deck2 = [ Card(CardType.Clubs, CardValue.Ace), Card(CardType.Diamonds, CardValue.Queen), Card(CardType.Hearts, CardValue.Queen), Card(CardType.Spades, CardValue.Queen), Card(CardType.Spades, CardValue.Three), Card(CardType.Spades, CardValue.Two) ] card_game.set_decks(deck1, deck2) card_game.play() self.assertEqual(11, len(card_game.player1_deck)) self.assertEqual(1, len(card_game.player2_deck))
def test_playing_works(self): card_game = CardGame() card_game.init_game() self.assertNotEqual(0, card_game.game())
def test_is_end_game_returns_correctly_when_both_are_empty(self): new_game = CardGame() new_game.set_decks([], []) self.assertEqual(3, new_game.is_end_game())
def setup_class(cls): cls.card_game = CardGame() cls.card_game.init_game()