Commits() public method

Gets the list of commits on a pull request.
http://developer.github.com/v3/pulls/#list-commits-on-a-pull-request
public Commits ( long repositoryId, int number ) : IObservable
repositoryId long The Id of the repository
number int The pull request number
return IObservable
コード例 #1
0
            public async Task FetchesAllCommitsForPullRequest()
            {
                var commit = new PullRequestCommit(null, null, null, null, null, Enumerable.Empty<GitReference>(), null, null);
                var expectedUrl = string.Format("repos/fake/repo/pulls/42/commits");
                var gitHubClient = Substitute.For<IGitHubClient>();
                var connection = Substitute.For<IConnection>();
                IApiResponse<List<PullRequestCommit>> response = new ApiResponse<List<PullRequestCommit>>
                (
                    new Response(),
                    new List<PullRequestCommit> { commit }
                );
                connection.Get<List<PullRequestCommit>>(Args.Uri, null, null)
                    .Returns(Task.FromResult(response));
                gitHubClient.Connection.Returns(connection);
                var client = new ObservablePullRequestsClient(gitHubClient);

                var commits = await client.Commits("fake", "repo", 42).ToList();

                Assert.Equal(1, commits.Count);
                Assert.Same(commit, commits[0]);
                connection.Received().Get<List<PullRequestCommit>>(new Uri(expectedUrl, UriKind.Relative), null, null);
            }
コード例 #2
0
            public async Task EnsuresNonNullArguments()
            {
                var connection = Substitute.For<IGitHubClient>();
                var client = new ObservablePullRequestsClient(connection);

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

                Assert.Throws<ArgumentException>(() => client.Commits("", "name", 1));
                Assert.Throws<ArgumentException>(() => client.Commits("owner", "", 1));
            }
コード例 #3
0
            public async Task FetchesAllCommitsForPullRequest()
            {
                var commit = new PullRequestCommit();
                var expectedUrl = string.Format("repos/fake/repo/pulls/42/commits");
                var gitHubClient = Substitute.For<IGitHubClient>();
                var connection = Substitute.For<IConnection>();
                IResponse<List<PullRequestCommit>> response = new ApiResponse<List<PullRequestCommit>>
                {
                    ApiInfo = new ApiInfo(
                        new Dictionary<string, Uri>(),
                        new List<string>(),
                        new List<string>(),
                        "",
                        new RateLimit(new Dictionary<string, string>())),
                    BodyAsObject = new List<PullRequestCommit> { commit }
                };
                connection.Get<List<PullRequestCommit>>(Args.Uri, null, null)
                    .Returns(Task.FromResult(response));
                gitHubClient.Connection.Returns(connection);
                var client = new ObservablePullRequestsClient(gitHubClient);

                var commits = await client.Commits("fake", "repo", 42).ToList();

                Assert.Equal(1, commits.Count);
                Assert.Same(commit, commits[0]);
                connection.Received().Get<List<PullRequestCommit>>(new Uri(expectedUrl, UriKind.Relative), null, null);
            }
コード例 #4
0
            public async void FetchesAllCommitsForPullRequest()
            {
                var expectedUrl = string.Format("repos/fake/repo/pulls/42/commits");
                var gitHubClient = Substitute.For<IGitHubClient>();
                var connection = Substitute.For<IConnection>();
                gitHubClient.Connection.Returns(connection);
                var client = new ObservablePullRequestsClient(gitHubClient);

                client.Commits("fake", "repo", 42);

                connection.Received().Get<List<PullRequestCommit>>(new Uri(expectedUrl, UriKind.Relative), null, null);
            }