implemented IReleaseClient.GetAll with overloads to take ApiOptions

This commit is contained in:
Brendan Forster
2016-02-14 15:46:41 +11:00
parent c098ecda60
commit 03ea831489
4 changed files with 42 additions and 4 deletions
+3 -3
View File
@@ -2,14 +2,13 @@
using System.IO;
using System.Threading.Tasks;
using NSubstitute;
using Octokit.Tests.Helpers;
using Xunit;
namespace Octokit.Tests.Clients
{
public class ReleasesClientTests
{
public class TheGetReleasesMethod
public class TheGetAllMethod
{
[Fact]
public void RequestsCorrectUrl()
@@ -21,7 +20,8 @@ namespace Octokit.Tests.Clients
client.Received().GetAll<Release>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/releases"),
null,
"application/vnd.github.v3");
AcceptHeaders.StableVersion,
Args.ApiOptions);
}
[Fact]
+5
View File
@@ -67,5 +67,10 @@ namespace Octokit.Tests
{
get { return Arg.Any<NewDeployKey>(); }
}
public static ApiOptions ApiOptions
{
get { return Arg.Any<ApiOptions>(); }
}
}
}
+13
View File
@@ -26,6 +26,19 @@ namespace Octokit
/// <returns>The list of <see cref="Release"/>s for the specified repository.</returns>
Task<IReadOnlyList<Release>> GetAll(string owner, string name);
/// <summary>
/// Gets all <see cref="Release"/>s for the specified repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/releases/#list-releases-for-a-repository">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The repository's owner</param>
/// <param name="name">The repository's name</param>
/// <param name="options">Options for changing the API response</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>The list of <see cref="Release"/>s for the specified repository.</returns>
Task<IReadOnlyList<Release>> GetAll(string owner, string name, ApiOptions options);
/// <summary>
/// Gets a single <see cref="Release"/> for the specified repository.
/// </summary>
+21 -1
View File
@@ -36,8 +36,28 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "repository");
return GetAll(owner, name, ApiOptions.None);
}
/// <summary>
/// Gets all <see cref="Release"/>s for the specified repository.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/releases/#list-releases-for-a-repository">API documentation</a> for more information.
/// </remarks>
/// <param name="owner">The repository's owner</param>
/// <param name="name">The repository's name</param>
/// <param name="options">Options for changing the API response</param>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>The list of <see cref="Release"/>s for the specified repository.</returns>
public Task<IReadOnlyList<Release>> GetAll(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "repository");
Ensure.ArgumentNotNull(options, "options");
var endpoint = ApiUrls.Releases(owner, name);
return ApiConnection.GetAll<Release>(endpoint, null, AcceptHeaders.StableVersion);
return ApiConnection.GetAll<Release>(endpoint, null, AcceptHeaders.StableVersion, options);
}
/// <summary>