Пример #1
0
        public static void performTest(Func <BoardSide, BoardSide, List <HearthstoneBoard>, string> setUp)
        {
            ConsoleColor defaults = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.Yellow;
            HearthstoneBoard        b        = new HearthstoneBoard();
            BoardSide               b1       = new BoardSide();
            BoardSide               b2       = new BoardSide();
            List <HearthstoneBoard> checkers = new List <HearthstoneBoard>();
            string testname = setUp(b1, b2, checkers);

            Console.WriteLine("Starting test: " + testname + "!--------------------------------------------------");
            Console.ForegroundColor = defaults;
            b.p1Board = b1;
            b.p2Board = b2;
            try
            {
                b.printState();
                Console.WriteLine("#####");
                b.printPriority = outputPriority;
                HearthstoneBoard res = b.simulateResults(1)[0];
                Console.WriteLine(testname + " done. Board state: ");
                res.printState();

                foreach (HearthstoneBoard h in checkers)
                {
                    if (res.compare(h))
                    {
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("Test (" + testname + ") passed!!!");
                        Console.WriteLine("----------------------------------------");
                        Console.WriteLine();
                        Console.WriteLine();
                        Console.ForegroundColor = defaults;

                        return;
                    }
                }
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Test (" + testname + ") failed. Board was :");
                res.printState();
                Console.WriteLine("But should be: ");
                checkers[0].printState();
                Console.ForegroundColor = defaults;
                Console.ReadLine();
            }
            catch (ExceptionWithMessageWhyDoesntCSharpHaveItDeafaultComeOne e)
            {
                Console.WriteLine("An error occured when performing test " + testname + ". Message: " + e.message);
                Console.ReadLine();
            }
        }