def test_advancedTakeDamage_whenPositiveDamagePoints_shouldReduceHealth( self): username = '******' advanced_p = Advanced(username) advanced_p.take_damage(50) self.assertEqual(200, advanced_p.health)
def test_advancedTakeDamage_whenNegativeDamagePoints_shouldRaise(self): username = '******' advanced_p = Advanced(username) with self.assertRaises(ValueError) as context: advanced_p.take_damage(-50) self.assertIsNotNone(context.exception) self.assertEqual(str(context.exception), 'Damage points cannot be less than zero.')
def test_advancedInit_whenSetHealthToNegative_shouldRaise(self): username = '******' advanced_p = Advanced(username) with self.assertRaises(ValueError) as context: advanced_p.health = -250 self.assertIsNotNone(context.exception) self.assertEqual(str(context.exception), "Player's health bonus cannot be less than zero.")
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 add_player(self, type_p: str, username: str): if type_p == 'Beginner': self.player_repository.add(Beginner(username)) elif type_p == 'Advanced': self.player_repository.add(Advanced(username)) return f'Successfully added player of type {type_p} with username: {username}'
def test_battleFieldFight_whenEnemyIsBeginnerAndWithoutCards_shouldIncreaseAttr(self): attacker = Advanced('attacker test') enemy = Beginner('enemy test') self.battle_field.fight(attacker, enemy) self.assertEqual(250, attacker.health) self.assertEqual(50 + 40, enemy.health)
def test_advancedInit_whenEmptyStringUsername_shouldRaise(self): username = '' with self.assertRaises(ValueError) as context: Advanced(username) self.assertIsNotNone(context.exception) self.assertEqual(str(context.exception), "Player's username cannot be an empty string.")
def test_battleFieldFight_whenAttackerOrEnemyIsDead_shouldRaise(self): attacker = Beginner('attacker test') enemy = Advanced('enemy test') attacker.health = 0 with self.assertRaises(ValueError) as context: self.battle_field.fight(attacker, enemy) self.assertIsNotNone(context.exception) self.assertEqual(str(context.exception), 'Player is dead!')
def test_advancedInit_whenZeroHealth_shouldSetIsDeadPropertyToTrue(self): username = '******' advanced_p = Advanced(username) advanced_p.health = 0 self.assertTrue(advanced_p.is_dead)
def test_advancedInit_whenValidUsername_shouldIt(self): username = '******' advanced_p = Advanced(username) self.assertEqual('test', advanced_p.username)
def test_advancedInit_whenPositiveHealth_shouldSetIsDeadPropertyToFalse( self): username = '******' advanced_p = Advanced(username) self.assertFalse(advanced_p.is_dead)
def test_advancedInit_shouldInitializeCardRepository(self): username = '******' advanced_p = Advanced(username) self.assertEqual('CardRepository', advanced_p.card_repository.__class__.__name__)
def test_advancedInit_shouldSetHealthTo250(self): username = '******' advanced_p = Advanced(username) self.assertEqual(250, advanced_p.health)