Beispiel #1
0
        public void RepeatedMethodCallDoNotChangeBehaviour()
        {
            var boardLines = new[]
            {
                "        ",
                "        ",
                "        ",
                "   q    ",
                "    K   ",
                " Q      ",
                "        ",
                "        ",
            };

            ChessProblem chessProblem = new ChessProblem();

            //var board = new BoardParser().ParseBoard(boardLines);
            chessProblem.LoadFrom(boardLines);
            chessProblem.CalculateChessStatus(PieceColor.White);
            Assert.AreEqual(ChessStatus.Check, chessProblem.ChessStatus);

            // Now check that internal board modifications during the first call do not change answer
            chessProblem.CalculateChessStatus(PieceColor.White);
            Assert.AreEqual(ChessStatus.Check, chessProblem.ChessStatus);
        }
Beispiel #2
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.CalculateChessStatus();

            Assert.AreEqual(expectedAnswer, status.ToString().ToLower(), "Failed test " + filename);
        }
Beispiel #3
0
        private static void TestOnFile(string filename)
        {
            var chessProblem = new ChessProblem();
            var boardLines   = File.ReadAllLines(filename);

            chessProblem.LoadFrom(boardLines);
            //var board = new BoardParser().ParseBoard(boardLines);
            var expectedAnswer = File.ReadAllText(Path.ChangeExtension(filename, ".ans")).Trim();

            chessProblem.CalculateChessStatus(PieceColor.White);
            Assert.AreEqual(expectedAnswer, chessProblem.ChessStatus.ToString().ToLower(), "Failed test " + filename);
        }
        public void RepeatedMethodCallDoNotChangeBehaviour()
        {
            var boardLines = new[]
            {
                "        ",
                "        ",
                "        ",
                "   q    ",
                "    K   ",
                " Q      ",
                "        ",
                "        ",
            };

            ChessProblem.LoadFrom(boardLines);
            ChessProblem.CalculateChessStatus();
            Assert.AreEqual(ChessStatus.Check, ChessProblem.ChessStatus);

            // Now check that internal board modifications during the first call do not change answer
            ChessProblem.CalculateChessStatus();
            Assert.AreEqual(ChessStatus.Check, ChessProblem.ChessStatus);
        }