-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_bonus.py
58 lines (49 loc) · 1.85 KB
/
test_bonus.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import copy
import unittest
import bonus
import Assets
import player
import pygame.math as pgm
from level_info import LevelInfo
class TestBonus(unittest.TestCase):
class GameForTest:
def __init__(self,
screen_width, screen_height,
textures, audio,
is_audio_on, count):
self.screen_width = screen_width
self.screen_height = screen_height
self.textures = textures
self.audio = audio
self.is_audio_on = is_audio_on
self.count = count
self.asteroids = []
self.saucers = []
self.level_info = LevelInfo(1, 1, 1, 1, 1, 1, 1, self)
self.bonuses = []
self.player = player.Player(self)
self.double_score = 0
def setUp(self):
self.game = self.GameForTest(800, 800,
Assets.Textures(), Assets.Audio(),
False, 0)
self.bonus = bonus.Bonus(self.game,
pgm.Vector2(0, 0), pgm.Vector2(1, 0))
def testMove(self):
init_position = copy.copy(self.bonus.position)
self.bonus.move(self.game)
self.assertNotEqual(init_position, self.bonus.position)
def testLifeBonus(self):
init_lives = self.game.player.lives
self.bonus.life_bonus(self.game)
self.assertGreater(self.game.player.lives, init_lives)
def testShieldBonus(self):
init_shield = self.game.player.shield
self.bonus.shield_bonus(self.game)
self.assertGreater(self.game.player.shield, init_shield)
def testDoubleScore(self):
init_score = self.game.double_score
self.bonus.score_bonus(self.game)
self.assertGreater(self.game.double_score, init_score)
if __name__ == '__main__':
unittest.main()