public async Task RunningUpgradeAppTwiceDoesntCrash()
        {
            string tempDir;
            string remotePkgDir;

            using (Utility.WithTempDirectory(out tempDir))
                using (Utility.WithTempDirectory(out remotePkgDir)) {
                    IntegrationTestHelper.CreateFakeInstalledApp("0.1.0", remotePkgDir);
                    var pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir);
                    ReleaseEntry.WriteReleaseFile(pkgs, Path.Combine(remotePkgDir, "RELEASES"));

                    using (var fixture = new UpdateManager(remotePkgDir, "theApp", tempDir)) {
                        await fixture.FullInstall();
                    }

                    await Task.Delay(1000);

                    IntegrationTestHelper.CreateFakeInstalledApp("0.2.0", remotePkgDir);
                    pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir);
                    ReleaseEntry.WriteReleaseFile(pkgs, Path.Combine(remotePkgDir, "RELEASES"));

                    using (var fixture = new UpdateManager(remotePkgDir, "theApp", tempDir)) {
                        await fixture.UpdateApp();
                    }

                    await Task.Delay(1000);

                    // NB: The 2nd time we won't have any updates to apply. We should just do nothing!
                    using (var fixture = new UpdateManager(remotePkgDir, "theApp", tempDir)) {
                        await fixture.UpdateApp();
                    }

                    await Task.Delay(1000);
                }
        }
        public async Task CleanInstallRunsSquirrelAwareAppsWithInstallFlag()
        {
            string tempDir;
            string remotePkgDir;

            using (Utility.WithTempDirectory(out tempDir))
                using (Utility.WithTempDirectory(out remotePkgDir)) {
                    IntegrationTestHelper.CreateFakeInstalledApp("0.1.0", remotePkgDir);
                    var pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir);
                    ReleaseEntry.WriteReleaseFile(pkgs, Path.Combine(remotePkgDir, "RELEASES"));

                    using (var fixture = new UpdateManager(remotePkgDir, "theApp", tempDir)) {
                        await fixture.FullInstall();

                        // NB: We execute the Squirrel-aware apps, so we need to give
                        // them a minute to settle or else the using statement will
                        // try to blow away a running process
                        await Task.Delay(1000);

                        Assert.False(File.Exists(Path.Combine(tempDir, "theApp", "app-0.1.0", "args2.txt")));
                        Assert.True(File.Exists(Path.Combine(tempDir, "theApp", "app-0.1.0", "args.txt")));

                        var text = File.ReadAllText(Path.Combine(tempDir, "theApp", "app-0.1.0", "args.txt"), Encoding.UTF8);
                        Assert.Contains("firstrun", text);
                    }
                }
        }
        public async Task UpgradeRunsSquirrelAwareAppsWithUpgradeFlag()
        {
            string tempDir;
            string remotePkgDir;

            using (Utility.WithTempDirectory(out tempDir))
                using (Utility.WithTempDirectory(out remotePkgDir)) {
                    IntegrationTestHelper.CreateFakeInstalledApp("0.1.0", remotePkgDir);
                    var pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir);
                    ReleaseEntry.WriteReleaseFile(pkgs, Path.Combine(remotePkgDir, "RELEASES"));

                    using (var fixture = new UpdateManager(remotePkgDir, "theApp", tempDir)) {
                        await fixture.FullInstall();
                    }

                    await Task.Delay(1000);

                    IntegrationTestHelper.CreateFakeInstalledApp("0.2.0", remotePkgDir);
                    pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir);
                    ReleaseEntry.WriteReleaseFile(pkgs, Path.Combine(remotePkgDir, "RELEASES"));

                    using (var fixture = new UpdateManager(remotePkgDir, "theApp", tempDir)) {
                        await fixture.UpdateApp();
                    }

                    await Task.Delay(1000);

                    Assert.False(File.Exists(Path.Combine(tempDir, "theApp", "app-0.2.0", "args2.txt")));
                    Assert.True(File.Exists(Path.Combine(tempDir, "theApp", "app-0.2.0", "args.txt")));

                    var text = File.ReadAllText(Path.Combine(tempDir, "theApp", "app-0.2.0", "args.txt"), Encoding.UTF8);
                    Assert.Contains("updated|0.2.0", text);
                }
        }
            public async Task CallingMethodTwiceShouldUpdateInstaller()
            {
                string remotePkgPath;
                string path;

                using (Utility.WithTempDirectory(out path)) {
                    using (Utility.WithTempDirectory(out remotePkgPath))
                        using (var mgr = new UpdateManager(remotePkgPath, "theApp", path)) {
                            IntegrationTestHelper.CreateFakeInstalledApp("1.0.0.1", remotePkgPath);
                            await mgr.FullInstall(false, new ProgressSource());
                        }

                    using (var mgr = new UpdateManager("http://lol", "theApp", path)) {
                        await mgr.CreateUninstallerRegistryEntry();

                        var regKey = await mgr.CreateUninstallerRegistryEntry();

                        Assert.False(String.IsNullOrWhiteSpace((string)regKey.GetValue("DisplayName")));

                        mgr.RemoveUninstallerRegistryEntry();
                    }

                    // NB: Squirrel-Aware first-run might still be running, slow
                    // our roll before blowing away the temp path
                    Thread.Sleep(1000);
                }

                var key = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default)
                          .OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall");

                using (key) {
                    Assert.False(key.GetSubKeyNames().Contains("theApp"));
                }
            }
