public void IsLatestRelease_BadVersion_ThrowsException() { var settings = new ReleaseDownloaderSettings(Author, Repo, true, _downloadDirPath); _downloader = new ReleaseDownloader(settings, _httpClient); Assert.Throws <Exception>(() => _downloader.IsLatestRelease("bad-version")); }
public void IsLatestRelease_IsLatestPR_ReturnsTrue() { var settings = new ReleaseDownloaderSettings(Author, Repo, true, _downloadDirPath); _downloader = new ReleaseDownloader(settings, _httpClient); Assert.IsTrue(_downloader.IsLatestRelease("6.0.53")); }
public void IsLatestRelease_OtherAPIError_ThrowsException() { var settings = new ReleaseDownloaderSettings(Author, "OTHER-ERROR", true, _downloadDirPath); _downloader = new ReleaseDownloader(settings, _httpClient); Assert.Throws <AggregateException>(() => _downloader.IsLatestRelease("5.0.0")); }
public void IsLatestRelease_BadRepo_ThrowsException() { var settings = new ReleaseDownloaderSettings(Author, "BAD-REPO", true, _downloadDirPath); _downloader = new ReleaseDownloader(settings, _httpClient); Assert.Throws <AggregateException>(() => _downloader.IsLatestRelease("5.0.0")); }
public void IsLatestRelease_RateLimit_ThrowsException() { var settings = new ReleaseDownloaderSettings(Author, "RATE-LIMITED", true, _downloadDirPath); _downloader = new ReleaseDownloader(settings, _httpClient); Assert.Throws <AggregateException>(() => _downloader.IsLatestRelease("5.0.0")); }
public void IsLatestRelease_IsNotLatestNoPR_ReturnsFalse() { var settings = new ReleaseDownloaderSettings(Author, Repo, false, _downloadDirPath); _downloader = new ReleaseDownloader(settings, _httpClient); Assert.IsFalse(_downloader.IsLatestRelease("6.0.29")); }
public void IsLatestRelease_IsLatestNoPR_ReturnsTrue() { var settings = new ReleaseDownloaderSettings(_httpClient, Author, Repo, false, _downloadDirPath); _downloader = new ReleaseDownloader(settings); Assert.IsTrue(_downloader.IsLatestRelease("6.0.30")); }
public void IsLatestRelease_IsNotLatestPR_ReturnsFalse() { var settings = new ReleaseDownloaderSettings(_httpClient, Author, Repo, true, _downloadDirPath); _downloader = new ReleaseDownloader(settings); Assert.IsFalse(_downloader.IsLatestRelease("5.0.0")); }
public void DownloadLatestRelease_ReturnsTrue() { var settings = new ReleaseDownloaderSettings(Author, Repo, true, _downloadDirPath); _downloader = new ReleaseDownloader(settings, _httpClient); Directory.CreateDirectory(_downloadDirPath); _downloader.DownloadLatestRelease(); }
public void DeInit_RemovesAgentHeader() { var settings = new ReleaseDownloaderSettings(Author, Repo, true, _downloadDirPath); _downloader = new ReleaseDownloader(settings, _httpClient); _downloader.DeInit(); Assert.IsEmpty(_httpClient.DefaultRequestHeaders.UserAgent); }
public void DownloadLatestRelease_IT_ReturnsTrue() { var httpClient = new HttpClient(); var settings = new ReleaseDownloaderSettings(Author, Repo, true, _downloadDirPath); _downloader = new ReleaseDownloader(settings, httpClient); Assert.IsTrue(_downloader.DownloadLatestRelease().Count > 0); httpClient.Dispose(); }
public void IsLatestRelease_IT_ReturnsTrue() { var httpClient = new HttpClient(); var settings = new ReleaseDownloaderSettings(Author, Repo, false, _downloadDirPath); _downloader = new ReleaseDownloader(settings, httpClient); Assert.IsTrue(_downloader.IsLatestRelease("6.0.30")); httpClient.Dispose(); }
private void btn_Download_Click(object sender, EventArgs e) { DialogResult result = fbd.ShowDialog(); if (result != DialogResult.OK) { return; } try { progressBar1.Enabled = true; progressBar1.Visible = true; // Create Setting Object IReleaseDownloaderSettings settings = new ReleaseDownloaderSettings(this.txt_User.Text, this.txt_Repository.Text, this.chk_IncludePreRelease.Checked, fbd.SelectedPath, this.txt_PAT.Text); // Create Downloader downloader = new ReleaseDownloader(settings) { // Fix DeadLock IsConfigureAwait = false }; // Check Exist User if (!downloader.IsExistUser(this.txt_User.Text)) { MessageBox.Show("User does not exist."); return; } // Check Exist Repository of User if (!downloader.IsExistRepository(this.txt_User.Text, this.txt_Repository.Text)) { MessageBox.Show("Repository does not exist."); return; } //downloader.SetPAT("a"); // Check Version bool isMostRecentVersion = downloader.IsLatestRelease("0.1.0.0"); // Download Latest Github Release if (!isMostRecentVersion) { //var version = downloader.GetRelease("0.2.0.0"); //downloader.DownloadRelease(version.Key); //downloader.DownloadLatestReleaseAsset("ac"); var last = downloader.DownloadLatestRelease(); } } catch (Exception ex) { MessageBox.Show($"[Error] {ex.Message}"); } finally { progressBar1.Enabled = false; progressBar1.Visible = false; } }
private void CheckUpdatesAndContinues() { HttpClient httpClient = new HttpClient(); string author = "ZombieRage"; string repo = "zRageMapDownloader"; bool includePreRelease = false; IReleaseDownloaderSettings settings = new ReleaseDownloaderSettings(httpClient, author, repo, includePreRelease, Utils.APP_PATH); // create downloader IReleaseDownloader downloader = new ReleaseDownloader(settings); // check version DispatchIfNecessary(() => { txtMessage.Text = "Checking for updates..."; }); string currentVersion = GetVersionKeyInfo(); bool installNewVersion = !string.IsNullOrEmpty(currentVersion) ? !downloader.IsLatestRelease(currentVersion) : true; if (installNewVersion || !File.Exists(Utils.APP_FILE)) { DispatchIfNecessary(() => { Visibility = Visibility.Visible; txtMessage.Text = "Downloading lastest version..."; }); downloader.DownloadLatestRelease(); var downloadedVersion = downloader.GetLatestReleaseVersion(); UpdateVersionKeyInfo(downloadedVersion); RegisterCustomUrlScheme(); } if (File.Exists(Utils.APP_FILE)) { DispatchIfNecessary(() => { txtMessage.Text = "Starting application..."; pbProgress.IsIndeterminate = false; pbProgress.Value = 1; }); ProcessStartInfo psi = new ProcessStartInfo(Utils.APP_FILE); Process.Start(psi); } else { DispatchIfNecessary(() => { MessageBox.Show("Application not found", "Error", MessageBoxButton.OK, MessageBoxImage.Error); }); } // clean up downloader.DeInit(); httpClient.Dispose(); DispatchIfNecessary(() => { Application.Current.Shutdown(); }); }