def test_downward_diagonal_win(self): x_token = XToken() grid = Grid(3, 3) grid_controller = GridController() grid_controller.assign_grid(grid) grid.add_token_position(x_token, 0, 0) grid.add_token_position(x_token, 1, 1) grid.add_token_position(x_token, 2, 2) winner = grid_controller.check_for_win() assert winner == x_token
def test_upward_diagonal_win(self): o_token = OToken() grid = Grid(3, 3) grid_controller = GridController() grid_controller.assign_grid(grid) grid.add_token_position(o_token, 0, 2) grid.add_token_position(o_token, 1, 1) grid.add_token_position(o_token, 2, 0) winner = grid_controller.check_for_win() assert winner == o_token
def test_horizontal_win(self): x_token = XToken() grid = Grid(3, 3) grid_controller = GridController() grid_controller.assign_grid(grid) grid.add_token_position(x_token, 0, 0) grid.add_token_position(x_token, 0, 1) grid.add_token_position(x_token, 0, 2) winner = grid_controller.check_for_win() assert winner == x_token
def test_no_winner_board_full(self): x_token = XToken() o_token = OToken() grid = Grid(3, 3) grid_controller = GridController() grid_controller.assign_grid(grid) grid.add_token_position(x_token, 0, 0) grid.add_token_position(x_token, 0, 1) grid.add_token_position(x_token, 1, 2) grid.add_token_position(x_token, 2, 0) grid.add_token_position(x_token, 2, 1) grid.add_token_position(o_token, 0, 2) grid.add_token_position(o_token, 1, 0) grid.add_token_position(o_token, 1, 1) grid.add_token_position(o_token, 2, 2) winner = grid_controller.check_for_win() assert winner is None assert grid_controller.grid_is_full()