def test_if_attacker_is_dead_should_raise_error(self):
     attacker = Beginner("Simo")
     enemy = Advanced('Dimo')
     attacker.health = 0
     with self.assertRaises(ValueError) as cm:
         self.battlefield.fight(attacker, enemy)
     self.assertEqual(str(cm.exception), "Player is dead!")
Exemplo n.º 2
0
 def test_fight_with_enemy_is_dead(self):
     a = Beginner('A')
     e = Beginner('A')
     e.health = 0
     with self.assertRaises(ValueError) as ex:
         self.b.fight(a, e)
     self.assertEqual(str(ex.exception), "Player is dead!")
Exemplo n.º 3
0
 def test_is_dead(self):
     a = Beginner("Test")
     self.assertEqual(a.health, INITIAL_HEALTH)
     self.assertFalse(a.is_dead)
     a.health = 0
     self.assertEqual(a.health, 0)
     self.assertTrue(a.is_dead)
Exemplo n.º 4
0
 def test_fight_any_is_dead(self):
     p1 = Beginner('One')
     p2 = Beginner('Two')
     p1.health = 0
     with self.assertRaises(ValueError) as ex:
         self.bf.fight(p1, p2)
     self.assertEqual(str(ex.exception), "Player is dead!")
Exemplo n.º 5
0
 def test_fight_with_dead_player_should_raise_error(self):
     bf = BattleField()
     p1 = Beginner("Peter")
     p2 = Beginner("George")
     p1.health = 0
     with self.assertRaises(ValueError) as cm:
         bf.fight(p1, p2)
     self.assertEqual(str(cm.exception), "Player is dead!")
    def test_if_one_from_the_players_is_dead_should_raise_error(self):
        attacker = Advanced('Thor')
        enemy = Beginner('War-Machine')

        enemy.health = 0

        with self.assertRaises(ValueError) as cm:
            self.battlefield.fight(attacker, enemy)
        self.assertEqual(str(cm.exception), "Player is dead!")
Exemplo n.º 7
0
    def test_fight__when_enemy_is_dead__expect_to_raise_exception(self):
        attacker = Beginner('Pesho')
        enemy = Beginner('Gosho')
        enemy.health = 0

        with self.assertRaises(ValueError) as context:
            self.battle_field.fight(attacker, enemy)
        expect = 'Player is dead!'
        actual = str(context.exception)

        self.assertEqual(expect, actual)
Exemplo n.º 8
0
 def test_helth_increase_beforo_fight_with_helth_of_card(self):
     a = Beginner('A')
     e = Advanced('AA')
     a.health = 1000
     # d- 120, h-5
     c_a = TrapCard('TrapCard')
     c_e = TrapCard('TrapCard')
     a.card_repository.cards.append(c_a)
     e.card_repository.cards.append(c_e)
     self.b.fight(a, e)
     self.assertEqual(sum(i.damage_points for i in a.card_repository.cards),
                      150)
     self.assertEqual(sum(i.damage_points for i in e.card_repository.cards),
                      120)
     self.assertEqual(a.health, 925)
     self.assertFalse(a.is_dead)
     self.assertFalse(e.is_dead)
 def test_is_dead_return_True_when_health_less_than_0(self):
     beginner = Beginner('test')
     beginner.health = 0
     self.assertEqual(beginner.is_dead, True)
    def test_health_raise_exemption_when_lower_than_0(self):
        with self.assertRaises(Exception) as ex:
            beginner = Beginner('test')
            beginner.health = -5

        self.assertIsNotNone(ex.exception)
Exemplo n.º 11
0
 def test_is_dead(self):
     advanced = Beginner("test")
     self.assertFalse(advanced.is_dead)
     advanced.health = 0
     self.assertTrue(advanced.is_dead)
Exemplo n.º 12
0
 def test_is_dead_returns_true(self):
     player = Beginner("Peter")
     player.health = 0
     self.assertTrue(player.is_dead)
Exemplo n.º 13
0
 def test_set_health_success(self):
     player = Beginner("Peter")
     player.health = 10
     self.assertEqual(player.health, 10)
Exemplo n.º 14
0
 def test_is_dead(self):
     beginner = Beginner("test")
     self.assertFalse(beginner.is_dead)
     beginner.health = 0
     self.assertTrue(beginner.is_dead)
Exemplo n.º 15
0
 def test_health_raises(self):
     beginner = Beginner("test")
     with self.assertRaises(ValueError) as ex:
         beginner.health = -2
         self.assertEqual(str(ex.exception), "Player's health bonus cannot be less than zero.")
Exemplo n.º 16
0
 def test_is_dead(self):
     beg = Beginner('test')
     self.assertFalse(beg.health <= 0)
     beg.health = 0
     self.assertTrue(beg.health <= 0)
Exemplo n.º 17
0
 def test_health_setter(self):
     beg = Beginner('test')
     beg.health = 100
     self.assertEqual(100, beg.health)
Exemplo n.º 18
0
    def test_health_invalid_data_should_raise_error(self):
        player = Beginner("Dave")

        with self.assertRaises(ValueError):
            player.health = -10
Exemplo n.º 19
0
    def test_health_valid_data_should_work_correctly(self):
        player = Beginner("Dave")

        player.health = 50

        self.assertEqual(player.health, 50)
Exemplo n.º 20
0
 def test_health_raises_value_error(self):
     beginner = Beginner('John')
     with self.assertRaises(ValueError) as context_manager:
         beginner.health = -1
     self.assertEqual('Player\'s health bonus cannot be less than zero.', str(context_manager.exception))
Exemplo n.º 21
0
 def test_take_health_more_then_zero(self):
     a = Beginner("test")
     a.health = 20
     self.assertEqual(a.health, 20)
Exemplo n.º 22
0
 def test_helath_is_less_then_zero_return_raises(self):
     a = Beginner('test')
     with self.assertRaises(ValueError) as ex:
         a.health = -10
     self.assertEqual(str(ex.exception),
                      'Player\'s health bonus cannot be less than zero.')
Exemplo n.º 23
0
 def test_set_health_negative_value_raises(self):
     a = Beginner("Test")
     with self.assertRaises(ValueError):
         a.health = -10