本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}