示例#1
0
        public void EmptyFile()
        {
            var parser = new PgnReader();
            var db     = parser.ReadFromFile(TestFolder + "empty-file.pgn");

            Assert.Empty(db.Games);
        }
示例#2
0
        public void EmptyFile()
        {
            var parser = new PgnReader();
            var db     = parser.ReadFromFile(TestFolder + "empty-file.pgn");

            Assert.AreEqual(0, db.Games.Count);
        }
示例#3
0
        static void Main(string[] args)
        {
            var reader = new PgnReader();
            var db     = reader.ReadFromFile("Tarrasch.pgn");
            var game   = db.Games[0];

            Console.WriteLine("{0} vs {1} in {2} ({3})", game.WhitePlayer, game.BlackPlayer, game.Site, game.Year);

            if (game.Result == GameResult.White)
            {
                Console.WriteLine("\nWhite wins in {0} moves.", game.MoveText.FullMoveCount);
            }
            else if (game.Result == GameResult.Black)
            {
                Console.WriteLine("\nBlack wins in {0} moves.", game.MoveText.FullMoveCount);
            }
            else if (game.Result == GameResult.Draw)
            {
                Console.WriteLine("\nGame ends in a draw.");
            }
            else
            {
                Console.WriteLine("\nGame not unfinshed.");
            }

            Console.WriteLine();
            Console.WriteLine("Press any key to exit.");

            Console.ReadKey();
        }
示例#4
0
        public void ReadFromFile_should_return_a_Database()
        {
            var parser = new PgnReader();

            PrepareFile("test.pgn", NormalGame);
            Assert.IsInstanceOfType(parser.ReadFromFile("test.pgn"), typeof(Database));
        }
示例#5
0
        public void ReadFromFile_should_return_a_Database()
        {
            var parser = new PgnReader();

            PrepareFile("test.pgn", NormalGame);
            Assert.IsType <Database>(parser.ReadFromFile("test.pgn"));
        }
示例#6
0
        public void ReadFromFile_should_return_read_game_from_file()
        {
            var parser = new PgnReader();

            PrepareFile("one-game.pgn", NormalGame);
            var db = parser.ReadFromFile("one-game.pgn");

            Assert.AreEqual(1, db.Games.Count);
        }
示例#7
0
        public static Database TestFile(string fileName)
        {
            if (!System.IO.File.Exists(TestFolder + fileName))
                Assert.Inconclusive("Test data not available (" + TestFolder + fileName + ")");

            var parser = new PgnReader();
            return parser.ReadFromFile(TestFolder + fileName);

        }
示例#8
0
        public void Convert(IConversionStrategy strategy, string pgnFilename)
        {
            var      pgnFileReader = new PgnReader();
            Database gameDb        = pgnFileReader.ReadFromFile(pgnFilename);

            foreach (var game in gameDb.Games)
            {
                strategy.ConvertAllFens(game);
            }
        }
示例#9
0
        public static Database TestFile(string fileName)
        {
            if (!System.IO.File.Exists(TestFolder + fileName))
            {
                throw new XunitException("Test data not available (" + TestFolder + fileName + ")");
            }

            var parser = new PgnReader();

            return(parser.ReadFromFile(TestFolder + fileName));
        }
示例#10
0
        public List <Match> LoadFromFile(string filePath)
        {
            var reader = new PgnReader();

            var database = reader.ReadFromFile(filePath);

            return(database
                   .Games
                   .Select(a => ToMatch(a))
                   .ToList());
        }
示例#11
0
        public static Database TestFile(string fileName)
        {
            if (!System.IO.File.Exists(TestFolder + fileName))
            {
                Assert.Inconclusive("Test data not available (" + TestFolder + fileName + ")");
            }

            var parser = new PgnReader();

            return(parser.ReadFromFile(TestFolder + fileName));
        }
示例#12
0
        public void ReadFromFile_should_return_read_game_from_file()
        {
            var parser = new PgnReader();
            PrepareFile("one-game.pgn", NormalGame);
            var db = parser.ReadFromFile("one-game.pgn");

            Assert.AreEqual(1, db.Games.Count);
        }
示例#13
0
 public void ReadFromFile_should_return_a_Database()
 {
     var parser = new PgnReader();
     PrepareFile("test.pgn", NormalGame);
     Assert.IsInstanceOfType(parser.ReadFromFile("test.pgn"), typeof(Database));
 }
示例#14
0
 public void ReadFromFile_should_throw_Exception_if_file_is_not_found()
 {
     var parser = new PgnReader();
     Assert.IsInstanceOfType(parser.ReadFromFile("blub_non-existent.pgn"), typeof(Database));
 }
示例#15
0
        public void ReadFromFile_should_throw_Exception_if_file_is_not_found()
        {
            var parser = new PgnReader();

            Assert.IsInstanceOfType(parser.ReadFromFile("blub_non-existent.pgn"), typeof(Database));
        }
示例#16
0
        static Database ReadPgn(string fileName)
        {
            var reader = new PgnReader();

            return(reader.ReadFromFile(fileName));
        }