public void ShouldComplainIfTheApplicationCantBeRecycled()
 {
     var launcher = new ApplicationLauncher();
     var complained = false;
     launcher.Recycle("Wibble.exe", s => complained = true);
     Assert.True(complained, "Launcher should have complained because the app could not be recycled");
 }
        public void ShouldComplainIfTheApplicationCantBeRecycled()
        {
            var launcher   = new ApplicationLauncher();
            var complained = false;

            launcher.Recycle("Wibble.exe", s => complained = true);
            Assert.True(complained, "Launcher should have complained because the app could not be recycled");
        }
        public void ShouldRecycleExistingApplicationIfRequested()
        {
            var launcher    = new ApplicationLauncher();
            var originalApp = launcher.Launch(EXAMPLE_APP_PATH, s => Assert.Fail("Should have launched the app"));

            originalApp.FindWindow(EXAMPLE_APP_WINDOW_NAME);

            var newApp = launcher.Recycle(EXAMPLE_APP_NAME, s => Assert.Fail("Should have launched the app"));

            newApp.FindWindow(EXAMPLE_APP_WINDOW_NAME);

            Assert.AreEqual(originalApp.Process.Id, newApp.Process.Id);
        }
        public void ShouldComplainIfMoreThanOneProcessExistsToRecycle()
        {
            var launcher = new ApplicationLauncher();
            launcher.Launch(EXAMPLE_APP_PATH, s => Assert.Fail("Should have launched the app"))
                .FindWindow(EXAMPLE_APP_WINDOW_NAME);
            launcher.Launch(EXAMPLE_APP_PATH, s => Assert.Fail("Should have launched the app"))
                .FindWindow(EXAMPLE_APP_WINDOW_NAME);

            var complained = false;
            launcher.Recycle(EXAMPLE_APP_NAME, s => complained = true);
            Assert.True(complained, "Launcher should have complained because two apps with the same name exist");

            complained = false;
            launcher.LaunchOrRecycle(EXAMPLE_APP_NAME, EXAMPLE_APP_PATH, s => complained = true);
            Assert.True(complained, "Launcher should have complained because two apps with the same name exist");
        }
        public void ShouldComplainIfMoreThanOneProcessExistsToRecycle()
        {
            var launcher = new ApplicationLauncher();

            launcher.Launch(EXAMPLE_APP_PATH, s => Assert.Fail("Should have launched the app"))
            .FindWindow(EXAMPLE_APP_WINDOW_NAME);
            launcher.Launch(EXAMPLE_APP_PATH, s => Assert.Fail("Should have launched the app"))
            .FindWindow(EXAMPLE_APP_WINDOW_NAME);

            var complained = false;

            launcher.Recycle(EXAMPLE_APP_NAME, s => complained = true);
            Assert.True(complained, "Launcher should have complained because two apps with the same name exist");

            complained = false;
            launcher.LaunchOrRecycle(EXAMPLE_APP_NAME, EXAMPLE_APP_PATH, s => complained = true);
            Assert.True(complained, "Launcher should have complained because two apps with the same name exist");
        }
        public void ShouldRecycleExistingApplicationIfRequested()
        {
            var launcher = new ApplicationLauncher();
            var originalApp = launcher.Launch(EXAMPLE_APP_PATH, s => Assert.Fail("Should have launched the app"));
            originalApp.FindWindow(EXAMPLE_APP_WINDOW_NAME);

            var newApp = launcher.Recycle(EXAMPLE_APP_NAME, s => Assert.Fail("Should have launched the app"));
            newApp.FindWindow(EXAMPLE_APP_WINDOW_NAME);

            Assert.AreEqual(originalApp.Process.Id, newApp.Process.Id);
        }