Added ApiOption overloads to methods on IRepositoryCommitsClient (#1247)

* Added ApiOptions overloads for RepositoryCommitClient methods

* Added overloads to Reactive clients

* Integration tests in progress

* Integration test addition in progress

* More integration tests added

* Added Ensure things

* Minor changes

* Minor changes

* Few changes

* Tried to fix errors

* Tried to fix errors

* Fixed a few things

* Fixed integration tests

* Tidying up

* Added public keyword

* Added unit tests for GetAll() in normal and reactive methods

* Minor changes

* Changed the class name

* Fixed the unit test
This commit is contained in:
Prayank Mathur
2016-04-11 02:58:01 +05:30
committed by Brendan Forster
parent 4ae6000ac1
commit 43f6cfe28b
15 changed files with 358 additions and 30 deletions

View File

@@ -35,6 +35,15 @@ namespace Octokit.Reactive
/// <returns></returns> /// <returns></returns>
IObservable<GitHubCommit> GetAll(string owner, string name); IObservable<GitHubCommit> GetAll(string owner, string name);
/// <summary>
/// Gets all commits for a given repository
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <returns></returns>
IObservable<GitHubCommit> GetAll(string owner, string name, ApiOptions options);
/// <summary> /// <summary>
/// Gets all commits for a given repository /// Gets all commits for a given repository
/// </summary> /// </summary>
@@ -44,6 +53,16 @@ namespace Octokit.Reactive
/// <returns></returns> /// <returns></returns>
IObservable<GitHubCommit> GetAll(string owner, string name, CommitRequest request); IObservable<GitHubCommit> GetAll(string owner, string name, CommitRequest request);
/// <summary>
/// Gets all commits for a given repository
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="request">Used to filter list of commits returned</param>
/// <param name="options">Options for changing the API response</param>
/// <returns></returns>
IObservable<GitHubCommit> GetAll(string owner, string name, CommitRequest request, ApiOptions options);
/// <summary> /// <summary>
/// Get the SHA-1 of a commit reference /// Get the SHA-1 of a commit reference
/// </summary> /// </summary>

View File

@@ -52,7 +52,7 @@ namespace Octokit.Reactive
Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
Ensure.ArgumentNotNull(options, "options"); Ensure.ArgumentNotNull(options, "options");
return _connection.GetAndFlattenAllPages<CommitStatus>(ApiUrls.CommitStatuses(owner, name, reference),options); return _connection.GetAndFlattenAllPages<CommitStatus>(ApiUrls.CommitStatuses(owner, name, reference), options);
} }
/// <summary> /// <summary>

View File

@@ -54,7 +54,26 @@ namespace Octokit.Reactive
/// <returns></returns> /// <returns></returns>
public IObservable<GitHubCommit> GetAll(string owner, string name) public IObservable<GitHubCommit> GetAll(string owner, string name)
{ {
return GetAll(owner, name, new CommitRequest()); Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return GetAll(owner, name, new CommitRequest(), ApiOptions.None);
}
/// <summary>
/// Gets all commits for a given repository
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <returns></returns>
public IObservable<GitHubCommit> GetAll(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(options, "options");
return GetAll(owner, name, new CommitRequest(), options);
} }
/// <summary> /// <summary>
@@ -70,8 +89,24 @@ namespace Octokit.Reactive
Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(request, "request"); Ensure.ArgumentNotNull(request, "request");
return _connection.GetAndFlattenAllPages<GitHubCommit>(ApiUrls.RepositoryCommits(owner, name), return GetAll(owner, name, request, ApiOptions.None);
request.ToParametersDictionary()); }
/// <summary>
/// Gets all commits for a given repository
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="request">Used to filter list of commits returned</param>
/// <param name="options">Options for changing the API response</param>
/// <returns></returns>
public IObservable<GitHubCommit> GetAll(string owner, string name, CommitRequest request, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(request, "request");
return _connection.GetAndFlattenAllPages<GitHubCommit>(ApiUrls.RepositoryCommits(owner, name), request.ToParametersDictionary(), options);
} }
/// <summary> /// <summary>

View File

