def testNumberOfCardsLeft(self): card = Card.Card( "Card name", "Card one Description", "https://sv.wikipedia.org/wiki/Portal:Huvudsida#/media/File:Panama_Canal_Gatun_Locks.jpg", 1, 1, 1) deck = Deck() deck.AddCard(card) self.assertEqual(1, deck.NumberOfCardsLeft, "Wrong number of cards left displayed") deck.AddCard(card) self.assertEqual( 2, deck.NumberOfCardsLeft, "Wrong number of cards left displayed after card added") deck.DrawCard() self.assertEqual( 1, deck.NumberOfCardsLeft, "Wrong number of cards left displayed after card removed")
def testDrawCard(self): card = Card.Card( "Card name", "Card one Description", "https://sv.wikipedia.org/wiki/Portal:Huvudsida#/media/File:Panama_Canal_Gatun_Locks.jpg", 1, 1, 1) deck = Deck() deck.AddCard(card) try: deck.DrawCard() except: self.fail("Card not drawn with one card in the deck") self.assertFalse( deck.DrawCard(), "Deck returned card and now false when deck is empty")
def testAddCard(self): card = Card.Card( "Card name", "Card one Description", "https://sv.wikipedia.org/wiki/Portal:Huvudsida#/media/File:Panama_Canal_Gatun_Locks.jpg", 1, 1, 1) deck = Deck() self.assertTrue(deck.OutOfCards, "Deck marked as containing cards with no cards") try: deck.AddCard(card) except: self.fail("Card was not added (AssertFail)") self.assertEquals(card, deck.DrawCard(), "Card not added correct")
def testOutOfCards(self): deck = Deck() deck.AddCard( Card.Card( "Card name", "Card one Description", "https://sv.wikipedia.org/wiki/Portal:Huvudsida#/media/File:Panama_Canal_Gatun_Locks.jpg", 1, 1, 1)) self.assertFalse(deck.OutOfCards, "Deck with a card marked as out of cards") deck.DrawCard() self.assertTrue(deck.OutOfCards, "Deck with no cards marked as containing cards") pass