Ejemplo n.º 1
0
            public void PieceAtBoardPositionTests()
            {
                //"r1bq1rk1/pp3ppp/3b1n2/3pN3/8/3B4/PPPN1PPP/R1BQ1RK1 b - - 0 11";
                // This method assumes the FEN is already expanded on the correct rank, so just expand the
                // whole thing for the tests.  Expansion has its own tests.
                string expandedFEN = "r1bq1rk1/pp111ppp/111b1n11/111pN111/11111111/111B1111/PPPN1PPP/R1BQ1RK1 b - - 0 11";

                // Board position (WHITE IS UPPERCASE)
                // +---+---+---+---+---+---+---+---+
                // | r |   | b | q |   | r | k |   |
                // +---+---+---+---+---+---+---+---+
                // | p | p |   |   |   | p | p | p |
                // +---+---+---+---+---+---+---+---+
                // |   |   |   | b |   | n |   |   |
                // +---+---+---+---+---+---+---+---+
                // |   |   |   | p | N |   |   |   |
                // +---+---+---+---+---+---+---+---+
                // |   |   |   |   |   |   |   |   |
                // +---+---+---+---+---+---+---+---+
                // |   |   |   | B |   |   |   |   |
                // +---+---+---+---+---+---+---+---+
                // | P | P | P | N |   | P | P | P |
                // +---+---+---+---+---+---+---+---+
                // | R |   | B | Q |   | R | K |   |
                // +---+---+---+---+---+---+---+---+

                // File, Rank, Expected
                Tuple <int, int, char>[] testData =
                {
                    new Tuple <int, int, char>(1, 1, 'R'),
                    new Tuple <int, int, char>(3, 1, 'B'),
                    new Tuple <int, int, char>(4, 1, 'Q'),
                    new Tuple <int, int, char>(6, 1, 'R'),
                    new Tuple <int, int, char>(7, 1, 'K'),
                    new Tuple <int, int, char>(1, 2, 'P'),
                    new Tuple <int, int, char>(2, 2, 'P'),
                    new Tuple <int, int, char>(3, 2, 'P'),
                    new Tuple <int, int, char>(4, 2, 'N'),
                    new Tuple <int, int, char>(5, 2, '1'), // Empty space since expanded
                    new Tuple <int, int, char>(6, 2, 'P'),
                    new Tuple <int, int, char>(7, 2, 'P'),
                    new Tuple <int, int, char>(8, 2, 'P'),
                    new Tuple <int, int, char>(4, 3, 'B'),
                    new Tuple <int, int, char>(4, 5, 'p'),
                    new Tuple <int, int, char>(5, 5, 'N'),
                    new Tuple <int, int, char>(4, 6, 'b'),
                    new Tuple <int, int, char>(6, 6, 'n'),
                    new Tuple <int, int, char>(1, 8, 'r'),
                    new Tuple <int, int, char>(8, 8, '1'),
                };

                foreach (Tuple <int, int, char> tuple in testData)
                {
                    Trace.WriteLine(String.Format("Veriying {0} found at [{1}:{2}]", tuple.Item3, tuple.Item1, tuple.Item2));
                    Assert.AreEqual(tuple.Item3, FenParser.PieceAtBoardPosition(expandedFEN, tuple.Item1, tuple.Item2));
                }
            }