/// <summary>
        /// The button_ click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The click event.
        /// </param>
        private void CellButtonClick(object sender, RoutedEventArgs e)
        {
            if ((sender as WpfMinesweeperButton) == null)
            {
                throw new NullReferenceException("No object given!");
            }

            var args = new MinesweeperCellClickEventArgs
                           {
                               Row = ((WpfMinesweeperButton)sender).Row,
                               Col = ((WpfMinesweeperButton)sender).Col
                           };

            this.lastCol = args.Col;
            this.lastRow = args.Row;

            if (this.OpenCellEvent != null)
            {
                this.OpenCellEvent.Invoke(this, args);
            }
        }
        public void TestControllerOnTickEventShouldDisplayGrid()
        {
            var grid = this.GridMock();
            var view = this.ViewMock();
            var timer = this.TimerMock();
            var players = new List<MinesweeperPlayer>();
            var controller = new MinesweeperGameController(
                grid.Object,
                view.Object,
                timer.Object,
                players,
                MinesweeperDifficultyType.Easy);
            var args = new MinesweeperCellClickEventArgs { Row = 1, Col = 1 };
            this.isGridDisplayed = false;

            this.isScoreBoardDisplayed = false;
            view.Raise(e => e.OpenCellEvent += null, args);
            view.Raise(e => e.ProtectCellEvent += null, args);
            timer.Raise(e => e.TickEvent += null, EventArgs.Empty);

            Assert.AreEqual(this.isGridDisplayed, true, "Grid not displayed!");
        }
        /// <summary>
        /// The button on mouse right button up.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="mouseButtonEventArgs">
        /// The mouse button event args.
        /// </param>
        private void ButtonOnMouseRightButtonUp(object sender, MouseButtonEventArgs mouseButtonEventArgs)
        {
            if ((sender as WpfMinesweeperButton) == null)
            {
                throw new NullReferenceException("No object given!");
            }

            var args = new MinesweeperCellClickEventArgs
                           {
                               Row = ((WpfMinesweeperButton)sender).Row,
                               Col = ((WpfMinesweeperButton)sender).Col
                           };

            this.lastCol = args.Col;
            this.lastRow = args.Row;

            if (this.ProtectCellEvent != null)
            {
                this.ProtectCellEvent.Invoke(this, args);
            }
        }
        /// <summary>
        /// The print grid.
        /// </summary>
        /// <param name="output">
        /// The output.
        /// </param>
        /// <param name="box">
        /// The console box.
        /// </param>
        /// <param name="openCellEvent">
        /// The open cell event.
        /// </param>
        /// <param name="protectCellEvent">
        /// The protect cell event.
        /// </param>
        public static void PrintGrid(
            IConsoleWrapper<ConsoleColor, ConsoleKeyInfo> output, 
            IConsoleBox<ConsoleColor> box, 
            EventHandler openCellEvent, 
            EventHandler protectCellEvent)
        {
            Print(output, box);

            var x = box.StartX + 1;
            var y = box.StartY + 1;

            output.CursorVisible = true;
            output.CursorSize = 100;
            output.SetCursorPosition(x, y);

            ConsoleKeyInfo key;

            do
            {
                key = output.ReadKey(true);

                if (key.Key == ConsoleKey.RightArrow)
                {
                    if (x < box.StartX + box.SizeX - 1)
                    {
                        x += 1;
                    }
                }

                if (key.Key == ConsoleKey.DownArrow)
                {
                    if (y < box.StartY + box.SizeY - 1)
                    {
                        y += 1;
                    }
                }

                if (key.Key == ConsoleKey.LeftArrow)
                {
                    if (x > box.StartX + 1)
                    {
                        x -= 1;
                    }
                }

                if (key.Key == ConsoleKey.UpArrow)
                {
                    if (y > box.StartY + 1)
                    {
                        y -= 1;
                    }
                }

                if (key.Key == ConsoleKey.Spacebar)
                {
                    var args = new MinesweeperCellClickEventArgs { Row = y - box.StartY - 1, Col = x - box.StartX - 1 };

                    openCellEvent.Invoke(null, args);
                }

                if (key.Key == ConsoleKey.F)
                {
                    var args = new MinesweeperCellClickEventArgs { Row = y - box.StartY - 1, Col = x - box.StartX - 1 };

                    protectCellEvent.Invoke(null, args);
                }

                output.SetCursorPosition(x, y);
            }
            while (key.Key != ConsoleKey.End);
        }