Esempio n. 1
0
 public void Test()
 {
     int testsCount = 0;
     foreach (var file in Directory.GetFiles("ChessTests"))
     {
         if (Path.GetExtension(file) != string.Empty) continue;
         using (var f = File.OpenText(file))
         {
             var chess = new Chess(f);
             Console.WriteLine("Loaded " + file);
             var expectedAnswer = File.ReadAllText(file + ".ans").Trim();
             chess.Solve();
             Assert.AreEqual(expectedAnswer, chess.Solve(), "error in file " + file);
         }
         testsCount++;
     }
     Console.WriteLine("Tests count: " + testsCount);
 }
Esempio n. 2
0
        public void Test()
        {
            var chess = new Chess();
            int testsCount = 0;
            foreach (var fileName in Directory.GetFiles("ChessTests"))
            {
                if (Path.GetExtension(fileName) != string.Empty) continue;
                using (var file = File.OpenText(fileName))
                {
                    var board = ChessBoardLoader.LoadFromStream(file);

                    Console.WriteLine("Loaded " + fileName);
                    var expectedAnswer = File.ReadAllText(fileName + ".ans").Trim();
                    Assert.AreEqual(expectedAnswer, chess.GetWhiteKingStatus(board), "error in file " + fileName);
                }
                testsCount++;
            }
            Console.WriteLine("Tests count: " + testsCount);
        }