@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Reactive.Linq; using System.Reactive.Linq;
using System.Reactive.Threading.Tasks; using System.Reactive.Threading.Tasks;
@@ -16,11 +15,7 @@ namespace Octokit.Reactive.Internal
public static IObservable<T> GetAndFlattenAllPages<T>(this IConnection connection, Uri url, ApiOptions options) public static IObservable<T> GetAndFlattenAllPages<T>(this IConnection connection, Uri url, ApiOptions options)
{ {
return GetPagesWithOptions(url, options, (pageUrl, o) => return connection.GetAndFlattenAllPages<T>(url, null, options);
{
var parameters = Pagination.Setup(new Dictionary<string, string>(), options);
return connection.Get<List<T>>(pageUrl, parameters, null).ToObservable();
});
} }
public static IObservable<T> GetAndFlattenAllPages<T>(this IConnection connection, Uri url, IDictionary<string, string> parameters) public static IObservable<T> GetAndFlattenAllPages<T>(this IConnection connection, Uri url, IDictionary<string, string> parameters)
@@ -28,6 +23,15 @@ namespace Octokit.Reactive.Internal
return GetPages(url, parameters, (pageUrl, pageParams) => connection.Get<List<T>>(pageUrl, pageParams, null).ToObservable()); return GetPages(url, parameters, (pageUrl, pageParams) => connection.Get<List<T>>(pageUrl, pageParams, null).ToObservable());
} }
public static IObservable<T> GetAndFlattenAllPages<T>(this IConnection connection, Uri url, IDictionary<string, string> parameters, ApiOptions options)
{
return GetPagesWithOptions(url, parameters, options, (pageUrl, pageParams, o) =>
{
var passingParameters = Pagination.Setup(parameters, options);
return connection.Get<List<T>>(pageUrl, passingParameters, null).ToObservable();
});
}
public static IObservable<T> GetAndFlattenAllPages<T>(this IConnection connection, Uri url, IDictionary<string, string> parameters, string accepts) public static IObservable<T> GetAndFlattenAllPages<T>(this IConnection connection, Uri url, IDictionary<string, string> parameters, string accepts)
{ {
return GetPages(url, parameters, (pageUrl, pageParams) => connection.Get<List<T>>(pageUrl, pageParams, accepts).ToObservable()); return GetPages(url, parameters, (pageUrl, pageParams) => connection.Get<List<T>>(pageUrl, pageParams, accepts).ToObservable());
@@ -47,19 +51,16 @@ namespace Octokit.Reactive.Internal
.SelectMany(resp => resp.Body); .SelectMany(resp => resp.Body);
} }
static IObservable<T> GetPagesWithOptions<T>(Uri uri, ApiOptions options, static IObservable<T> GetPagesWithOptions<T>(Uri uri, IDictionary<string, string> parameters, ApiOptions options, Func<Uri, IDictionary<string, string>, ApiOptions, IObservable<IApiResponse<List<T>>>> getPageFunc)
Func<Uri, ApiOptions, IObservable<IApiResponse<List<T>>>> getPageFunc)
{ {
return getPageFunc(uri, options).Expand(resp => return getPageFunc(uri, parameters, options).Expand(resp =>
{ {
var nextPageUri = resp.HttpResponse.ApiInfo.GetNextPageUrl(); var nextPageUrl = resp.HttpResponse.ApiInfo.GetNextPageUrl();
var shouldContinue = Pagination.ShouldContinue( var shouldContinue = Pagination.ShouldContinue(nextPageUrl, options);
nextPageUri,
options);
return shouldContinue return shouldContinue
? Observable.Defer(() => getPageFunc(nextPageUri, null)) ? Observable.Defer(() => getPageFunc(nextPageUrl, null, null))
: Observable.Empty<IApiResponse<List<T>>>(); : Observable.Empty<IApiResponse<List<T>>>();
}) })
.Where(resp => resp != null) .Where(resp => resp != null)

View File

@@ -42,6 +42,59 @@ public class RepositoryCommitsClientTests
Assert.NotEmpty(list); Assert.NotEmpty(list);
} }
[IntegrationTest]
public async Task CanGetCorrectCountOfCommitsWithoutStart()
{
var options = new ApiOptions
{
PageSize = 5,
PageCount = 1
};
var commits = await _fixture.GetAll("shiftkey", "ReactiveGit", options);
Assert.Equal(5, commits.Count);
}
[IntegrationTest]
public async Task CanGetCorrectCountOfCommitsWithStart()
{
var options = new ApiOptions
{
PageSize = 5,
PageCount = 1,
StartPage = 2
};
var commits = await _fixture.GetAll("shiftkey", "ReactiveGit", options);
Assert.Equal(5, commits.Count);
}
[IntegrationTest]
public async Task ReturnsDistinctResultsBasedOnStart()
{
var startOptions = new ApiOptions
{
PageSize = 5,
PageCount = 1,
};
var skipStartOptions = new ApiOptions
{
PageSize = 5,
PageCount = 1,
StartPage = 2
};
var firstCommit = await _fixture.GetAll("shiftkey", "ReactiveGit", startOptions);
var secondCommit = await _fixture.GetAll("shiftkey", "ReactiveGit", skipStartOptions);
Assert.NotEqual(firstCommit[0].Sha, secondCommit[0].Sha);
Assert.NotEqual(firstCommit[1].Sha, secondCommit[1].Sha);
Assert.NotEqual(firstCommit[2].Sha, secondCommit[2].Sha);
Assert.NotEqual(firstCommit[3].Sha, secondCommit[3].Sha);
Assert.NotEqual(firstCommit[4].Sha, secondCommit[4].Sha);
}
[IntegrationTest] [IntegrationTest]
public async Task CanGetListOfCommitsBySha() public async Task CanGetListOfCommitsBySha()
{ {

View File

@@ -137,6 +137,7 @@
<Compile Include="Reactive\Enterprise\ObservableEnterpriseLicenseClientTests.cs" /> <Compile Include="Reactive\Enterprise\ObservableEnterpriseLicenseClientTests.cs" />
<Compile Include="Reactive\Enterprise\ObservableEnterpriseSearchIndexingClientTests.cs" /> <Compile Include="Reactive\Enterprise\ObservableEnterpriseSearchIndexingClientTests.cs" />
<Compile Include="Reactive\Enterprise\ObservableEnterpriseOrganizationClientTests.cs" /> <Compile Include="Reactive\Enterprise\ObservableEnterpriseOrganizationClientTests.cs" />
<Compile Include="Reactive\ObservableRepositoryDeployKeysClientTests.cs" />
<Compile Include="Reactive\ObservableAssigneesClientTests.cs" /> <Compile Include="Reactive\ObservableAssigneesClientTests.cs" />
<Compile Include="Reactive\ObservableAuthorizationsClientTests.cs" /> <Compile Include="Reactive\ObservableAuthorizationsClientTests.cs" />
<Compile Include="Reactive\ObservableEventsClientTests.cs" /> <Compile Include="Reactive\ObservableEventsClientTests.cs" />
@@ -151,7 +152,7 @@
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Helper.cs" /> <Compile Include="Helper.cs" />
<Compile Include="Clients\UsersClientTests.cs" /> <Compile Include="Clients\UsersClientTests.cs" />
<Compile Include="Reactive\ObservableRepositoryDeployKeysClientTests.cs" /> <Compile Include="Reactive\ObservableRepositoryCommitsClientTests.cs" />
<Compile Include="Reactive\ObservableUserAdministrationClientTests.cs" /> <Compile Include="Reactive\ObservableUserAdministrationClientTests.cs" />
<Compile Include="Reactive\ObservableUserEmailsClientTests.cs" /> <Compile Include="Reactive\ObservableUserEmailsClientTests.cs" />
<Compile Include="Reactive\ObservableTeamsClientTests.cs" /> <Compile Include="Reactive\ObservableTeamsClientTests.cs" />

View File

@@ -0,0 +1,75 @@
using System.Linq;
using System.Threading.Tasks;
using Octokit.Reactive;
using System.Reactive.Linq;
using Xunit;
namespace Octokit.Tests.Integration.Reactive
{
public class ObservableRepositoryCommitsClientTests
{
public class TheGetAllMethod
{
readonly ObservableRepositoryCommitsClient _repositoryCommitsClient;
public TheGetAllMethod()
{
var client = Helper.GetAuthenticatedClient();
_repositoryCommitsClient = new ObservableRepositoryCommitsClient(client);
}
[IntegrationTest]
public async Task CanGetCorrectCountOfCommitsWithoutStart()
{
var options = new ApiOptions
{
PageSize = 5,
PageCount = 1
};
var commits = await _repositoryCommitsClient.GetAll("shiftkey", "ReactiveGit", options).ToList();
Assert.Equal(5, commits.Count);
}
[IntegrationTest]
public async Task CanGetCorrectCountOfCommitsWithStart()
{
var options = new ApiOptions
{
PageSize = 5,
PageCount = 1,
StartPage = 2
};
var commits = await _repositoryCommitsClient.GetAll("shiftkey", "ReactiveGit", options).ToList();
Assert.Equal(5, commits.Count);
}
[IntegrationTest]
public async Task ReturnsDistinctResultsBasedOnStart()
{
var startOptions = new ApiOptions
{
PageSize = 5,
PageCount = 1,
};
var skipStartOptions = new ApiOptions
{
PageSize = 5,
PageCount = 1,
StartPage = 2
};
var firstCommit = await _repositoryCommitsClient.GetAll("shiftkey", "ReactiveGit", startOptions).ToList();
var secondCommit = await _repositoryCommitsClient.GetAll("shiftkey", "ReactiveGit", skipStartOptions).ToList();
Assert.NotEqual(firstCommit[0].Sha, secondCommit[0].Sha);
Assert.NotEqual(firstCommit[1].Sha, secondCommit[1].Sha);
Assert.NotEqual(firstCommit[2].Sha, secondCommit[2].Sha);
Assert.NotEqual(firstCommit[3].Sha, secondCommit[3].Sha);
Assert.NotEqual(firstCommit[4].Sha, secondCommit[4].Sha);
}
}
}
}

View File

@@ -6,7 +6,7 @@ using Octokit.Reactive;
using Octokit.Tests.Integration; using Octokit.Tests.Integration;
using Xunit; using Xunit;
public class ObservableRepositoryDeployKeysClientTests : IDisposable public class ObservableRespositoryDeployKeysClientTests : IDisposable
{ {
const string _key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDB8IE5+RppLpeW+6lqo0fpfvMunKg6W4bhYCfVJIOYbpKoHP95nTUMZPBT++9NLeB4/YsuNTCrrpnpjc4f2IVpGvloRiVXjAzoJk9QIL6uzn1zRFdvaxSJ3Urhe9LcLHcIgccgZgSdWGzaZI3xtMvGC4diwWNsPjvVc/RyDM/MPqAim0X5XVOQwEFsSsUSraezJ+VgYMYzLYBcKWW0B86HVVhL4ZtmcY/RN2544bljnzw2M3aQvXNPTvkuiUoqLOI+5/qzZ8PfkruO55YtweEd0lkY6oZvrBPMD6dLODEqMHb4tD6htx60wSipNqjPwpOMpzp0Bk3G909unVXi6Fw5"; const string _key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDB8IE5+RppLpeW+6lqo0fpfvMunKg6W4bhYCfVJIOYbpKoHP95nTUMZPBT++9NLeB4/YsuNTCrrpnpjc4f2IVpGvloRiVXjAzoJk9QIL6uzn1zRFdvaxSJ3Urhe9LcLHcIgccgZgSdWGzaZI3xtMvGC4diwWNsPjvVc/RyDM/MPqAim0X5XVOQwEFsSsUSraezJ+VgYMYzLYBcKWW0B86HVVhL4ZtmcY/RN2544bljnzw2M3aQvXNPTvkuiUoqLOI+5/qzZ8PfkruO55YtweEd0lkY6oZvrBPMD6dLODEqMHb4tD6htx60wSipNqjPwpOMpzp0Bk3G909unVXi6Fw5";
const string _keyTitle = "octokit@github"; const string _keyTitle = "octokit@github";
@@ -14,7 +14,7 @@ public class ObservableRepositoryDeployKeysClientTests : IDisposable
Repository _repository; Repository _repository;
string _owner; string _owner;
public ObservableRepositoryDeployKeysClientTests() public ObservableRespositoryDeployKeysClientTests()
{ {
var github = Helper.GetAuthenticatedClient(); var github = Helper.GetAuthenticatedClient();

View File

@@ -740,7 +740,7 @@ namespace Octokit.Tests.Clients
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null));
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", ""));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "repo", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "repo", null, ApiOptions.None));
} }
[Fact] [Fact]
@@ -752,8 +752,7 @@ namespace Octokit.Tests.Clients
client.GetAll("owner", "name"); client.GetAll("owner", "name");
connection.Received() connection.Received()
.GetAll<GitHubCommit>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/commits"), .GetAll<GitHubCommit>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/commits"), Args.EmptyDictionary, Args.ApiOptions);
Arg.Any<Dictionary<string, string>>());
} }
} }

