def test_is_valid_noncontiguous_vertical(self): game = Game() is_valid = game.is_valid_play([ Board.MIDDLE, (Board.MIDDLE[0] + 1, Board.MIDDLE[1]), (Board.MIDDLE[0] + 3, Board.MIDDLE[1]) ], Orientation.VERTICAL) self.assertEqual(is_valid, ValidationReason.NOT_CONTIGUOUS)
def test_is_valid_not_adjacent(self): game = Game() game.board[Board.MIDDLE[0]][Board.MIDDLE[1]] = self.A game.board.is_empty = False is_valid = game.is_valid_play([(Board.MIDDLE[0] + 5, Board.MIDDLE[1])], Orientation.HORIZONTAL) self.assertEqual(is_valid, ValidationReason.NOT_ADJACENT)
def test_is_valid_noncontiguous_horizontal(self): game = Game() is_valid = game.is_valid_play([ Board.MIDDLE, (Board.MIDDLE[0], Board.MIDDLE[1] + 1), (Board.MIDDLE[0], Board.MIDDLE[1] + 3) ], Orientation.HORIZONTAL) self.assertEqual(is_valid, ValidationReason.NOT_CONTIGUOUS)
def test_is_valid_first_play_not_on_middle(self): game = Game() is_valid = game.is_valid_play([(Board.MIDDLE[0], Board.MIDDLE[1] + 1), (Board.MIDDLE[0], Board.MIDDLE[1] + 2)], Orientation.HORIZONTAL) self.assertEqual(is_valid, ValidationReason.FIRST_PLAY_NOT_ON_MIDDLE_CELL)
def test_is_valid_vertical_true(self): game = Game() is_valid = game.is_valid_play([ Board.MIDDLE, (Board.MIDDLE[0] + 1, Board.MIDDLE[1]), (Board.MIDDLE[0] + 2, Board.MIDDLE[1]) ], Orientation.VERTICAL) self.assertEqual(is_valid, ValidationReason.VALID)
def test_is_valid_horizontal_true(self): game = Game() is_valid = game.is_valid_play([ Board.MIDDLE, (Board.MIDDLE[0], Board.MIDDLE[1] + 1), (Board.MIDDLE[0], Board.MIDDLE[1] + 2) ], Orientation.HORIZONTAL) self.assertEqual(is_valid, ValidationReason.VALID)
def test_is_valid_invalid_orientation(self): game = Game() is_valid = game.is_valid_play([ Board.MIDDLE, (Board.MIDDLE[0], Board.MIDDLE[1] + 1), (Board.MIDDLE[0] + 1, Board.MIDDLE[1] + 1) ], Orientation.NONE) self.assertEqual(is_valid, ValidationReason.INVALID_ORIENTATION)
def test_is_valid_prefix_suffix_horizontal(self): game = Game() game.board[Board.MIDDLE[0]][Board.MIDDLE[1]] = self.A game.board.is_empty = False is_valid = game.is_valid_play([(Board.MIDDLE[0], Board.MIDDLE[1] - 1), (Board.MIDDLE[0], Board.MIDDLE[1] + 1)], Orientation.HORIZONTAL) self.assertEqual(is_valid, ValidationReason.VALID)
def test_is_valid_prefix_suffix_vertical(self): game = Game() game.board[Board.MIDDLE[0]][Board.MIDDLE[1]] = self.A game.board.is_empty = False is_valid = game.is_valid_play([(Board.MIDDLE[0] - 1, Board.MIDDLE[1]), (Board.MIDDLE[0] + 1, Board.MIDDLE[1])], Orientation.VERTICAL) self.assertEqual(is_valid, ValidationReason.VALID)
def test_is_valid_cell_full(self): game = Game() game.board[Board.MIDDLE[0]][Board.MIDDLE[1]] = self.A game.board.is_empty = False is_valid = game.is_valid_play([Board.MIDDLE], Orientation.HORIZONTAL) self.assertEqual(is_valid, ValidationReason.CELL_ALREADY_FULL)
def test_is_valid_first_play_too_short(self): game = Game() game.board[Board.MIDDLE[0]][Board.MIDDLE[1]] = self.A is_valid = game.is_valid_play([Board.MIDDLE], Orientation.HORIZONTAL) self.assertEqual(is_valid, ValidationReason.FIRST_PLAY_TOO_FEW_TILES)