public void TestColdUpdate1() { var watchdog = new SharpRemote.Watchdog.Watchdog(CreateWatchdog()); InstalledApplication app, update; ApplicationDescriptor desc = SharpRemote("0.5"); using (IApplicationInstaller installer = watchdog.StartInstallation(desc)) { DeploySharpRemote(installer); app = installer.Commit(); } // Let's try patching the pdb... using (IApplicationInstaller installer = watchdog.StartInstallation(desc, Installation.ColdUpdate)) { string pdb = Path.Combine(SharpRemoteFolder, "SharpRemote.pdb"); installer.AddFile(pdb, Environment.SpecialFolder.LocalApplicationData); update = installer.Commit(); } // The update should consists of all files from the first installation *AND* the pdb // we installed as an update update.Files.Count.Should().Be(app.Files.Count + 1); List <InstalledFile> updated = update.Files.Except(app.Files).ToList(); updated.Count.Should().Be(1); updated[0].Filename.Should().Be("SharpRemote.pdb"); updated[0].Folder.Should().Be(Environment.SpecialFolder.LocalApplicationData); updated[0].Id.Should().Be(4); }
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); }
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(); } }