View File

@@ -0,0 +1,50 @@
using NSubstitute;
using System;
using System.Collections.Generic;
using Xunit;
namespace Octokit.Tests.Clients
{
public class RespositoryCommitsClientTests
{
public class TheGetAllMethod
{
[Fact]
public void EnsuresNonEmptyArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoryCommitsClient(connection);
var options = new ApiOptions();
var request = new CommitRequest();
Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "name", request, options));
Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "", request, options));
}
[Fact]
public void EnsuresNonNullArguments()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoryCommitsClient(connection);
var options = new ApiOptions();
var request = new CommitRequest();
Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "name", request, options));
Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null, request, options));
Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "name", null, options));
Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "name", request, null));
}
[Fact]
public void GetsCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new RepositoryCommitsClient(connection);
client.GetAll("fake", "repo", new CommitRequest(), new ApiOptions());
connection.Received().GetAll<GitHubCommit>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits"), Args.EmptyDictionary, Args.ApiOptions);
}
}
}
}

View File

@@ -99,6 +99,7 @@
<Compile Include="Clients\RepositoryDeployKeysClientTests.cs" /> <Compile Include="Clients\RepositoryDeployKeysClientTests.cs" />
<Compile Include="Clients\RepositoryContentsClientTests.cs" /> <Compile Include="Clients\RepositoryContentsClientTests.cs" />
<Compile Include="Clients\RepositoryPagesClientTests.cs" /> <Compile Include="Clients\RepositoryPagesClientTests.cs" />
<Compile Include="Clients\RespositoryCommitsClientTests.cs" />
<Compile Include="Clients\SearchClientTests.cs" /> <Compile Include="Clients\SearchClientTests.cs" />
<Compile Include="Clients\GistCommentsClientTests.cs" /> <Compile Include="Clients\GistCommentsClientTests.cs" />
<Compile Include="Clients\GistsClientTests.cs" /> <Compile Include="Clients\GistsClientTests.cs" />

