public async Task EnsuresNonEmptyArguments()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservableCheckSuitesClient(gitHubClient);

                var request = new CheckSuiteRequest();

                Assert.Throws <ArgumentException>(() => client.GetAllForReference("", "repo", "ref"));
                Assert.Throws <ArgumentException>(() => client.GetAllForReference("fake", "", "ref"));
                Assert.Throws <ArgumentException>(() => client.GetAllForReference("fake", "repo", ""));

                Assert.Throws <ArgumentException>(() => client.GetAllForReference("", "repo", "ref", request));
                Assert.Throws <ArgumentException>(() => client.GetAllForReference("fake", "", "ref", request));
                Assert.Throws <ArgumentException>(() => client.GetAllForReference("fake", "repo", "", request));

                Assert.Throws <ArgumentException>(() => client.GetAllForReference("", "repo", "ref", request, ApiOptions.None));
                Assert.Throws <ArgumentException>(() => client.GetAllForReference("fake", "", "ref", request, ApiOptions.None));
                Assert.Throws <ArgumentException>(() => client.GetAllForReference("fake", "repo", "", request, ApiOptions.None));

                Assert.Throws <ArgumentException>(() => client.GetAllForReference(1, ""));

                Assert.Throws <ArgumentException>(() => client.GetAllForReference(1, "", request));

                Assert.Throws <ArgumentException>(() => client.GetAllForReference(1, "", request, ApiOptions.None));
            }
Пример #2
0
            public async Task EnsuresNonEmptyArguments()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckSuitesClient(connection);

                var request = new CheckSuiteRequest();

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference("", "repo", "ref"));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference("fake", "", "ref"));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference("fake", "repo", ""));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference("", "repo", "ref", request));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference("fake", "", "ref", request));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference("fake", "repo", "", request));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference("", "repo", "ref", request, ApiOptions.None));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference("fake", "", "ref", request, ApiOptions.None));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference("fake", "repo", "", request, ApiOptions.None));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference(1, ""));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference(1, "", request));

                await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForReference(1, "", request, ApiOptions.None));
            }
            public async Task RequestsCorrectUrlWithRequest()
            {
                var connection   = Substitute.For <IConnection>();
                var gitHubClient = new GitHubClient(connection);
                var client       = new ObservableCheckSuitesClient(gitHubClient);

                var request = new CheckSuiteRequest
                {
                    AppId     = 123,
                    CheckName = "build"
                };

                client.GetAllForReference("fake", "repo", "ref", request);

                connection.Received().Get <List <CheckSuitesResponse> >(
                    Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/commits/ref/check-suites"),
                    Arg.Is <Dictionary <string, string> >(x =>
                                                          x["app_id"] == "123" &&
                                                          x["check_name"] == "build"),
                    "application/vnd.github.antiope-preview+json");
            }
Пример #4
0
            public async Task RequestsCorrectUrlWithRequestWithRepositoryId()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new CheckSuitesClient(connection);

                var request = new CheckSuiteRequest
                {
                    AppId     = 123,
                    CheckName = "build"
                };

                await client.GetAllForReference(1, "ref", request);

                connection.Received().GetAll <CheckSuitesResponse>(
                    Arg.Is <Uri>(u => u.ToString() == "repositories/1/commits/ref/check-suites"),
                    Arg.Is <Dictionary <string, string> >(x =>
                                                          x["app_id"] == "123" &&
                                                          x["check_name"] == "build"),
                    "application/vnd.github.antiope-preview+json",
                    Args.ApiOptions);
            }
Пример #5
0
        /// <summary>
        /// Lists Check Suites for a commit reference (SHA, branch name or tag name)
        /// </summary>
        /// <remarks>
        /// See the <a href="https://developer.github.com/v3/checks/suites/#list-check-suites-for-a-specific-ref">Check Suites API documentation</a> for more information.
        /// </remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="reference">The reference (SHA, branch name or tag name) to list check suites for</param>
        /// <param name="request">Details to filter the request, such as by App Id or Check Name</param>
        /// <param name="options">Options to change the API response</param>
        public IObservable <CheckSuitesResponse> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request, ApiOptions options)
        {
            Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));
            Ensure.ArgumentNotNull(request, nameof(request));
            Ensure.ArgumentNotNull(options, nameof(options));

            return(_connection.GetAndFlattenAllPages <CheckSuitesResponse>(ApiUrls.CheckSuitesForReference(repositoryId, reference), request.ToParametersDictionary(), AcceptHeaders.ChecksApiPreview, options));
        }
Пример #6
0
        /// <summary>
        /// Lists Check Suites for a commit reference (SHA, branch name or tag name)
        /// </summary>
        /// <remarks>
        /// See the <a href="https://developer.github.com/v3/checks/suites/#list-check-suites-for-a-specific-ref">Check Suites API documentation</a> for more information.
        /// </remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="reference">The reference (SHA, branch name or tag name) to list check suites for</param>
        /// <param name="request">Details to filter the request, such as by App Id or Check Name</param>
        public IObservable <CheckSuitesResponse> GetAllForReference(long repositoryId, string reference, CheckSuiteRequest request)
        {
            Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));
            Ensure.ArgumentNotNull(request, nameof(request));

            return(GetAllForReference(repositoryId, reference, request, ApiOptions.None));
        }
Пример #7
0
        /// <summary>
        /// Lists Check Suites for a commit reference (SHA, branch name or tag name)
        /// </summary>
        /// <remarks>
        /// See the <a href="https://developer.github.com/v3/checks/suites/#list-check-suites-for-a-specific-ref">Check Suites API documentation</a> for more information.
        /// </remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="reference">The reference (SHA, branch name or tag name) to list check suites for</param>
        /// <param name="request">Details to filter the request, such as by App Id or Check Name</param>
        public IObservable <CheckSuitesResponse> GetAllForReference(string owner, string name, string reference, CheckSuiteRequest request)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
            Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
            Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference));
            Ensure.ArgumentNotNull(request, nameof(request));

            return(GetAllForReference(owner, name, reference, request, ApiOptions.None));
        }