public void TestInstallAndExecuteSharpRemote() { var watchdog = new SharpRemote.Watchdog.Watchdog(CreateWatchdog()); InstalledApplication app; using (IApplicationInstaller installer = watchdog.StartInstallation(SharpRemote("0.1"))) { DeploySharpRemote(installer); app = installer.Commit(); } app.Should().NotBeNull(); // Let's verify that the deployment actually worked... VerifyPostSharpDeployment(app); // Now that SharpRemote is deployed we can start an actual instance... var instance = new ApplicationInstanceDescription { ApplicationName = app.Name, Executable = app.Files.First(x => x.Filename.EndsWith("SampleBrowser.exe")), Name = "Test Host" }; watchdog.RegisterApplicationInstance(instance); // Due to the watchdog being executed on the same computer, we expect // the process to be running now... IsBrowserRunning().Should().BeTrue(); }
public void TestHotUpdate1() { var watchdog = new SharpRemote.Watchdog.Watchdog(CreateWatchdog()); InstalledApplication app; ApplicationDescriptor desc = SharpRemote("0.7"); using (IApplicationInstaller installer = watchdog.StartInstallation(desc)) { DeploySharpRemote(installer); app = installer.Commit(); } // Let's start a browser application to ensure that some files from the update are now in use... ApplicationInstanceDescription instance = CreateBrowserInstance(app); watchdog.RegisterApplicationInstance(instance); IsBrowserRunning().Should().BeTrue(); // Performing a cold update should be possible because it kills the app(s) first.. using (IApplicationInstaller installer = watchdog.StartInstallation(desc, Installation.HotUpdate)) { IsBrowserRunning().Should().BeTrue("because the update shouldn't kill any instance"); string browser = Path.Combine(SharpRemoteFolder, "SampleBrowser.exe"); installer.AddFile(browser, Environment.SpecialFolder.LocalApplicationData); InstallationFailedException exception = null; try { installer.Commit(); } catch (InstallationFailedException e) { exception = e; } exception.Should().NotBeNull(); exception.Message.Should().Be("Application of 'SharpRemote 0.7' failed"); var inner = exception.InnerException; (inner is IOException || inner is UnauthorizedAccessException).Should().BeTrue(); } }
public void TestColdUpdate2() { var watchdog = new SharpRemote.Watchdog.Watchdog(CreateWatchdog()); InstalledApplication app, update; ApplicationDescriptor desc = SharpRemote("0.6"); using (IApplicationInstaller installer = watchdog.StartInstallation(desc)) { DeploySharpRemote(installer); app = installer.Commit(); } // Let's start a browser application to ensure that some files from the update are now in use... ApplicationInstanceDescription instance = CreateBrowserInstance(app); watchdog.RegisterApplicationInstance(instance); IsBrowserRunning().Should().BeTrue(); // Performing a cold update should be possible because it kills the app(s) first.. using (IApplicationInstaller installer = watchdog.StartInstallation(desc, Installation.ColdUpdate)) { IsBrowserRunning().Should().BeFalse("because the update needed to kill the browser"); string pdb = Path.Combine(SharpRemoteFolder, "SharpRemote.dll"); installer.AddFile(pdb, Environment.SpecialFolder.LocalApplicationData); string browser = Path.Combine(SharpRemoteFolder, "SampleBrowser.exe"); installer.AddFile(browser, Environment.SpecialFolder.LocalApplicationData); update = installer.Commit(); IsBrowserRunning() .Should() .BeTrue("because after the update's finished all application instances should be running again"); } // The update shouldn't have written new files, not even their file sizes should've changed... app.Files.Should().BeEquivalentTo(update.Files); }