Example #5
0
        public void CreateFakePackageSmokeTest()
        {
            string path;

            using (Utility.WithTempDirectory(out path)) {
                var output = IntegrationTestHelper.CreateFakeInstalledApp("0.3.0", path);
                Assert.True(File.Exists(output));
            }
        }
        public async Task GetShortcutsSmokeTest()
        {
            string remotePkgPath;
            string path;

            using (Utility.WithTempDirectory(out path)) {
                using (Utility.WithTempDirectory(out remotePkgPath))
                    using (var mgr = new UpdateManager(remotePkgPath, "theApp", path)) {
                        IntegrationTestHelper.CreateFakeInstalledApp("1.0.0.1", remotePkgPath);
                        await mgr.FullInstall();
                    }

                var fixture = new UpdateManager.ApplyReleasesImpl(Path.Combine(path, "theApp"));
                var result  = fixture.GetShortcutsForExecutable("SquirrelAwareApp.exe", ShortcutLocation.Desktop | ShortcutLocation.StartMenu | ShortcutLocation.Startup, null);

                Assert.Equal(3, result.Keys.Count);

                // NB: Squirrel-Aware first-run might still be running, slow
                // our roll before blowing away the temp path
                Thread.Sleep(1000);
            }
        }
        public async Task CreateShortcutsRoundTrip()
        {
            string remotePkgPath;
            string path;

            using (Utility.WithTempDirectory(out path)) {
                using (Utility.WithTempDirectory(out remotePkgPath))
                    using (var mgr = new UpdateManager(remotePkgPath, "theApp", path)) {
                        IntegrationTestHelper.CreateFakeInstalledApp("1.0.0.1", remotePkgPath);
                        await mgr.FullInstall();
                    }

                var fixture = new UpdateManager.ApplyReleasesImpl(Path.Combine(path, "theApp"));
                fixture.CreateShortcutsForExecutable("SquirrelAwareApp.exe", ShortcutLocation.Desktop | ShortcutLocation.StartMenu | ShortcutLocation.Startup | ShortcutLocation.AppRoot, false, null, null);

                // NB: COM is Weird.
                Thread.Sleep(1000);
                fixture.RemoveShortcutsForExecutable("SquirrelAwareApp.exe", ShortcutLocation.Desktop | ShortcutLocation.StartMenu | ShortcutLocation.Startup | ShortcutLocation.AppRoot);

                // NB: Squirrel-Aware first-run might still be running, slow
                // our roll before blowing away the temp path
                Thread.Sleep(1000);
            }
        }
        public async Task FullUninstallRemovesAllVersions()
        {
            string tempDir;
            string remotePkgDir;

            using (Utility.WithTempDirectory(out tempDir))
                using (Utility.WithTempDirectory(out remotePkgDir)) {
                    IntegrationTestHelper.CreateFakeInstalledApp("0.1.0", remotePkgDir);
                    var pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir);
                    ReleaseEntry.WriteReleaseFile(pkgs, Path.Combine(remotePkgDir, "RELEASES"));

                    using (var fixture = new UpdateManager(remotePkgDir, "theApp", tempDir)) {
                        await fixture.FullInstall();
                    }

                    await Task.Delay(1000);

                    IntegrationTestHelper.CreateFakeInstalledApp("0.2.0", remotePkgDir);
                    pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir);
                    ReleaseEntry.WriteReleaseFile(pkgs, Path.Combine(remotePkgDir, "RELEASES"));

                    using (var fixture = new UpdateManager(remotePkgDir, "theApp", tempDir)) {
                        await fixture.UpdateApp();
                    }

                    await Task.Delay(1000);

                    using (var fixture = new UpdateManager(remotePkgDir, "theApp", tempDir)) {
                        await fixture.FullUninstall();
                    }

                    Assert.False(File.Exists(Path.Combine(tempDir, "theApp", "app-0.1.0", "args.txt")));
                    Assert.False(File.Exists(Path.Combine(tempDir, "theApp", "app-0.2.0", "args.txt")));
                    Assert.True(File.Exists(Path.Combine(tempDir, "theApp", "app-0.2.0", ".dead")));
                }
        }