def test_play_reversed(self): """ Tests for a game which reverses the order into negative numbers. """ pa = player.RandomAiPlayer("Player A") pb = player.RandomAiPlayer("Player B") pc = player.RandomAiPlayer("Player C") u = uno.Uno([pa, pb, pc]) pa.hand = [ unocard.UnoCard(1, 7), unocard.UnoCard(1, 7), unocard.UnoCard(1, 7) ] # 7 of Diamonds pb.hand = [unocard.ReverseActionCard(1), unocard.ReverseActionCard(1)] # 10 of Diamonds pc.hand = [unocard.UnoCard(1, 9), unocard.UnoCard(1, 9)] # 9 of Diamonds u.play() # This game should have resulted in 5 cards played, in order: self.assertEqual(5, len(u.pile)) self.assertEqual(7, u.pile[0].rank) self.assertEqual(10, u.pile[1].rank) self.assertEqual(7, u.pile[2].rank) self.assertEqual(9, u.pile[3].rank) self.assertEqual(10, u.pile[4].rank)
def test_performAction(self): """ Tests the performAction method of ReverseActionCard. """ card = unocard.ReverseActionCard(0) gameState = UnoGameState() card.performAction(gameState) self.assertEqual(True, gameState.isReversed) card.performAction(gameState) self.assertEqual(False, gameState.isReversed)
def test_init(self): """ Tests the init method of ReverseActionCard. """ card = unocard.ReverseActionCard(1) self.assert_unocard_init(card, 1, 10, "Reverse")