當前位置: 首頁>>代碼示例>>C#>>正文


C# ObservablePullRequestsClient.GetAllForRepository方法代碼示例

本文整理匯總了C#中Octokit.Reactive.ObservablePullRequestsClient.GetAllForRepository方法的典型用法代碼示例。如果您正苦於以下問題:C# ObservablePullRequestsClient.GetAllForRepository方法的具體用法?C# ObservablePullRequestsClient.GetAllForRepository怎麽用?C# ObservablePullRequestsClient.GetAllForRepository使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Octokit.Reactive.ObservablePullRequestsClient的用法示例。


在下文中一共展示了ObservablePullRequestsClient.GetAllForRepository方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RequestsCorrectUrlWithRepositoryId

            public void RequestsCorrectUrlWithRepositoryId()
            {
                var gitHubClient = Substitute.For<IGitHubClient>();
                var client = new ObservablePullRequestsClient(gitHubClient);

                client.GetAllForRepository(1);

                gitHubClient.Received().PullRequest.GetAllForRepository(1);
            }
開發者ID:daveaglick,項目名稱:octokit.net,代碼行數:9,代碼來源:ObservablePullRequestsClientTests.cs

示例2: SendsAppropriateParameters

            public void SendsAppropriateParameters()
            {
                var gitHubClient = Substitute.For<IGitHubClient>();
                var client = new ObservablePullRequestsClient(gitHubClient);

                var pullRequestRequest = new PullRequestRequest { SortDirection = SortDirection.Descending };
                client.GetAllForRepository("fake", "repo", pullRequestRequest);

                gitHubClient.Received().PullRequest.GetAllForRepository("fake", "repo", pullRequestRequest, Args.ApiOptions);
            }
開發者ID:jrusbatch,項目名稱:octokit.net,代碼行數:10,代碼來源:ObservablePullRequestsClientTests.cs

示例3: RequestsCorrectUrlWithApiOptions

            public void RequestsCorrectUrlWithApiOptions()
            {
                var gitHubClient = Substitute.For<IGitHubClient>();
                var client = new ObservablePullRequestsClient(gitHubClient);

                var options = new ApiOptions
                {
                    PageCount = 1,
                    PageSize = 1,
                    StartPage = 1
                };

                client.GetAllForRepository("fake", "repo", options);

                gitHubClient.Received().PullRequest.GetAllForRepository("fake", "repo", options);
            }
開發者ID:jrusbatch,項目名稱:octokit.net,代碼行數:16,代碼來源:ObservablePullRequestsClientTests.cs

示例4: SendsAppropriateParameters

            public void SendsAppropriateParameters()
            {
                var firstPageUrl = new Uri("repos/fake/repo/pulls", UriKind.Relative);
                var secondPageUrl = new Uri("https://example.com/page/2");
                var firstPageLinks = new Dictionary<string, Uri> { { "next", secondPageUrl } };
                var firstPageResponse = new ApiResponse<List<PullRequest>>
                (
                    CreateResponseWithApiInfo(firstPageLinks),
                    new List<PullRequest>
                    {
                        new PullRequest(1),
                        new PullRequest(2),
                        new PullRequest(3)
                    }
                );
                var thirdPageUrl = new Uri("https://example.com/page/3");
                var secondPageLinks = new Dictionary<string, Uri> { { "next", thirdPageUrl } };
                var secondPageResponse = new ApiResponse<List<PullRequest>>
                (
                    CreateResponseWithApiInfo(secondPageLinks),
                    new List<PullRequest>
                    {
                        new PullRequest(4),
                        new PullRequest(5),
                        new PullRequest(6)
                    }
                );
                var lastPageResponse = new ApiResponse<List<PullRequest>>
                (
                    new Response(),
                    new List<PullRequest>
                    {
                        new PullRequest(7)
                    }
                );
                var gitHubClient = Substitute.For<IGitHubClient>();
                gitHubClient.Connection.Get<List<PullRequest>>(Arg.Is(firstPageUrl),
                    Arg.Is<Dictionary<string, string>>(d => d.Count == 5
                        && d["head"] == "user:ref-name"
                        && d["state"] == "open"
                        && d["base"] == "fake_base_branch"
                        && d["sort"] == "created"
                        && d["direction"] == "desc"), Arg.Any<string>())
                    .Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => firstPageResponse));
                gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, null, null)
                    .Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => secondPageResponse));
                gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, null, null)
                    .Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => lastPageResponse));
                var client = new ObservablePullRequestsClient(gitHubClient);

                var results = client.GetAllForRepository("fake", "repo", new PullRequestRequest { Head = "user:ref-name", Base = "fake_base_branch" }).ToArray().Wait();

                Assert.Equal(7, results.Length);
                Assert.Equal(firstPageResponse.Body[0].Number, results[0].Number);
                Assert.Equal(secondPageResponse.Body[1].Number, results[4].Number);
                Assert.Equal(lastPageResponse.Body[0].Number, results[6].Number);
            }
