def test_zombies_on_the_screen(self): # Assign settings = Settings() zombie = Zombie(settings) # zombie.moving_right = True zombie.rect.right = 550 zombie.screen_rect.right = 500 settings.fleet_direction = -1 # Act zombie.ZombiesOnTheScreen() # Assert self.assertTrue(settings.fleet_direction == 1)
def test_init_score_position(self): # Requirement ID: 4.0.1 """Displays the current score""" # Assign pygame.init() settings = Settings() stats = Stats(settings) display = PointsDisplay(settings, stats) display.stats.score = 5 display.text_color = settings.supernova font = pygame.font.SysFont("freesan", 42) display.stats.score = 5 display.score_rect.top = 40 display.score_rect.right = 40 score_str = "{:,}".format(display.stats.score) display.score_image = font.render(score_str, True, display.text_color, display.text_color) # Act display.InitScore() # Assert self.assertTrue(display.score_rect.top == 20 and display.score_rect.right == 1180)
def test_bullets_on_the_screen(self): # Assign settings = Settings() shooter = Shooter(settings) bullet = Bullet(settings, shooter) settings.bullet_color = settings.green bullet.circle.x = 500 bullet.circle.y = 500 bullet.bullet_size = 20 # Act bullet.Draw() # Assert self.assertTrue(bullet.bullet_color == (0, 0, 0) and bullet.circle.x == 500 and bullet.circle.y == 500 and bullet.bullet_size == 20)
def test_rotate(self): # Assign settings = Settings() shooter = Shooter(settings) rotate = 45 # Act shooter.Rotate(rotate) #Assert self.assertTrue(shooter.facing_angle == 45)
def test_center_shooter(self): # Assign settings = Settings() shooter = Shooter(settings) shooter.centerx = 5 shooter.centery = 5 #Act shooter.CenterShooter() # Assert self.assertTrue(shooter.centerx == 600 and shooter.bottom == 600)
def test_init_play_display(self): # Requirement ID: 3.0.1 # Assign pygame.init() settings = Settings() playbutton = PlayButton(settings) msg = "test play button" # Act playbutton.PlayDisplay(settings, msg) # Assert self.assertTrue(playbutton.settings.msg == "Play")
def test_center_zombies(self): # Assign settings = Settings() zombie = Zombie(settings) zombie.centerx = 5 zombie.centery = 5 #Act zombie.CenterZombie() # Assert self.assertTrue(zombie.center == 600)
def test_shooter_update(self): # Assign settings = Settings() shooter = Shooter(settings) shooter.moving_right = True shooter.rect.centerx = 550 shooter.rect.bottom = 500 # Act shooter.update() self.assertTrue(shooter.rect.centerx == 615 and shooter.rect.bottom == 580)
def test_init_score_lives(self): # Requirement ID: 4.0.4 """Displays the shooter lives. Display one image per life remaining.""" # Assign pygame.init() settings = Settings() stats = Stats(settings) display = PointsDisplay(settings, stats) display.stats.lives = 5 # Act display.InitScore() # Assert self.assertTrue(display.stats.lives == 5)
def test_init_score_bullets(self): # Requirement ID: 4.0.3 """Displays the number of bullets remaining """ # Assign pygame.init() settings = Settings() stats = Stats(settings) display = PointsDisplay(settings, stats) display.stats.remaining_bullets = 5 # Act display.InitScore() # Assert self.assertTrue(display.stats.remaining_bullets == 5)
def test_init_score_level(self): # Requirement ID: 4.0.2 """Displays the current level""" # Assign pygame.init() settings = Settings() stats = Stats(settings) display = PointsDisplay(settings, stats) display.stats.level = 5 # Act display.InitScore() # Assert self.assertTrue(display.stats.level == 5)
def test_update(self): # Assign settings = Settings() shooter = Shooter(settings) bullet = Bullet(settings, shooter) bullet.circle.x = 500 bullet.circle.y = 500 shooter.rect.top = 500 bullet.pos = [500, 500] #Act bullet.update() # Assert self.assertTrue(bullet.circle.x == 500 and bullet.circle.y == 481)
def test_init_score_color(self): # Requirement ID: 4.0.1 """Displays the current score""" # Assign pygame.init() settings = Settings() stats = Stats(settings) display = PointsDisplay(settings, stats) display.stats.score = 5 display.text_color = (5, 5, 5) self.font = pygame.font.SysFont("freesan", 42) display.stats.score = 5 #Act display.InitScore() # Assert self.assertTrue(display.text_color == (5, 5, 5))