コード例 #1
0
            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));
            }
コード例 #2
0
            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"));
            }
コード例 #3
0
            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"));
            }
コード例 #4
0
            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));
            }
コード例 #5
0
            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"));
            }
コード例 #6
0
            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"));
            }
コード例 #7
0
            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"));
            }
コード例 #8
0
 /// <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;
 }
コード例 #9
0
            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"));
            }
コード例 #10
0
            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));
            }
コード例 #11
0
            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"));
            }
コード例 #12
0
            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));
            }
コード例 #13
0
            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));
            }
コード例 #14
0
            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));
            }
コード例 #15
0
            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);
            }
コード例 #16
0
            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));
            }
コード例 #17
0
            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);
            }
コード例 #18
0
            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");
            }
コード例 #19
0
            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");
            }
コード例 #20
0
            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");
            }
コード例 #21
0
            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");
            }
コード例 #22
0
            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");
            }
コード例 #23
0
            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);
            }
コード例 #24
0
            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));
            }
コード例 #25
0
            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));
            }
コード例 #26
0
            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");
            }
コード例 #27
0
            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);
            }
コード例 #28
0
        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();
            }
        }
コード例 #29
0
            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);
            }
コード例 #30
0
            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));
            }
コード例 #31
0
        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("");
            }
        }
コード例 #32
0
            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));
            }
コード例 #33
0
            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);
            }
コード例 #34
0
            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"));
            }
コード例 #35
0
            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"));
            }
コード例 #36
0
            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);
            }
コード例 #37
0
            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);
            }
コード例 #38
0
            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);
                }
            }
コード例 #39
0
            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"));
            }
コード例 #40
0
        // 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);
            }
        }
コード例 #41
0
            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));
            }
コード例 #42
0
            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));
            }
コード例 #43
0
            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"));
            }
コード例 #44
0
            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);
            }
コード例 #45
0
            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");
            }
コード例 #46
0
            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));
            }
コード例 #47
0
            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);
            }
コード例 #48
0
            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");
            }
コード例 #49
0
            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"));
            }
コード例 #50
0
            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);
            }
コード例 #51
0
            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));
            }
コード例 #52
0
            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);
            }
コード例 #53
0
            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);
            }
コード例 #54
0
            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));
                
            }
コード例 #55
0
            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));
            }
コード例 #56
0
            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);
            }
コード例 #57
0
            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));
            }