public void CheckOpenedPlayerTest() { MainWindow_Accessor target = new MainWindow_Accessor(); // TODO: Initialize to an appropriate value int expected = 0; // TODO: Initialize to an appropriate value int actual; actual = target.CheckOpenedPlayer(); Assert.AreEqual(1, actual); Process.Start("C:\\Program Files (x86)\\Windows Media Player\\wmplayer.exe"); System.Threading.Thread.Sleep(1000); actual = target.CheckOpenedPlayer(); Assert.AreEqual(expected, actual); //Assert.Inconclusive("Verify the correctness of this test method."); }
public void CheckOpenedPlayerTest() { MainWindow_Accessor target = new MainWindow_Accessor(); int playerRunning = 0, playerNotRunning = 1; int actual; Stopwatch sw = new Stopwatch(); long elapsed = 0; // Run CheckOpenPlayer() without any running WMP instances actual = target.CheckOpenedPlayer(); Assert.AreEqual(playerNotRunning, actual); //Runs an instance of WMP to check if CheckOpenedPlayer can detect it Process wmp = setupProc(); // run media player sw.Start(); while (wmp.MainWindowHandle == IntPtr.Zero) // spin until media player window appears { elapsed = sw.ElapsedMilliseconds; if (elapsed > 2000) { break; // break spin if waited for more than 2 seconds } } sw.Stop(); actual = target.CheckOpenedPlayer(); wmp.Kill(); Assert.AreEqual(playerRunning, actual); }
public void CheckOpenedPlayerTest() { MainWindow_Accessor target = new MainWindow_Accessor(); int playerRunning = 0, playerNotRunning = 1; int actual; // Run CheckOpenPlayer() without any running WMP instances actual = target.CheckOpenedPlayer(); Assert.AreEqual(playerNotRunning, actual); //Runs an instance of WMP to check if CheckOpenedPlayer can detect it Process wmp = setupProc(); System.Threading.Thread.Sleep(1000); actual = target.CheckOpenedPlayer(); Assert.AreEqual(playerRunning, actual); ControlFunction.Execute(Parameter.play); System.Threading.Thread.Sleep(1000); Console.Out.WriteLine("process ID: " + wmp.Id); wmp.Kill(); }