// The goal is to verify components which initialize a new game by
            // checking that the required number of pieces have been placed in a
            // manner consistent with the Tzaar game rules. Throws Exception if
            // an incorrect number of pieces appear on the game board at
            // initialization.
            private static void TestBoardInitialization()
            {
                TzaarLogic game = new TzaarLogic();

                int[] blackPieceCount = new int[3];
                int[] whitePieceCount = new int[3];

                // Scan the board and query.
                for (int i = 0; i < 9; i++)
                    for (int j = 0; j < 9; j++)
                    {
                        Stack<TzaarPiece> s = (((TzaarBoard)game.GetGameState().Board).Query(i, j));
                        if (s == null)
                            break;
                        // There must be only one piece at each position on the
                        // board at the start of a new game.
                        if (s.Count != 1)
                            throw new Exception();
                        // First check the color, then increment the respective
                        // piece count.
                        if (s.Peek().Color == TzaarColor.BLACK)
                        {
                            if (s.Peek().GetType() == typeof(TzaarPiece.Tzaar))
                                blackPieceCount[0]++;
                            else if (s.Peek().GetType() == typeof(TzaarPiece.Tzarra))
                                blackPieceCount[1]++;
                            else
                                blackPieceCount[2]++;
                        }
                        else
                        {
                            if (s.Peek().GetType() == typeof(TzaarPiece.Tzaar))
                                whitePieceCount[0]++;
                            else if (s.Peek().GetType() == typeof(TzaarPiece.Tzarra))
                                whitePieceCount[1]++;
                            else
                                whitePieceCount[2]++;
                        }
                    }

                // Check if the piece counts for each player are equal to the
                // required piece counts for a new game, as dictated by the
                // Tzaar game rules.
                if (blackPieceCount[0] != 6 || whitePieceCount[0] != 6)
                    throw new Exception();
                if (blackPieceCount[1] != 9 || whitePieceCount[1] != 9)
                    throw new Exception();
                if (blackPieceCount[2] != 15 || whitePieceCount[2] != 15)
                    throw new Exception();
            }
            // The goal is to verify that a change to the board state in the
            // form of a 'capture' or 'stack' operation results in a correct
            // update to the counts for each piece remaining on the board.
            // Throws Exception if a piece count is inconsistent with the actual
            // game state following the specified operation.
            private static void TestUpdatePieceCount()
            {
                TzaarBoard board = new TzaarBoard(true);
                board.Add(new TzaarPiece.Tzaar(TzaarColor.WHITE), 2, 2);
                board.Add(new TzaarPiece.Tzaar(TzaarColor.BLACK), 2, 3);
                board.Add(new TzaarPiece.Tzaar(TzaarColor.BLACK), 3, 4);
                TzaarGameState state = new TzaarGameState(board);
                TzaarLogic game = new TzaarLogic(state);
                int BlackTzaarCount = ((TzaarBoard)game.GetGameState().Board).BlackTzaarCount;

                game.Move(2, 2, 2, 3);

                // A Black Tzaar was 'captured', so the piece count should be
                // decremented by 1.
                if (BlackTzaarCount - ((TzaarBoard)game.GetGameState().Board).BlackTzaarCount != 1)
                    throw new Exception();
            }