Ejemplo n.º 1
0
            public void InsertPieceTests()
            {
                // Note this is raw manipulation of the string, not logic, i.e. inserting a piece
                // with this method does not have side effects like updating the move counts or
                // castling rights
                //"r3r1k1/p2b1ppp/1p1q1n2/3p4/2P5/3BRN1P/PP1Q1PP1/R5K1 w - - 0 19";
                string expandedFEN = "r111r1k1/p11b1ppp/1p1q1n11/111p1111/11P11111/111BRN1P/PP1Q1PP1/R11111K1 w - - 0 19";

                // +---+---+---+---+---+---+---+---+
                // | r |   |   |   | r |   | k |   |
                // +---+---+---+---+---+---+---+---+
                // | p |   |   | b |   | p | p | p |
                // +---+---+---+---+---+---+---+---+
                // |   | p |   | q |   | n |   |   |
                // +---+---+---+---+---+---+---+---+
                // |   |   |   | p |   |   |   |   |
                // +---+---+---+---+---+---+---+---+
                // |   |   | P |   |   |   |   |   |
                // +---+---+---+---+---+---+---+---+
                // |   |   |   | B | R | N |   | P |
                // +---+---+---+---+---+---+---+---+
                // | P | P |   | Q |   | P | P |   |
                // +---+---+---+---+---+---+---+---+
                // | R |   |   |   |   |   | K |   |
                // +---+---+---+---+---+---+---+---+

                // Piece, file, rank, expected
                Tuple <char, int, int, string>[] testData =
                {
                    new Tuple <char, int, int, string>('Q', 3, 1, "r111r1k1/p11b1ppp/1p1q1n11/111p1111/11P11111/111BRN1P/PP1Q1PP1/R1Q111K1 w - - 0 19"),
                    new Tuple <char, int, int, string>('P', 2, 8, "rP11r1k1/p11b1ppp/1p1q1n11/111p1111/11P11111/111BRN1P/PP1Q1PP1/R11111K1 w - - 0 19"),
                    new Tuple <char, int, int, string>('b', 5, 5, "r111r1k1/p11b1ppp/1p1q1n11/111pb111/11P11111/111BRN1P/PP1Q1PP1/R11111K1 w - - 0 19"),
                };

                foreach (Tuple <char, int, int, string> tuple in testData)
                {
                    Trace.WriteLine(String.Format("Verifying piece '{0}' inserted at [{1}:{2}] => {3}", tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4));
                    Assert.IsTrue(String.Compare(FenParser.InsertPiece(expandedFEN, tuple.Item1, tuple.Item2, tuple.Item3), tuple.Item4) == 0);
                }
            }