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

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

            Assert.AreEqual(0, db.Games.Count);
        }
Exemple #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();
        }
Exemple #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));
        }
Exemple #5
0
        public void ReadFromFile_should_return_a_Database()
        {
            var parser = new PgnReader();

            PrepareFile("test.pgn", NormalGame);
            Assert.IsType <Database>(parser.ReadFromFile("test.pgn"));
        }
Exemple #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);
        }
Exemple #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);

        }
        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);
            }
        }
Exemple #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));
        }
Exemple #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());
        }
Exemple #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));
        }
Exemple #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);
        }
Exemple #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));
 }
Exemple #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));
 }
Exemple #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));
        }
Exemple #16
0
        static Database ReadPgn(string fileName)
        {
            var reader = new PgnReader();

            return(reader.ReadFromFile(fileName));
        }