public static IEnumerable <TestCaseData> GetCastlingMoves(Color color, Move move) { const string emptyFenWhiteToMove = "4k3/8/8/8/8/8/8/4K3 w - - 0 1"; const string emptyFenBlackToMove = "4k3/8/8/8/8/8/8/4K3 b - - 0 1"; var rookInitialSquareIndex = MoveHelpers.GetRookMoveForCastleMove(move).SourceIndex; var between = BoardHelpers.InBetween(rookInitialSquareIndex, move.SourceIndex); var blockerPermutations = MovingPieceService.GetAllPermutationsOfSetBits(between.GetSetBits(), 0, 0) .Where(x => x != 0); var fen = color == Color.Black ? emptyFenBlackToMove : emptyFenWhiteToMove; var board = fenTextToBoard.Translate(fen); foreach (var permutation in blockerPermutations) { var editedBoard = (Board)board.Clone(); editedBoard.Occupancy[(int)color][(int)Piece.King] = permutation; var strBlockers = string.Join(", ", permutation.GetSetBits()); yield return(new TestCaseData(editedBoard, move) .SetName($"Blockers on indices {strBlockers}") .Returns(MoveError.CastleOccupancyBetween)); } yield return(new TestCaseData(board, move) .SetName("No Blockers") .Returns(MoveError.NoneSet)); }