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 RequestsTheCorrectUrlWithRepositoryIdByTag() { var connection = Substitute.For <IApiConnection>(); var client = new ReleasesClient(connection); await client.Get(1, "tag"); connection.Received().Get <Release>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/releases/tags/tag")); }
public async Task RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new ReleasesClient(connection); await client.Get("fake", "repo", 1); connection.Received().Get<Release>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/releases/1")); }
public void EnsuresNonNullArguments() { var releasesClient = new ReleasesClient(Substitute.For<IApiConnection>()); Assert.Throws<ArgumentNullException>(() => releasesClient.Get(null, "name", 1)); Assert.Throws<ArgumentException>(() => releasesClient.Get("", "name", 1)); Assert.Throws<ArgumentNullException>(() => releasesClient.Get("owner", null, 1)); Assert.Throws<ArgumentException>(() => releasesClient.Get("owner", "", 1)); }
public async Task RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new ReleasesClient(connection); await client.DeleteAsset(1, 1); connection.Received().Delete(Arg.Is <Uri>(u => u.ToString() == "repositories/1/releases/assets/1")); }
public async Task RequestsTheCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new ReleasesClient(connection); await client.GetAsset("fake", "repo", 1); connection.Received().Get <ReleaseAsset>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/releases/assets/1")); }
public void RequestsTheCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new ReleasesClient(connection); client.GetLatest("fake", "repo"); connection.Received().Get <Release>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/releases/latest")); }
/// <summary> /// Gets the latest release. /// </summary> private static async Task<Release> GetLatest() { if (_release == null) { ReleasesClient releases = new ReleasesClient(new ApiConnection(new Connection(new ProductHeaderValue("DiscordPresenceUI")))); _release = await releases.GetLatest("hawezo", "DiscordPresenceUI"); } return _release; }
public void RequestsTheCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new ReleasesClient(connection); client.DeleteAsset("fake", "repo", 1); connection.Received().Delete(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/releases/assets/1")); }
public void EnsuresNonNullArguments() { var releasesClient = new ReleasesClient(Substitute.For <IApiConnection>()); Assert.Throws <ArgumentNullException>(() => releasesClient.Get(null, "name", 1)); Assert.Throws <ArgumentException>(() => releasesClient.Get("", "name", 1)); Assert.Throws <ArgumentNullException>(() => releasesClient.Get("owner", null, 1)); Assert.Throws <ArgumentException>(() => releasesClient.Get("owner", "", 1)); }
public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new ReleasesClient(connection); client.GetLatest("fake", "repo"); connection.Received().Get<Release>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/releases/latest")); }
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)); await Assert.ThrowsAsync <ArgumentNullException>(() => releasesClient.GetAll("owner", "name", null)); }
public async Task EnsuresArgumentsNotNull() { var releasesClient = new ReleasesClient(Substitute.For <IApiConnection>()); var release = new Release("https://uploads.github.com/anything"); var uploadData = new ReleaseAssetUpload("good", "good/good", Stream.Null, null); await Assert.ThrowsAsync <ArgumentNullException>(() => releasesClient.UploadAsset(null, uploadData)); await Assert.ThrowsAsync <ArgumentNullException>(() => releasesClient.UploadAsset(release, null)); }
public async Task EnsuresArgumentsNotNull() { var releasesClient = new ReleasesClient(Substitute.For<IApiConnection>()); var data = new NewRelease("fake-tag"); Assert.Throws<ArgumentNullException>(() => new NewRelease(null)); await Assert.ThrowsAsync<ArgumentNullException>(() => releasesClient.Create(null, "name", data)); await Assert.ThrowsAsync<ArgumentNullException>(() => releasesClient.Create("owner", null, data)); await Assert.ThrowsAsync<ArgumentNullException>(() => releasesClient.Create("owner", "name", null)); }
public void RequestsTheCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var releasesClient = new ReleasesClient(connection); var data = new ReleaseUpdate("fake-tag"); releasesClient.EditRelease("fake", "repo", 1, data); connection.Received().Patch <Release>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/releases/1"), data); }
public void EnsuresNonNullArguments() { var client = new ReleasesClient(Substitute.For <IApiConnection>()); Assert.Throws <ArgumentNullException>(() => client.EditAsset(null, "name", 1, 1, new ReleaseAssetUpdate("name"))); Assert.Throws <ArgumentException>(() => client.EditAsset("", "name", 1, 1, new ReleaseAssetUpdate("name"))); Assert.Throws <ArgumentNullException>(() => client.EditAsset("owner", null, 1, 1, new ReleaseAssetUpdate("name"))); Assert.Throws <ArgumentException>(() => client.EditAsset("owner", "", 1, 1, new ReleaseAssetUpdate("name"))); Assert.Throws <ArgumentNullException>(() => client.EditAsset("owner", "name", 1, 1, null)); }
public async Task RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new ReleasesClient(connection); var data = new ReleaseAssetUpdate("asset"); await client.EditAsset(1, 1, data); connection.Received().Patch <ReleaseAsset>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/releases/assets/1"), data); }
public void RequestsTheCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new ReleasesClient(connection); client.GetAllAssets("fake", "repo", 1); connection.Received().GetAll <ReleaseAsset>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/releases/1/assets"), 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 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); var data = new ReleaseUpdate("fake-tag"); releasesClient.CreateRelease("fake", "repo", data); client.Received().Post <Release>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/releases"), data, "application/vnd.github.manifold-preview"); }
public void RequestsCorrectUrl() { var client = Substitute.For<IApiConnection>(); var releasesClient = new ReleasesClient(client); var data = new NewRelease("fake-tag"); releasesClient.Create("fake", "repo", data); client.Received().Post<Release>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/releases"), data, "application/vnd.github.v3"); }
public async Task RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var client = new ReleasesClient(connection); await client.GetAllAssets(1, 1); connection.Received().GetAll <ReleaseAsset>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/releases/1/assets"), null, "application/vnd.github.v3", Args.ApiOptions); }
public async Task EnsuresNonNullArguments() { var client = new ReleasesClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.DeleteAsset(null, "name", 1)); await Assert.ThrowsAsync <ArgumentException>(() => client.DeleteAsset("", "name", 1)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.DeleteAsset("owner", null, 1)); await Assert.ThrowsAsync <ArgumentException>(() => client.DeleteAsset("owner", "", 1)); }
public async Task EnsuresArgumentsNotNull() { var releasesClient = new ReleasesClient(Substitute.For <IApiConnection>()); var data = new NewRelease("fake-tag"); Assert.Throws <ArgumentNullException>(() => new NewRelease(null)); await Assert.ThrowsAsync <ArgumentNullException>(() => releasesClient.Create(null, "name", data)); await Assert.ThrowsAsync <ArgumentNullException>(() => releasesClient.Create("owner", null, data)); await Assert.ThrowsAsync <ArgumentNullException>(() => releasesClient.Create("owner", "name", null)); }
public async Task RequestsCorrectUrl() { var client = Substitute.For <IApiConnection>(); var releasesClient = new ReleasesClient(client); var data = new NewRelease("fake-tag"); await releasesClient.Create("fake", "repo", data); client.Received().Post <Release>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/releases"), data, "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); }
private static async Task TestReleases() { var releasesClient = new ReleasesClient("https://releases.eclipseorigins.com"); var releases = await releasesClient.GetReleasesAsync(new Guid("0836bbd7-d9b4-466a-a566-7670bd568e3b"), 0, 1); if (releases.Items.Count > 0) { var latestRelease = releases.Items[0]; var downloadUrl = latestRelease.GetDownloadUrl(); } }
public async Task RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For <IApiConnection>(); var releasesClient = new ReleasesClient(connection); var data = new ReleaseUpdate { TagName = "fake-tag" }; await releasesClient.Edit(1, 1, data); connection.Received().Patch <Release>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/releases/1"), data); }
public void EnsuresNonNullArguments() { var releasesClient = new ReleasesClient(Substitute.For <IApiConnection>()); var releaseUpdate = new ReleaseUpdate { TagName = "tag" }; Assert.Throws <ArgumentNullException>(() => releasesClient.Edit(null, "name", 1, releaseUpdate)); Assert.Throws <ArgumentException>(() => releasesClient.Edit("", "name", 1, releaseUpdate)); Assert.Throws <ArgumentNullException>(() => releasesClient.Edit("owner", null, 1, releaseUpdate)); Assert.Throws <ArgumentException>(() => releasesClient.Edit("owner", "", 1, releaseUpdate)); Assert.Throws <ArgumentNullException>(() => releasesClient.Edit("owner", "name", 1, null)); }
public static async Task <string> GetLatestVersion(Guid projectId) { try { var releasesClient = new ReleasesClient("https://releases.eclipseorigins.com"); var releaseLocal = await releasesClient.GetReleasesAsync(projectId, 0, 1); return((releaseLocal.Items.Count == 0) ? "" : releaseLocal.Items[0].Version); } catch { return(""); } }
public async Task EnsuresArgumentsNotNull() { var releasesClient = new ReleasesClient(Substitute.For <IApiConnection>()); var release = new Release { UploadUrl = "https://uploads.github.com/anything" }; var uploadData = new ReleaseAssetUpload { FileName = "good", ContentType = "good/good", RawData = Stream.Null }; await AssertEx.Throws <ArgumentNullException>(async() => await releasesClient.UploadAsset(null, uploadData)); await AssertEx.Throws <ArgumentNullException>(async() => await releasesClient.UploadAsset(release, null)); }
public async Task OverrideDefaultTimeout() { var newTimeout = TimeSpan.FromSeconds(100); var apiConnection = Substitute.For <IApiConnection>(); var fixture = new ReleasesClient(apiConnection); var release = new Release("https://uploads.github.com/anything"); var uploadData = new ReleaseAssetUpload("good", "good/good", Stream.Null, newTimeout); await fixture.UploadAsset(release, uploadData); apiConnection.Received().Post <ReleaseAsset>(Arg.Any <Uri>(), uploadData.RawData, Arg.Any <string>(), uploadData.ContentType, newTimeout); }
public void UploadsToCorrectUrl() { var client = Substitute.For<IApiConnection>(); var releasesClient = new ReleasesClient(client); var release = new Release { UploadUrl = "https://uploads.test.dev/does/not/matter/releases/1/assets{?name}" }; var rawData = Substitute.For<Stream>(); var upload = new ReleaseAssetUpload { FileName = "example.zip", ContentType = "application/zip", RawData = rawData }; releasesClient.UploadAsset(release, upload); client.Received().Post<ReleaseAsset>( Arg.Is<Uri>(u => u.ToString() == "https://uploads.test.dev/does/not/matter/releases/1/assets?name=example.zip"), rawData, "application/vnd.github.v3", Arg.Is<string>(contentType => contentType == "application/zip")); }
public async Task UploadsToCorrectUrl() { var client = Substitute.For <IApiConnection>(); var releasesClient = new ReleasesClient(client); var release = new Release("https://uploads.test.dev/does/not/matter/releases/1/assets{?name}"); var rawData = Substitute.For <Stream>(); var upload = new ReleaseAssetUpload("example.zip", "application/zip", rawData, null); await releasesClient.UploadAsset(release, upload); client.Received().Post <ReleaseAsset>( Arg.Is <Uri>(u => u.ToString() == "https://uploads.test.dev/does/not/matter/releases/1/assets?name=example.zip"), rawData, "application/vnd.github.v3", Arg.Is <string>(contentType => contentType == "application/zip")); }
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 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 CanBeCancelled() { var httpClient = new CancellationTestHttpClient(); var connection = new Connection(new ProductHeaderValue("TEST"), httpClient); var apiConnection = new ApiConnection(connection); var fixture = new ReleasesClient(apiConnection); var release = new Release("https://uploads.github.com/anything"); var uploadData = new ReleaseAssetUpload("good", "good/good", Stream.Null, null); using (var cts = new CancellationTokenSource()) { var uploadTask = fixture.UploadAsset(release, uploadData, cts.Token); cts.Cancel(); await Assert.ThrowsAsync <TaskCanceledException>(() => uploadTask); } }
public void UploadsToCorrectUrl() { var client = Substitute.For <IApiConnection>(); var releasesClient = new ReleasesClient(client); var release = new Release { UploadUrl = "https://uploads.test.dev/does/not/matter/releases/1/assets{?name}" }; var rawData = Substitute.For <Stream>(); var upload = new ReleaseAssetUpload { FileName = "example.zip", ContentType = "application/zip", RawData = rawData }; releasesClient.UploadAsset(release, upload); client.Received().Post <ReleaseAsset>( Arg.Is <Uri>(u => u.ToString() == "https://uploads.test.dev/does/not/matter/releases/1/assets?name=example.zip"), rawData, "application/vnd.github.manifold-preview", Arg.Is <string>(contentType => contentType == "application/zip")); }
// Returns a string array of urls to download files public static async Task <string[]> GetUpdateUrls(Guid projectId, DateTime dateUpdate) { try { var releasesClient = new ReleasesClient("https://releases.eclipseorigins.com"); var releaseNewest = await releasesClient.GetReleasesAsync(projectId, 0, 1, minimumDate : dateUpdate); int cntReleases = releaseNewest.TotalCount; string[] urlReleases = new string[cntReleases]; // Check if the versions match if (releaseNewest.Items[0].Id == ConfigHandler.ConfigFile.Version.ID) { return(null); } // Get each page of updates int i = 0; while (i < cntReleases) { var releases = await releasesClient.GetReleasesAsync(projectId, 0, 1); for (int r = 0; r < releases.Items.Count; ++r) { urlReleases[r + i] = releases.Items[r].GetDownloadUrl(); } i += countPage; } return(urlReleases); } catch { return(null); } }
public async Task EnsuresNonNullArguments() { var client = new ReleasesClient(Substitute.For<IApiConnection>()); AssertEx.Throws<ArgumentNullException>(async () => await client.GetAsset(null, "name", 1, 1)); AssertEx.Throws<ArgumentException>(async () => await client.GetAsset("", "name", 1, 1)); AssertEx.Throws<ArgumentNullException>(async () => await client.GetAsset("owner", null, 1, 1)); AssertEx.Throws<ArgumentException>(async () => await client.GetAsset("owner", "", 1, 1)); }
public async Task EnsuresNonNullArguments() { var client = new ReleasesClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteAsset(null, "name", 1)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.DeleteAsset("owner", null, 1)); await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteAsset("", "name", 1)); await Assert.ThrowsAsync<ArgumentException>(() => client.DeleteAsset("owner", "", 1)); }
public async Task RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new ReleasesClient(connection); await client.DeleteAsset(1, 1); connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repositories/1/releases/assets/1")); }
public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new ReleasesClient(connection); var data = new ReleaseAssetUpdate("asset"); client.EditAsset("fake", "repo", 1, data); connection.Received().Patch<ReleaseAsset>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/releases/assets/1"), data); }
public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new ReleasesClient(connection); client.GetAllAssets("fake", "repo", 1); connection.Received().GetAll<ReleaseAsset>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/releases/1/assets"), null, "application/vnd.github.v3"); }
public async Task EnsuresArgumentsNotNull() { var releasesClient = new ReleasesClient(Substitute.For<IApiConnection>()); var release = new Release { UploadUrl = "https://uploads.github.com/anything" }; var uploadData = new ReleaseAssetUpload { FileName = "good", ContentType = "good/good", RawData = Stream.Null }; await AssertEx.Throws<ArgumentNullException>(async () => await releasesClient.UploadAsset(null, uploadData)); await AssertEx.Throws<ArgumentNullException>(async () => await releasesClient.UploadAsset(release, null)); }
public async Task RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var releasesClient = new ReleasesClient(connection); var data = new ReleaseUpdate { TagName = "fake-tag" }; await releasesClient.Edit(1, 1, data); connection.Received().Patch<Release>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/releases/1"), data); }
public async Task RequestsCorrectUrlWithRepositoryId() { var client = Substitute.For<IApiConnection>(); var releasesClient = new ReleasesClient(client); var data = new NewRelease("fake-tag"); await releasesClient.Create(1, data); client.Received().Post<Release>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/releases"), data, "application/vnd.github.v3"); }
public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new ReleasesClient(connection); client.DeleteAsset("fake", "repo", 1); connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/releases/assets/1")); }
public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var releasesClient = new ReleasesClient(connection); var data = new ReleaseUpdate { TagName = "fake-tag" }; releasesClient.Edit("fake", "repo", 1, data); connection.Received().Patch<Release>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/releases/1"), data); }
public async Task EnsuresNonNullArguments() { var releasesClient = new ReleasesClient(Substitute.For<IApiConnection>()); var release = new Release("https://uploads.github.com/anything"); var uploadData = new ReleaseAssetUpload("good", "good/good", Stream.Null, null); await Assert.ThrowsAsync<ArgumentNullException>(() => releasesClient.UploadAsset(null, uploadData)); await Assert.ThrowsAsync<ArgumentNullException>(() => releasesClient.UploadAsset(release, null)); }
public async Task OverrideDefaultTimeout() { var newTimeout = TimeSpan.FromSeconds(100); var apiConnection = Substitute.For<IApiConnection>(); var fixture = new ReleasesClient(apiConnection); var release = new Release("https://uploads.github.com/anything"); var uploadData = new ReleaseAssetUpload("good", "good/good", Stream.Null, newTimeout); await fixture.UploadAsset(release, uploadData); apiConnection.Received().Post<ReleaseAsset>(Arg.Any<Uri>(), uploadData.RawData, Arg.Any<string>(), uploadData.ContentType, newTimeout); }
public async Task RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new ReleasesClient(connection); var data = new ReleaseAssetUpdate("asset"); await client.EditAsset(1, 1, data); connection.Received().Patch<ReleaseAsset>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/releases/assets/1"), data); }
public async Task EnsuresNonNullArguments() { var releasesClient = new ReleasesClient(Substitute.For<IApiConnection>()); var releaseUpdate = new ReleaseUpdate { TagName = "tag" }; await Assert.ThrowsAsync<ArgumentNullException>(() => releasesClient.Edit(null, "name", 1, releaseUpdate)); await Assert.ThrowsAsync<ArgumentNullException>(() => releasesClient.Edit("owner", null, 1, releaseUpdate)); await Assert.ThrowsAsync<ArgumentNullException>(() => releasesClient.Edit("owner", "name", 1, null)); await Assert.ThrowsAsync<ArgumentNullException>(() => releasesClient.Edit(1, 1, null)); await Assert.ThrowsAsync<ArgumentException>(() => releasesClient.Edit("", "name", 1, releaseUpdate)); await Assert.ThrowsAsync<ArgumentException>(() => releasesClient.Edit("owner", "", 1, releaseUpdate)); }
public async Task EnsuresNonNullArguments() { var releasesClient = new ReleasesClient(Substitute.For<IApiConnection>()); AssertEx.Throws<ArgumentNullException>(async () => await releasesClient.EditRelease(null, "name", new ReleaseUpdate("tag"))); AssertEx.Throws<ArgumentException>(async () => await releasesClient.EditRelease("", "name", new ReleaseUpdate("tag"))); AssertEx.Throws<ArgumentNullException>(async () => await releasesClient.EditRelease("owner", null, new ReleaseUpdate("tag"))); AssertEx.Throws<ArgumentException>(async () => await releasesClient.EditRelease("owner", "", new ReleaseUpdate("tag"))); AssertEx.Throws<ArgumentNullException>(async () => await releasesClient.EditRelease("owner", "name", null)); }
public async Task RequestsTheCorrectUrlWithApiOptions() { var connection = Substitute.For<IApiConnection>(); var client = new ReleasesClient(connection); var options = new ApiOptions { StartPage = 1, PageCount = 1, PageSize = 1 }; await client.GetAllAssets("fake", "repo", 1, options); connection.Received().GetAll<ReleaseAsset>( Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/releases/1/assets"), null, "application/vnd.github.v3", options); }
public void EnsuresNonNullArguments() { var client = new ReleasesClient(Substitute.For<IApiConnection>()); Assert.Throws<ArgumentNullException>(() => client.EditAsset(null, "name", 1, new ReleaseAssetUpdate("name"))); Assert.Throws<ArgumentException>(() => client.EditAsset("", "name", 1, new ReleaseAssetUpdate("name"))); Assert.Throws<ArgumentNullException>(() => client.EditAsset("owner", null, 1, new ReleaseAssetUpdate("name"))); Assert.Throws<ArgumentException>(() => client.EditAsset("owner", "", 1, new ReleaseAssetUpdate("name"))); Assert.Throws<ArgumentNullException>(() => client.EditAsset("owner", "name", 1, null)); }