public GetAllForRepository ( long repositoryId ) : IObservable |
||
repositoryId | long | The Id of the repository |
return | IObservable |
public async Task EnsuresNonNullArguments() { var client = new ObservablePullRequestReviewCommentsClient(Substitute.For<IGitHubClient>()); var request = new PullRequestReviewCommentRequest(); 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", request)); Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, request)); Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (PullRequestReviewCommentRequest)null)); Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(null, "name", request, ApiOptions.None)); Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", null, request, ApiOptions.None)); Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null, ApiOptions.None)); Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", request, null)); Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, (ApiOptions)null)); Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, (PullRequestReviewCommentRequest)null)); Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, null, ApiOptions.None)); Assert.Throws<ArgumentNullException>(() => client.GetAllForRepository(1, request, null)); Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name", ApiOptions.None)); Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", ApiOptions.None)); Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name", request)); Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", request)); Assert.Throws<ArgumentException>(() => client.GetAllForRepository("", "name", request, ApiOptions.None)); Assert.Throws<ArgumentException>(() => client.GetAllForRepository("owner", "", request, ApiOptions.None)); }
public void RequestsCorrectUrlWithoutSelectedSortingArgumentsWithApiOptionsWithRepositoryId() { var gitHubClient = Substitute.For<IGitHubClient>(); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); var options = new ApiOptions { PageCount = 1, PageSize = 1, StartPage = 1 }; client.GetAllForRepository(1, options); gitHubClient.Received().PullRequest.ReviewComment.GetAllForRepository(1, options); }
public async Task RequestsCorrectUrlWithoutSelectedSortingArgumentsMultiWithRepositoryId() { var firstPageUrl = new Uri("repositories/1/pulls/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), new PullRequestReviewComment(8) } ); var gitHubClient = Substitute.For<IGitHubClient>(); gitHubClient.Connection.Get<List<PullRequestReviewComment>>(firstPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" && d["sort"] == "created"), "application/vnd.github.squirrel-girl-preview") .Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => firstPageResponse)); gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" && d["sort"] == "created"), "application/vnd.github.squirrel-girl-preview") .Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => secondPageResponse)); gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" && d["sort"] == "created"), "application/vnd.github.squirrel-girl-preview") .Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => lastPageResponse)); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); var results = await client.GetAllForRepository(1).ToArray(); Assert.Equal(8, results.Length); gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(firstPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" && d["sort"] == "created"), "application/vnd.github.squirrel-girl-preview"); gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" && d["sort"] == "created"), "application/vnd.github.squirrel-girl-preview"); gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 2 && d["direction"] == "asc" && d["sort"] == "created"), "application/vnd.github.squirrel-girl-preview"); }
public void RequestsCorrectUrlWithoutSelectedSortingArgumentsWithRepositoryId() { var gitHubClient = Substitute.For<IGitHubClient>(); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); client.GetAllForRepository(1); gitHubClient.Received().PullRequest.ReviewComment.GetAllForRepository(1); }
public async Task RequestsCorrectUrlMultiWithRepositoryId() { var firstPageUrl = new Uri("repositories/1/pulls/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), new PullRequestReviewComment(8) } ); var gitHubClient = Substitute.For<IGitHubClient>(); gitHubClient.Connection.Get<List<PullRequestReviewComment>>(firstPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" && d["sort"] == "updated"), "application/vnd.github.squirrel-girl-preview") .Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => firstPageResponse)); gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" && d["sort"] == "updated"), "application/vnd.github.squirrel-girl-preview") .Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => secondPageResponse)); gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" && d["sort"] == "updated"), "application/vnd.github.squirrel-girl-preview") .Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => lastPageResponse)); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); var request = new PullRequestReviewCommentRequest { Direction = SortDirection.Descending, Since = new DateTimeOffset(2013, 11, 15, 11, 43, 01, 00, new TimeSpan()), Sort = PullRequestReviewCommentSort.Updated }; var results = await client.GetAllForRepository(1, request).ToArray(); Assert.Equal(8, results.Length); gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(firstPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" && d["sort"] == "updated"), "application/vnd.github.squirrel-girl-preview"); gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(secondPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" && d["sort"] == "updated"), "application/vnd.github.squirrel-girl-preview"); gitHubClient.Connection.Received(1).Get<List<PullRequestReviewComment>>(thirdPageUrl, Arg.Is<Dictionary<string, string>>(d => d.Count == 3 && d["direction"] == "desc" && d["since"] == "2013-11-15T11:43:01Z" && d["sort"] == "updated"), "application/vnd.github.squirrel-girl-preview"); }
public void RequestsCorrectUrlWithApiOptionsWithRepositoryId() { var gitHubClient = Substitute.For<IGitHubClient>(); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); var request = new PullRequestReviewCommentRequest { Direction = SortDirection.Descending, Since = new DateTimeOffset(2013, 11, 15, 11, 43, 01, 00, new TimeSpan()), Sort = PullRequestReviewCommentSort.Updated }; var options = new ApiOptions { PageCount = 1, PageSize = 1, StartPage = 1 }; client.GetAllForRepository(1, request, options); gitHubClient.Received().PullRequest.ReviewComment.GetAllForRepository(1, request, options); }
public void RequestsCorrectUrl() { var gitHubClient = Substitute.For<IGitHubClient>(); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); var request = new PullRequestReviewCommentRequest { Direction = SortDirection.Descending, Since = new DateTimeOffset(2013, 11, 15, 11, 43, 01, 00, new TimeSpan()), Sort = PullRequestReviewCommentSort.Updated }; client.GetAllForRepository("fake", "repo", request); gitHubClient.Received().PullRequest.ReviewComment.GetAllForRepository("fake", "repo", request); }
public async Task EnsuresArgumentsNotNull() { var client = new ObservablePullRequestReviewCommentsClient(Substitute.For<IGitHubClient>()); var request = new PullRequestReviewCommentRequest(); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", request).ToTask()); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", request).ToTask()); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, request).ToTask()); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", request).ToTask()); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null).ToTask()); }