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"); }