public GetAll ( long repositoryId, int number ) : IObservable |
||
repositoryId | long | The Id of the repository |
number | int | The pull request number |
Результат | IObservable |
public async Task EnsuresArgumentsNotNull() { var gitHubClient = Substitute.For<IGitHubClient>(); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); await AssertEx.Throws<ArgumentNullException>(async () => await client.GetAll(null, "name", 1)); await AssertEx.Throws<ArgumentException>(async () => await client.GetAll("", "name", 1)); await AssertEx.Throws<ArgumentNullException>(async () => await client.GetAll("owner", null, 1)); await AssertEx.Throws<ArgumentException>(async () => await client.GetAll("owner", "", 1)); await AssertEx.Throws<ArgumentNullException>(async () => await client.GetAll(null, null, 1)); await AssertEx.Throws<ArgumentException>(async () => await client.GetAll("", "", 1)); }
public void RequestsCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For<IGitHubClient>(); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); client.GetAll(1, 1); gitHubClient.Received().PullRequest.ReviewComment.GetAll(1, 1); }
public void RequestsCorrectUrl() { var gitHubClient = Substitute.For<IGitHubClient>(); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); client.GetAll("fake", "repo", 1); gitHubClient.Received().PullRequest.ReviewComment.GetAll("fake", "repo", 1); }
public async Task RequestsCorrectUrl() { var firstPageUrl = new Uri("repos/fakeOwner/fakeRepoName/pulls/7/comments", UriKind.Relative); var secondPageUrl = new Uri("https://example.com/page/2"); var firstPageLinks = new Dictionary<string, Uri> { { "next", secondPageUrl } }; var firstPageResponse = new ApiResponse<List<PullRequestReviewComment>> { BodyAsObject = new List<PullRequestReviewComment> { new PullRequestReviewComment {Id = 1}, new PullRequestReviewComment {Id = 2}, new PullRequestReviewComment {Id = 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<PullRequestReviewComment>> { BodyAsObject = new List<PullRequestReviewComment> { new PullRequestReviewComment {Id = 4}, new PullRequestReviewComment {Id = 5}, new PullRequestReviewComment {Id = 6} }, ApiInfo = CreateApiInfo(secondPageLinks) }; var lastPageResponse = new ApiResponse<List<PullRequestReviewComment>> { BodyAsObject = new List<PullRequestReviewComment> { new PullRequestReviewComment {Id = 7} }, ApiInfo = CreateApiInfo(new Dictionary<string, Uri>()) }; var gitHubClient = Substitute.For<IGitHubClient>(); gitHubClient.Connection.Get<List<PullRequestReviewComment>>(firstPageUrl, null, null) .Returns(Task.Factory.StartNew<IResponse<List<PullRequestReviewComment>>>(() => firstPageResponse)); gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, null, null) .Returns(Task.Factory.StartNew<IResponse<List<PullRequestReviewComment>>>(() => secondPageResponse)); gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, null, null) .Returns(Task.Factory.StartNew<IResponse<List<PullRequestReviewComment>>>(() => lastPageResponse)); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); var results = await client.GetAll("fakeOwner", "fakeRepoName", 7).ToArray(); Assert.Equal(7, results.Length); gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(firstPageUrl, null, null); gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, null, null); gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, null, null); }
public void RequestsCorrectUrlWithApiOptionsWithRepositoryId() { var gitHubClient = Substitute.For<IGitHubClient>(); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); var options = new ApiOptions { PageCount = 1, PageSize = 1, StartPage = 1 }; client.GetAll(1, 1, options); gitHubClient.Received().PullRequest.ReviewComment.GetAll(1, 1, options); }
public async Task RequestsCorrectUrlMulti() { var firstPageUrl = new Uri("repos/owner/name/pulls/7/comments", UriKind.Relative); var secondPageUrl = new Uri("https://example.com/page/2"); var firstPageLinks = new Dictionary<string, Uri> { { "next", secondPageUrl } }; var firstPageResponse = new ApiResponse<List<PullRequestReviewComment>> ( CreateResponseWithApiInfo(firstPageLinks), new List<PullRequestReviewComment> { new PullRequestReviewComment(1), new PullRequestReviewComment(2), new PullRequestReviewComment(3) }); var thirdPageUrl = new Uri("https://example.com/page/3"); var secondPageLinks = new Dictionary<string, Uri> { { "next", thirdPageUrl } }; var secondPageResponse = new ApiResponse<List<PullRequestReviewComment>> ( CreateResponseWithApiInfo(secondPageLinks), new List<PullRequestReviewComment> { new PullRequestReviewComment(4), new PullRequestReviewComment(5), new PullRequestReviewComment(6) } ); var lastPageResponse = new ApiResponse<List<PullRequestReviewComment>> ( new Response(), new List<PullRequestReviewComment> { new PullRequestReviewComment(7) } ); var gitHubClient = Substitute.For<IGitHubClient>(); var acceptHeader = "application/vnd.github.squirrel-girl-preview"; gitHubClient.Connection.Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary, acceptHeader) .Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => firstPageResponse)); gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary, acceptHeader) .Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => secondPageResponse)); gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary, acceptHeader) .Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => lastPageResponse)); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); var results = await client.GetAll("owner", "name", 7).ToArray(); Assert.Equal(7, results.Length); gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(firstPageUrl, Args.EmptyDictionary, acceptHeader); gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Args.EmptyDictionary, acceptHeader); gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Args.EmptyDictionary, acceptHeader); }
public async Task EnsuresNonNullArguments() { var gitHubClient = Substitute.For<IGitHubClient>(); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); Assert.Throws<ArgumentNullException>(() => client.GetAll(null, "name", 1)); Assert.Throws<ArgumentNullException>(() => client.GetAll("owner", null, 1)); Assert.Throws<ArgumentNullException>(() => client.GetAll(null, "name", 1, ApiOptions.None)); Assert.Throws<ArgumentNullException>(() => client.GetAll("owner", null, 1, ApiOptions.None)); Assert.Throws<ArgumentNullException>(() => client.GetAll("owner", "name", 1, null)); Assert.Throws<ArgumentNullException>(() => client.GetAll(1, 1, null)); Assert.Throws<ArgumentException>(() => client.GetAll("", "name", 1)); Assert.Throws<ArgumentException>(() => client.GetAll("owner", "", 1)); Assert.Throws<ArgumentException>(() => client.GetAll("", "name", 1, ApiOptions.None)); Assert.Throws<ArgumentException>(() => client.GetAll("owner", "", 1, ApiOptions.None)); }