示例#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);
        }
示例#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);
        }
示例#3
0
        public void RepeatedMethodCallDoNotChangeBehaviour()
        {
            var board       = BoardParser.ParseBoardByLines(_testBoardLines);
            var chesProblem = new ChessProblem(board);

            Assert.AreEqual(ChessStatus.Check, chesProblem.CalculateChessStatus());

            // Now check that internal board modifications during the first call do not change answer
            Assert.AreEqual(ChessStatus.Check, chesProblem.CalculateChessStatus());
        }
        private void TestOnFile(string filename)
        {
            Board board = parser.ParseBoard(File.ReadAllLines(filename));

            chessProblem = new ChessProblem(board);
            var expectedAnswer = File.ReadAllText(Path.ChangeExtension(filename, ".ans")).Trim();

            chessProblem.CalculateChessStatus(PieceColor.White);
            Assert.AreEqual(expectedAnswer, chessProblem.ChessStatus.ToString().ToLower(), "Failed test " + filename);
        }
示例#5
0
        private static void TestOnFile(string filename)
        {
            var boardLines  = File.ReadAllLines(filename);
            var board       = BoardParser.ParseBoardByLines(boardLines);
            var chesProblem = new ChessProblem(board);

            var expectedAnswer = File.ReadAllText(Path.ChangeExtension(filename, ".ans")).Trim();
            var resultStatus   = chesProblem.CalculateChessStatus();

            Assert.AreEqual(expectedAnswer, resultStatus.ToString().ToLower(), "Failed test " + filename);
        }
示例#6
0
        private static void TestOnFile(string filename)
        {
            var lines = File.ReadAllLines(filename);
            var board = new BoardParser().ParseBoard(lines);

            var ch             = new ChessProblem(board);
            var expectedAnswer = File.ReadAllText(Path.ChangeExtension(filename, ".ans")).Trim();

            ch.GetChessStatusFor(PieceColor.White);
            Assert.AreEqual(expectedAnswer, ch.GetChessStatusFor(PieceColor.White).ToString().ToLower(), "Failed test " + filename);
        }
示例#7
0
        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);
        }
示例#8
0
        public void RepeatedMethodCallDoNotChangeBehaviour()
        {
            var lines = new[]
            {
                "        ",
                "        ",
                "        ",
                "   q    ",
                "    K   ",
                " Q      ",
                "        ",
                "        ",
            };
            var board = new BoardParser().ParseBoard(lines);
            var ch    = new ChessProblem(board);

            Assert.AreEqual(ChessStatus.Check, ch.GetChessStatusFor(PieceColor.White));

            // Now check that internal board modifictions during the first call do not change answer
            ch.GetChessStatusFor(PieceColor.White);
            Assert.AreEqual(ChessStatus.Check, ch.GetChessStatusFor(PieceColor.White));
        }
示例#9
0