View File

@@ -269,13 +269,13 @@ namespace Octokit.Tests.Reactive
public class TheGetAllCommitsMethod public class TheGetAllCommitsMethod
{ {
[Fact] [Fact]
public void EnsuresArguments() public void EnsuresNonNullArguments()
{ {
var client = new ObservableRepositoriesClient(Substitute.For<IGitHubClient>()); var client = new ObservableRepositoriesClient(Substitute.For<IGitHubClient>());
Assert.Throws<ArgumentNullException>(() => client.Commit.GetAll(null, "repo")); Assert.Throws<ArgumentNullException>(() => client.Commit.GetAll(null, "repo"));
Assert.Throws<ArgumentNullException>(() => client.Commit.GetAll("owner", null)); Assert.Throws<ArgumentNullException>(() => client.Commit.GetAll("owner", null));
Assert.Throws<ArgumentNullException>(() => client.Commit.GetAll("owner", "repo", null)); Assert.Throws<ArgumentNullException>(() => client.Commit.GetAll("owner", "repo", null, ApiOptions.None));
Assert.Throws<ArgumentException>(() => client.Commit.GetAll("", "repo")); Assert.Throws<ArgumentException>(() => client.Commit.GetAll("", "repo"));
Assert.Throws<ArgumentException>(() => client.Commit.GetAll("owner", "")); Assert.Throws<ArgumentException>(() => client.Commit.GetAll("owner", ""));
} }

View File

@@ -18,6 +18,48 @@ namespace Octokit.Tests.Reactive
} }
} }
public class TheGetAllMethod
{
[Fact]
public void EnsuresNonEmptyArguments()
{
var githubClient = Substitute.For<IGitHubClient>();
var client = new ObservableRepositoryCommitsClient(githubClient);
var options = new ApiOptions();
var request = new CommitRequest();
Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "name", request, options).ToTask());
Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", "", request, options).ToTask());
}
[Fact]
public void EnsuresNonNullArguments()
{
var githubClient = Substitute.For<IGitHubClient>();
var client = new ObservableRepositoryCommitsClient(githubClient);
var options = new ApiOptions();
var request = new CommitRequest();
Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(null, "name", request, options).ToTask());
Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null, request, options).ToTask());
Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "name", null, options).ToTask());
Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "name", request, null).ToTask());
}
[Fact]
public void GetsCorrectUrl()
{
var githubClient = Substitute.For<IGitHubClient>();
var client = new ObservableRepositoryCommitsClient(githubClient);
var options = new ApiOptions();
var request = new CommitRequest();
client.GetAll("fake", "repo", request, options);
githubClient.Received().Repository.Commit.GetAll("fake", "repo", request, options);
}
}
public class TheGetSha1Method public class TheGetSha1Method
{ {
[Fact] [Fact]

View File

@@ -42,6 +42,15 @@ namespace Octokit
/// <returns></returns> /// <returns></returns>
Task<IReadOnlyList<GitHubCommit>> GetAll(string owner, string name); Task<IReadOnlyList<GitHubCommit>> GetAll(string owner, string name);
/// <summary>
/// Gets all commits for a given repository
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <returns></returns>
Task<IReadOnlyList<GitHubCommit>> GetAll(string owner, string name, ApiOptions options);
/// <summary> /// <summary>
/// Gets all commits for a given repository /// Gets all commits for a given repository
/// </summary> /// </summary>
@@ -51,6 +60,15 @@ namespace Octokit
/// <returns></returns> /// <returns></returns>
Task<IReadOnlyList<GitHubCommit>> GetAll(string owner, string name, CommitRequest request); Task<IReadOnlyList<GitHubCommit>> GetAll(string owner, string name, CommitRequest request);
/// <summary>
/// Gets all commits for a given repository
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="request">Used to filter list of commits returned</param>
/// <param name="options">Options for changing the API response</param>
/// <returns></returns>
Task<IReadOnlyList<GitHubCommit>> GetAll(string owner, string name, CommitRequest request, ApiOptions options);
/// <summary> /// <summary>
/// Get the SHA-1 of a commit reference /// Get the SHA-1 of a commit reference
/// </summary> /// </summary>

View File

@@ -60,7 +60,25 @@ namespace Octokit
/// <returns></returns> /// <returns></returns>
public Task<IReadOnlyList<GitHubCommit>> GetAll(string owner, string name) public Task<IReadOnlyList<GitHubCommit>> GetAll(string owner, string name)
{ {
return GetAll(owner, name, new CommitRequest()); Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return GetAll(owner, name, new CommitRequest(), ApiOptions.None);
}
/// <summary>
/// Gets all commits for a given repository
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="options">Options for changing the API response</param>
/// <returns></returns>
public Task<IReadOnlyList<GitHubCommit>> GetAll(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return GetAll(owner, name, new CommitRequest(), options);
} }
/// <summary> /// <summary>
@@ -76,8 +94,24 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(request, "request"); Ensure.ArgumentNotNull(request, "request");
return _apiConnection.GetAll<GitHubCommit>(ApiUrls.RepositoryCommits(owner, name), return GetAll(owner, name, request, ApiOptions.None);
request.ToParametersDictionary()); }
/// <summary>
/// Gets all commits for a given repository
/// </summary>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="request">Used to filter list of commits returned</param>
/// <param name="options">Options for changing the API response</param>
/// <returns></returns>
public Task<IReadOnlyList<GitHubCommit>> GetAll(string owner, string name, CommitRequest request, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(request, "request");
return _apiConnection.GetAll<GitHubCommit>(ApiUrls.RepositoryCommits(owner, name), request.ToParametersDictionary(), options);
} }
/// <summary> /// <summary>