Esempio n. 1
0
        private static void TestOnFile(string filename)
        {
            var board = File.ReadAllLines(filename);

            ChessProblem.LoadFrom(board);
            var expectedAnswer = File.ReadAllText(Path.ChangeExtension(filename, ".ans")).Trim();
            var status         = ChessProblem.GetChessStatus();

            Assert.AreEqual(expectedAnswer, status.ToString().ToLower(), "Failed test " + filename);
        }
Esempio n. 2
0
        public void RepeatedMethodCallDoNotChangeBehaviour()
        {
            var board = new[]
            {
                "        ",
                "        ",
                "        ",
                "   q    ",
                "    K   ",
                " Q      ",
                "        ",
                "        ",
            };

            ChessProblem.LoadFrom(board);
            var status = ChessProblem.GetChessStatus();

            Assert.AreEqual(ChessStatus.Check, status);

            // Now check that internal board modifictions during the first call do not change answer
            var status2 = ChessProblem.GetChessStatus();

            Assert.AreEqual(ChessStatus.Check, status2);
        }