Exemplo n.º 1
0
        public void BidTest()
        {
            var bidManager = new BidManager();
            var pbn        = new Pbn();

            foreach (var pbnFile in Directory.GetFiles("..\\..\\..\\..\\Wpf.BidTrainer\\Pbn", "*.pbn"))
            {
                pbn.Load(pbnFile);
                foreach (var board in pbn.Boards)
                {
                    board.Auction = bidManager.GetAuction(board.Deal, board.Dealer);
                }

                var filePath = $"{pbnFile}.{DateTime.Now.ToShortDateString()}";
                pbn.Save(filePath);
                Assert.Equal(File.ReadAllText($"{pbnFile}.etalon"), File.ReadAllText(filePath));
            }
        }
Exemplo n.º 2
0
        private static void ExecuteAndCompare(string path, string filename)
        {
            var filePath       = Path.Combine(path, filename);
            var filePathActual = Path.Combine(path, $"{Path.GetFileNameWithoutExtension(filename)}_1.pbn");
            var pbn            = new Pbn();

            pbn.Load(filePath);
            pbn.Save(filePathActual);

            var expected = File.ReadAllLines(filePath).Select(x => x.Trim()).Select(x => Regex.Replace(Regex.Replace(x, " =[0-9]= ", "\t"), " {2,}", "\t"));
            var actual   = File.ReadAllLines(filePathActual);

            foreach (var line in actual)
            {
                if (!string.IsNullOrWhiteSpace(line))
                {
                    Assert.Contains(line, expected);
                }
            }
        }