def test_magicCardInit_whenHealthPointsNegative_shouldRaise(self): name = 'test' magic_card = MagicCard(name) with self.assertRaises(ValueError) as context: magic_card.health_points = -50 self.assertIsNotNone(context.exception) self.assertEqual(str(context.exception), "Card's HP cannot be less than zero.")
def add_card(self, type_c: str, name: str): if type_c == 'Magic': self.card_repository.add(MagicCard(name)) elif type_c == 'Trap': self.card_repository.add(TrapCard(name)) return f'Successfully added card of type {type_c}Card with name: {name}'
def test_magicCardInit_shouldSetDamagePointsAndHealthPointsInInitialization( self): name = 'test' magic_card = MagicCard(name) self.assertEqual(5, magic_card.damage_points) self.assertEqual(80, magic_card.health_points)
def test_magicCardInit_whenEmptyStringName_shouldRaise(self): name = '' with self.assertRaises(ValueError) as context: MagicCard(name) self.assertIsNotNone(context.exception) self.assertEqual(str(context.exception), "Card's name cannot be an empty string.")
def test_battleFieldFight_whenPlayersWithCards_shouldIncreasePointsAndTakeDamage(self): attacker = Advanced('attacker test') enemy = Advanced('enemy test') card = MagicCard('magic card test') attacker.card_repository.add(card) self.battle_field.fight(attacker, enemy) self.assertEqual(250 + 80, attacker.health) self.assertEqual(245, enemy.health)
def test_controllerAddPlayerCard_shouldAddCardToPlayersCardRepository( self): username = '******' card_name = 'test card name' player = Beginner(username) card = MagicCard(card_name) self.controller.player_repository.add(player) self.controller.card_repository.add(card) result = self.controller.add_player_card(username, card_name) self.assertListEqual([card], player.card_repository.cards) self.assertEqual( 'Successfully added card: test card name to user: test username', result)
def test_magicCardInit_whenValidName_shouldSetIt(self): name = 'test' magic_card = MagicCard(name) self.assertEqual('test', magic_card.name)