開發者ID:cloudRoutine,項目名稱:octokit.net,代碼行數:57,代碼來源:ObservablePullRequestsClientTests.cs

示例5: ReturnsEveryPageOfPullRequests

            public void ReturnsEveryPageOfPullRequests()
            {
                var firstPageUrl = new Uri("repos/fake/repo/pulls", UriKind.Relative);
                var secondPageUrl = new Uri("https://example.com/page/2");
                var firstPageLinks = new Dictionary<string, Uri> { { "next", secondPageUrl } };
                var firstPageResponse = new ApiResponse<List<PullRequest>>
                (
                    CreateResponseWithApiInfo(firstPageLinks),
                    new List<PullRequest>
                    {
                        new PullRequest(1),
                        new PullRequest(2),
                        new PullRequest(3)
                    }
                );
                var thirdPageUrl = new Uri("https://example.com/page/3");
                var secondPageLinks = new Dictionary<string, Uri> { { "next", thirdPageUrl } };
                var secondPageResponse = new ApiResponse<List<PullRequest>>
                (
                    CreateResponseWithApiInfo(secondPageLinks),
                    new List<PullRequest>
                    {
                        new PullRequest(4),
                        new PullRequest(5),
                        new PullRequest(6)
                    }
                );
                var lastPageResponse = new ApiResponse<List<PullRequest>>
                (
                    new Response(),
                    new List<PullRequest>
                    {
                        new PullRequest(7)
                    }
                );
                var gitHubClient = Substitute.For<IGitHubClient>();
                gitHubClient.Connection.Get<List<PullRequest>>(firstPageUrl, null, null)
                    .Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => firstPageResponse));
                gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, null, null)
                    .Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => secondPageResponse));
                gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, null, null)
                    .Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => lastPageResponse));
                var client = new ObservablePullRequestsClient(gitHubClient);

                var results = client.GetAllForRepository("fake", "repo").ToArray().Wait();

                Assert.Equal(7, results.Length);
                Assert.Equal(firstPageResponse.Body[0].Number, results[0].Number);
                Assert.Equal(secondPageResponse.Body[1].Number, results[4].Number);
                Assert.Equal(lastPageResponse.Body[0].Number, results[6].Number);
            }
開發者ID:cloudRoutine,項目名稱:octokit.net,代碼行數:51,代碼來源:ObservablePullRequestsClientTests.cs

示例6: EnsuresNonNullArguments

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

                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name"));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null));

                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name", ApiOptions.None));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, ApiOptions.None));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (ApiOptions)null));

                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name", new PullRequestRequest()));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, new PullRequestRequest()));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (PullRequestRequest)null));

                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name", new PullRequestRequest(), ApiOptions.None));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, new PullRequestRequest(), ApiOptions.None));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null, ApiOptions.None));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", new PullRequestRequest(), null));

                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, (ApiOptions)null));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, (PullRequestRequest)null));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, null, ApiOptions.None));
                Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, new PullRequestRequest(), null));

                Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name"));
                Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", ""));

                Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name", ApiOptions.None));
                Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", ApiOptions.None));

                Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name", new PullRequestRequest()));
                Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", new PullRequestRequest()));

                Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name", new PullRequestRequest(), ApiOptions.None));
                Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", new PullRequestRequest(), ApiOptions.None));
            }
開發者ID:daveaglick,項目名稱:octokit.net,代碼行數:38,代碼來源:ObservablePullRequestsClientTests.cs

示例7: SendsAppropriateParametersWithApiOptionsWithRepositoryId

            public void SendsAppropriateParametersWithApiOptionsWithRepositoryId()
            {
                var gitHubClient = Substitute.For<IGitHubClient>();
                var client = new ObservablePullRequestsClient(gitHubClient);

                var options = new ApiOptions
                {
                    PageCount = 1,
                    PageSize = 1,
                    StartPage = 1
                };

                var pullRequestRequest = new PullRequestRequest { SortDirection = SortDirection.Descending };
                client.GetAllForRepository(1, pullRequestRequest, options);

                gitHubClient.Received().PullRequest.GetAllForRepository(1, pullRequestRequest, options);
            }
開發者ID:daveaglick,項目名稱:octokit.net,代碼行數:17,代碼來源:ObservablePullRequestsClientTests.cs


注:本文中的Octokit.Reactive.ObservablePullRequestsClient.GetAllForRepository方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。