public async Task EnsuresNonNullArguments() { var releasesClient = new ReleasesClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => releasesClient.GetAll(null, "name")); await Assert.ThrowsAsync<ArgumentNullException>(() => releasesClient.GetAll("owner", null)); }
public async Task EnsuresNonNullArguments() { var releasesClient = new ReleasesClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => releasesClient.GetAll(null, "name")); await Assert.ThrowsAsync <ArgumentNullException>(() => releasesClient.GetAll("owner", null)); }
static void Main(string[] args) { var client = new GitHubClient(new ProductHeaderValue("MyAmazingApp")); var user = client.User.Get("zeppaman").Result; var repos = client.Repository.GetAllForUser(user.Login).Result; var apiConnection = new ApiConnection(client.Connection); var releases = new ReleasesClient(apiConnection); foreach (var v in repos) { Console.WriteLine(v.Name); var items = releases.GetAll(v.Id).Result; var relase = client.Repository.Release.GetAll(v.Id); var download = relase.Result[0].Assets[0].DownloadCount; var latest = items[0]; Console.WriteLine( "The latest release is tagged at {0} and is named {1}", latest.TagName, latest.Name); } Console.WriteLine(user.Followers + " folks love the half ogre!"); }
public void RequestsCorrectUrl() { var client = Substitute.For <IApiConnection>(); var releasesClient = new ReleasesClient(client); releasesClient.GetAll("fake", "repo"); client.Received().GetAll <Release>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/releases"), null, "application/vnd.github.v3"); }
public void RequestsCorrectUrl() { var client = Substitute.For<IApiConnection>(); var releasesClient = new ReleasesClient(client); releasesClient.GetAll("fake", "repo"); client.Received().GetAll<Release>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/releases"), null, "application/vnd.github.v3"); }
public async Task RequestsCorrectUrlWithRepositoryId() { var client = Substitute.For<IApiConnection>(); var releasesClient = new ReleasesClient(client); await releasesClient.GetAll(1); client.Received().GetAll<Release>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/releases"), null, "application/vnd.github.v3", Args.ApiOptions); }
public async Task RequestsCorrectUrlWithRepositoryId() { var client = Substitute.For <IApiConnection>(); var releasesClient = new ReleasesClient(client); await releasesClient.GetAll(1); client.Received().GetAll <Release>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/releases"), null, "application/vnd.github.v3", Args.ApiOptions); }
public async Task RequestsCorrectUrlWithApiOptions() { var client = Substitute.For <IApiConnection>(); var releasesClient = new ReleasesClient(client); var options = new ApiOptions { PageSize = 1, PageCount = 1, StartPage = 1 }; await releasesClient.GetAll("fake", "repo", options); client.Received().GetAll <Release>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/releases"), null, "application/vnd.github.v3", options); }
public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions() { var client = Substitute.For<IApiConnection>(); var releasesClient = new ReleasesClient(client); var options = new ApiOptions { PageSize = 1, PageCount = 1, StartPage = 1 }; await releasesClient.GetAll(1, options); client.Received().GetAll<Release>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/releases"), null, "application/vnd.github.v3", options); }
public async void CheckUpdates() { try { System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; var octoApi = new ApiConnection(new Connection(new ProductHeaderValue("WoWmapper"))); var octoRelease = new ReleasesClient(octoApi); var wmReleases = await octoRelease.GetAll("topher-au", "wowmapper"); var latestStable = wmReleases.First(release => release.Prerelease == false); var latestVersion = new Version(latestStable.TagName); var currentVersion = Assembly.GetExecutingAssembly().GetName().Version; if (latestVersion > currentVersion) { _latest = latestStable; TextUpdateStatus1.Text = $"Version {latestVersion} is available now!"; TextUpdateStatus1.Cursor = Cursors.Hand; TextUpdateStatus1.TextDecorations.Add(TextDecorations.Underline); ImageUpdateIcon.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/update-available.png")); } else { TextUpdateStatus1.Text = "You have the latest version."; ImageUpdateIcon.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/update-ok.png")); } } catch (Exception ex) { TextUpdateStatus1.Text = "Error checking for updates!"; ImageUpdateIcon.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/update-failed.png")); TextUpdateStatus1.ToolTip = ex.Message; } ImageUpdateIcon.RenderTransform = null; ImageUpdateIcon.Triggers.Clear(); }
public static async Task <string?> FindUpdate(string owner, string name) { var entryAssembly = Assembly.GetEntryAssembly(); if (entryAssembly == null) { return(null); } var appVersion = SemanticVersion.Parse(entryAssembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>().InformationalVersion); if (appVersion.Version == new Version()) { return(null); } var productHeaderValue = new ProductHeaderValue(entryAssembly.GetCustomAttribute <AssemblyTitleAttribute>()?.Title ?? "UpdateCheck"); var connection = new Connection(productHeaderValue); var apiConnection = new ApiConnection(connection); var client = new ReleasesClient(apiConnection); var latestRelease = (await client.GetAll(owner, name)) .OrderByDescending(r => SemanticVersion.Parse(r.TagName)) .FirstOrDefault(); if (SemanticVersion.Parse(latestRelease.TagName) <= appVersion) { return(null); } return(latestRelease.Assets .Where(asset => string.Equals(asset.Name, Path.ChangeExtension(Path.GetFileName(entryAssembly.Location), ".exe"), StringComparison.OrdinalIgnoreCase)) .Select(asset => asset.BrowserDownloadUrl) .FirstOrDefault()); }