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 ShouldStartUpApplicationOnRequest()
        {
            var launcher = new ApplicationLauncher();
            var app      = launcher.Launch(EXAMPLE_APP_PATH, s => Assert.Fail("Should have launched the app"));

            app.FindWindow(EXAMPLE_APP_WINDOW_NAME);
            Assert.IsNotNull(app.Process);
        }
        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);
        }
        public void ShouldComplainIfTheApplicationCantBeLaunched()
        {
            var launcher = new ApplicationLauncher();
            var complained = false;
            launcher.Launch("Wibble.exe", s => complained = true);
            Assert.True(complained, "Launcher should have complained because the app could not be launched");

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

            launcher.Launch("Wibble.exe", s => complained = true);
            Assert.True(complained, "Launcher should have complained because the app could not be launched");

            complained = false;
            launcher.LaunchOrRecycle("Wibble", "Wibble.exe", s => complained = true);
            Assert.True(complained, "Launcher should have complained because the app could not be launched");
        }
        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 ShouldStartUpApplicationOnRequest()
 {
     var launcher = new ApplicationLauncher();
     var app = launcher.Launch(EXAMPLE_APP_PATH, s => Assert.Fail("Should have launched the app"));
     app.FindWindow(EXAMPLE_APP_WINDOW_NAME);
     Assert.IsNotNull(app.Process);
 }