/// <summary>
        ///     Initializes a new instance of the <see cref="MainWindow" /> class.
        /// </summary>
        public MainWindow()
        {
            this.InitializeComponent();

            if (File.Exists(MinesweeperGameController.PlayersFilename))
            {
                this.players =
                    MinesweeperGameData.Load<List<MinesweeperPlayer>>(MinesweeperGameController.PlayersFilename);
            }
            else
            {
                this.players = new List<MinesweeperPlayer>();
            }

            this.view = new WpfView(this.WinesweeperGrid);
            this.Width = 240;
            this.Height = 340;
            this.gameController =
                new MinesweeperGameController(
                    MinesweeperGridFactory.CreateNewTable(MinesweeperDifficultyType.Easy),
                    this.view,
                    new WpfTimer(new DispatcherTimer(), new TimeSpan(0, 0, 1)),
                    this.players,
                    MinesweeperDifficultyType.Easy);
        }
        public void TestGameOverShouldBeShown()
        {
            MainWindow mainWindow = new MainWindow();
            WpfView view = new WpfView(mainWindow.WinesweeperGrid);

            view.DisplayGameOver(false);
            view.DisplayGameOver(true);
        }
        public void TestViewCreation()
        {
            WpfView view = new WpfView(mainWindow.WinesweeperGrid);

            Assert.AreNotEqual(null, view, "View is created");
        }
        public void TestIncorrectTime()
        {
            WpfView view = new WpfView(mainWindow.WinesweeperGrid);
            Label timeLabel = (Label)mainWindow.WinesweeperGrid.FindName("TimeLabel");

            Stopwatch sw = Stopwatch.StartNew();
            Thread.Sleep(3000);
            sw.Stop();

            int timePassed = sw.Elapsed.Seconds;

            view.DisplayTime(timePassed);

            Assert.AreNotEqual("001", timeLabel.Content, "Incorrect time is shown");
        }
        public void TestCorrectTime()
        {
            WpfView view = new WpfView(mainWindow.WinesweeperGrid);
            Label timeLabel = (Label)mainWindow.WinesweeperGrid.FindName("TimeLabel");

            Stopwatch sw = Stopwatch.StartNew();
            Thread.Sleep(2250); //A little bit over two seconds because of offset between Thread.Sleep and Stopwatch
            sw.Stop();

            int timePassed = sw.Elapsed.Seconds;

            view.DisplayTime(timePassed);

            Assert.AreEqual("002", timeLabel.Content, "Correct time is shown");
        }
 /// <summary>
 /// The menu item_ new medium game_ click.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// The click event.
 /// </param>
 private void MenuItemNewMediumGameClick(object sender, RoutedEventArgs e)
 {
     this.Width = 380;
     this.Height = 480;
     this.view = new WpfView(this.WinesweeperGrid);
     this.gameController =
         new MinesweeperGameController(
             MinesweeperGridFactory.CreateNewTable(MinesweeperDifficultyType.Medium),
             this.view,
             new WpfTimer(new DispatcherTimer(), new TimeSpan(0, 0, 1)),
             this.players,
             MinesweeperDifficultyType.Medium);
 }