def test_dont_move_left_when_rotating_at_right_side_isnt_possible(self): self.create_tetromino_type_I() util.control_tetromino(self.tetromino, "DDDSSSS") self.board.add_tetromino(self.tetromino) self.create_tetromino_type_I() util.control_tetromino(self.tetromino, "DDDDDDSSSS") self.assertFalse(util.control_tetromino(self.tetromino, "W"))
def test_cant_rotate(self): self.create_tetromino_type_I() util.control_tetromino(self.tetromino, "DDSSSS") self.board.add_tetromino(self.tetromino) self.create_tetromino_type_T() util.control_tetromino(self.tetromino, "WSSS") self.assertFalse(util.control_tetromino(self.tetromino, "W"))
def add_test_data(self): # ..... # ....# # .#.## # .#### tetromino = Tetromino(3, self.board) util.control_tetromino(tetromino, "WWWDSS") self.board.add_tetromino(tetromino) tetromino = Tetromino(6, self.board) util.control_tetromino(tetromino, "WWDDWDS") self.board.add_tetromino(tetromino)
def test_remove_multiple_full_rows(self): self.add_test_data() self.board.remove_full_rows(0, 4) tetromino = Tetromino(6, self.board) util.control_tetromino(tetromino, "DS") self.board.add_tetromino(tetromino) tetromino = Tetromino(1, self.board) self.board.add_tetromino(tetromino) self.board.remove_full_rows(0, 4) util.check_board_state(self, self.board, [".....", ".....", ".....", "#...."])
def test_invalid_tetromino_move_inside_used_board(self): self.add_test_data() tetromino = Tetromino(0, self.board) self.assertFalse(util.control_tetromino(tetromino, "S")) self.assertFalse(util.control_tetromino(tetromino, "DDD"))
def test_moving_tetromino_outside_board_box(self): tetromino = Tetromino(0, self.board) self.assertFalse(util.control_tetromino(tetromino, "A")) self.assertFalse(util.control_tetromino(tetromino, "DDDD")) self.assertFalse(util.control_tetromino(tetromino, "SSS"))
def test_moving_tetromino_inside_empty_board(self): tetromino = Tetromino(0, self.board) self.assertTrue(util.control_tetromino(tetromino, "DADDDSAADSDAD"))
def test_move_left(self): self.create_tetromino_type_T() self.tetromino.move_to_initial_pos() util.control_tetromino(self.tetromino, "A") position = self.tetromino.position self.assertEqual(position, Point(1, 0))
def test_move_left_when_rotating_at_right_side(self): self.create_tetromino_type_I() util.control_tetromino(self.tetromino, "DDDDD") self.assertEqual(self.tetromino.position, Point(5, 0)) util.control_tetromino(self.tetromino, "W") self.assertEqual(self.tetromino.position, Point(3, 0))