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


C# ObservablePullRequestsClient.GetForRepository方法代碼示例

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


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

示例1: 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>>
                {
                    BodyAsObject = new List<PullRequest>
                    {
                        new PullRequest {Number = 1},
                        new PullRequest {Number = 2},
                        new PullRequest {Number = 3},
                    },
                    ApiInfo = CreateApiInfo(firstPageLinks)
                };
                var thirdPageUrl = new Uri("https://example.com/page/3");
                var secondPageLinks = new Dictionary<string, Uri> { { "next", thirdPageUrl } };
                var secondPageResponse = new ApiResponse<List<PullRequest>>
                {
                    BodyAsObject = new List<PullRequest>
                    {
                        new PullRequest {Number = 4},
                        new PullRequest {Number = 5},
                        new PullRequest {Number = 6},
                    },
                    ApiInfo = CreateApiInfo(secondPageLinks)
                };
                var lastPageResponse = new ApiResponse<List<PullRequest>>
                {
                    BodyAsObject = new List<PullRequest>
                    {
                        new PullRequest {Number = 7},
                    },
                    ApiInfo = CreateApiInfo(new Dictionary<string, Uri>())
                };
                var gitHubClient = Substitute.For<IGitHubClient>();
                gitHubClient.Connection.Get<List<PullRequest>>(Arg.Is(firstPageUrl),
                    Arg.Is<Dictionary<string, string>>(d => d.Count == 3
                        && d["head"] == "user:ref-name"
                        && d["state"] == "open"
                        && d["base"] == "fake_base_branch"), Arg.Any<string>())
                    .Returns(Task.Factory.StartNew<IResponse<List<PullRequest>>>(() => firstPageResponse));
                gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, null, null)
                    .Returns(Task.Factory.StartNew<IResponse<List<PullRequest>>>(() => secondPageResponse));
                gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, null, null)
                    .Returns(Task.Factory.StartNew<IResponse<List<PullRequest>>>(() => lastPageResponse));
                var client = new ObservablePullRequestsClient(gitHubClient);

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

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

示例2: 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>>
                {
                    BodyAsObject = new List<PullRequest>
                    {
                        new PullRequest {Number = 1},
                        new PullRequest {Number = 2},
                        new PullRequest {Number = 3},
                    },
                    ApiInfo = CreateApiInfo(firstPageLinks)
                };
                var thirdPageUrl = new Uri("https://example.com/page/3");
                var secondPageLinks = new Dictionary<string, Uri> { { "next", thirdPageUrl } };
                var secondPageResponse = new ApiResponse<List<PullRequest>>
                {
                    BodyAsObject = new List<PullRequest>
                    {
                        new PullRequest {Number = 4},
                        new PullRequest {Number = 5},
                        new PullRequest {Number = 6},
                    },
                    ApiInfo = CreateApiInfo(secondPageLinks)
                };
                var lastPageResponse = new ApiResponse<List<PullRequest>>
                {
                    BodyAsObject = new List<PullRequest>
                    {
                        new PullRequest {Number = 7},
                    },
                    ApiInfo = CreateApiInfo(new Dictionary<string, Uri>())
                };
                var gitHubClient = Substitute.For<IGitHubClient>();
                gitHubClient.Connection.Get<List<PullRequest>>(firstPageUrl, null, null)
                    .Returns(Task.Factory.StartNew<IResponse<List<PullRequest>>>(() => firstPageResponse));
                gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, null, null)
                    .Returns(Task.Factory.StartNew<IResponse<List<PullRequest>>>(() => secondPageResponse));
                gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, null, null)
                    .Returns(Task.Factory.StartNew<IResponse<List<PullRequest>>>(() => lastPageResponse));
                var client = new ObservablePullRequestsClient(gitHubClient);

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

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


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