예제 #1
0
        private async Task PerformManualUpdate(string appName, string expectedVersion)
        {
            Window updateNowMsgBox = await WindowHelpers
                                     .WaitForWindowAsync(x => x.Equals($"{appName} update installation"), TimeSpan.FromMinutes(1))
                                     .ConfigureAwait(false);

            this.CheckProperUpdateVersionDownloadedInMessageBox(updateNowMsgBox, expectedVersion);

            WindowHelpers.ClickButtonByText(updateNowMsgBox, "Yes");

            Log("Clicked yes");
            Window updater = await WindowHelpers
                             .WaitForWindowAsync(x => x.Contains($"{appName} Updater"), TimeSpan.FromMinutes(1))
                             .ConfigureAwait(false);

            WindowHelpers.ClickButtonByText(updater, "Install now!");

            Log("Clicked Install now!");

            Window doneMsg = await WindowHelpers.WaitForMessageBoxAsync(updater, "Update complete", TimeSpan.FromMinutes(1))
                             .ConfigureAwait(false);

            WindowHelpers.ClickButtonByText(doneMsg, "Yes");

            Log("Clicked yes");
        }
        public async Task _01_HandlePackageUpdates_NonBeta()
        {
            try
            {
                var stamp = DateTime.UtcNow;

                this.LaunchPackageUpdaterTestsAppWithArgs(out FileInfo appFile, Apps.PackageNames.PackageUpdaterTestAppV1, SharedTestHelpers.GetMethodName(), waitForExit: false);
                Window updateNowMsgBox =
                    await WindowHelpers.WaitForWindowAsync(x => x.Equals("PackageTriggerUpdaterTestApp update download"), TimeSpan.FromMinutes(1)).ConfigureAwait(false);

                WindowHelpers.ClickButtonByText(updateNowMsgBox, "Yes");

                Log("Clicked yes");

                var appDir = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
                var _      = await GetExecutionSummaryFile(appDir, "Executed", stamp).ConfigureAwait(false);

                var finishedFile = await GetExecutionSummaryFile(appDir, "Finished", stamp).ConfigureAwait(false);

                var finishedLines = File.ReadAllLines(finishedFile.FullName);

                Assert.AreEqual("Killed other processes: True", finishedLines[1]);

                //do not check if app was updated, because we only care whether the updater was actually launched
            }
            catch (Exception ex)
            {
                this.CleanupAndLog(ex);
                throw;
            }
        }
        public async Task _03_CheckAndInstallUpdates_NonBeta()
        {
            try
            {
                VersionTuple initialVersions    = this.GetVersionsFromExtractedAppFile(Apps.PackageNames.AutomaticTestsClientAppV1, SharedTestHelpers.GetMethodName(), out FileInfo appFile);
                var          installationResult = this.LaunchTestsAppAndGetResult <UpdateInstallationResult>(appFile, Actions.CheckAndInstallUpdates, Apps.Keys.AutomaticTestsClient, waitForExit: false);

                if (installationResult?.Exception != null)
                {
                    throw installationResult.Exception;
                }

                Window updater = await WindowHelpers.WaitForWindowAsync(x => x.Contains("AutomaticTestsClient Updater"), TimeSpan.FromMinutes(1)).ConfigureAwait(false);

                this.CheckProperUpdateVersionDownloadedInUpdater(updater, "2.");
                WindowHelpers.ClickButtonByText(updater, "Install now!");

                Log("Clicked Install now!");

                Window doneMsg = await WindowHelpers.WaitForMessageBoxAsync(updater, "Update complete", TimeSpan.FromMinutes(1)).ConfigureAwait(false);

                WindowHelpers.ClickButtonByText(doneMsg, "Yes");
                Log("Clicked yes");

                VersionTuple newVersions = this.GetVersionsFromApp(appFile);
                Log($"New versions: {newVersions.ToLog()}");

                this.AssertVersionAreCorrect(newVersions, initialVersions, appFile, "2.");

                //now just assert that the update check result is empty next time
                Log("Checking update info is false");

                UpdateCheckResult result = this.LaunchTestsAppAndGetResult <UpdateCheckResult>(appFile, Actions.CheckAndInstallUpdates, Apps.Keys.AutomaticTestsClient, waitForExit: true);
                this.AssertNoNonBetaUpdatesToInstall(result, true);
            }
            catch (Exception ex)
            {
                this.CleanupAndLog(ex);
                throw;
            }
        }
        public async Task _04_MsiCheckAndInstallUpdates()
        {
            this.ProductCodesTest_InstallersTestAppMsi3(); //sanity check to save time
            try
            {
                this.UninstallPackages(Apps.ProductCodes.InstallersTestAppMsi3V1, Apps.ProductCodes.InstallersTestAppMsi3V2);

                VersionTuple initialVersions = this.GetVersionsFromMsiApp(Apps.PackageNames.InstallersTestAppMsi3V1, Apps.Paths.InstallersTestAppMsi3, Apps.ProductCodes.InstallersTestAppMsi3V1);
                Log("Read initial versions");

                UpdateCheckResult result = this.LaunchTestsAppAndGetResult <UpdateCheckResult>(Apps.Paths.InstallersTestAppMsi3, Actions.CheckAndInstallUpdates, Apps.Keys.InstallersTestAppMsi3);
                Assert.IsNull(result.Exception);
                Window updater = await WindowHelpers.WaitForWindowAsync(x => x.Equals("InstallersTestApp.Msi3Installer"), TimeSpan.FromMinutes(1), "msiexec").ConfigureAwait(false);

                var dialog = updater.ModalWindows.First();
                WindowHelpers.ClickButtonByText(dialog, "OK");

                Log("Clicked OK");


                this.VerifyVersionsAreUpdatedAfterInstallation(initialVersions);


                //now just assert that the update check result is empty next time
                Log("Checking update info is false");
                result = this.LaunchTestsAppAndGetResult <UpdateCheckResult>(Apps.Paths.InstallersTestAppMsi3, Actions.CheckAndInstallUpdates, Apps.Keys.InstallersTestAppMsi3);

                this.AssertNoNonBetaUpdatesToInstall(result, false);

                this.UninstallPackages(Apps.ProductCodes.InstallersTestAppMsi3V1, Apps.ProductCodes.InstallersTestAppMsi3V2);
            }
            catch (Exception ex)
            {
                this.CleanupAndLog(ex);
                throw;
            }
        }