public void AllSteps() { var update = new Update(); update.PropertyChanged += Update_PropertyChanged; var assembly = Assembly.GetExecutingAssembly(); var version = assembly.GetName().Version; var tempDir = Path.Combine(Path.GetTempPath(), nameof(AutoUpdateViaGitHubRelease)); Stopwatch time = Stopwatch.StartNew(); var newVersion = update.CheckDownloadNewVersionAsync(GitHubApiTest.User , GitHubApiTest.Repo, version, tempDir); Assert.IsFalse(update.Available); var gitHub = new GitHubApi(); var latestReleaseJson = gitHub.GetLatestReleaseJSONAsync(GitHubApiTest.User , GitHubApiTest.Repo).Result; var latestVersion = GitHubApi.ParseVersion(latestReleaseJson); Assert.AreEqual(newVersion.Result, update.Available); Assert.AreEqual(update.Available, version < latestVersion); if (update.Available) { var destinationDir = Path.Combine(tempDir, "install"); var installProcess = update.StartInstall(destinationDir); installProcess.WaitForExit(); Assert.AreEqual(0, installProcess.ExitCode); } }
public void ParseVersion() { var gitHub = new GitHubApi(); var task = Task.Run(() => gitHub.GetLatestReleaseJSONAsync(User, Repo)); var json = task.Result; var version = GitHubApi.ParseVersion(json); Assert.AreNotEqual(0, version.Build); }
public void CheckDownloadNewVersionAssembly() { string tempDir = TempDir(); Directory.CreateDirectory(tempDir); var destFile = Path.Combine(tempDir, "Update.zip"); var assembly = Assembly.GetExecutingAssembly(); var downloadOk = UpdateTools.CheckDownloadNewVersionAsync(GitHubApiTest.User , GitHubApiTest.Repo, assembly, destFile).Result; var version = assembly.GetName().Version; var gitHub = new GitHubApi(); var latestReleaseJson = gitHub.GetLatestReleaseJSONAsync(GitHubApiTest.User , GitHubApiTest.Repo).Result; var latestVersion = GitHubApi.ParseVersion(latestReleaseJson); Assert.AreEqual(downloadOk, version < latestVersion); if (downloadOk) { Assert.IsTrue(File.Exists(destFile)); } Directory.Delete(tempDir, true); }