Add ApiOptions overloads to IWatchedClient + tests.

This commit is contained in:
Devesh Khandelwal
2016-04-21 17:52:32 +05:30
committed by aedampir@gmail.com
parent d089d18c1e
commit 591ab76a7b
3 changed files with 87 additions and 6 deletions
+3 -3
View File
@@ -31,7 +31,7 @@ namespace Octokit.Tests.Clients
client.GetAllForCurrent();
connection.Received().GetAll<Repository>(endpoint);
connection.Received().GetAll<Repository>(endpoint, Arg.Any<ApiOptions>());
}
}
@@ -46,7 +46,7 @@ namespace Octokit.Tests.Clients
client.GetAllForUser("banana");
connection.Received().GetAll<Repository>(endpoint);
connection.Received().GetAll<Repository>(endpoint, Arg.Any<ApiOptions>());
}
}
@@ -61,7 +61,7 @@ namespace Octokit.Tests.Clients
client.GetAllWatchers("fight", "club");
connection.Received().GetAll<User>(endpoint);
connection.Received().GetAll<User>(endpoint, Arg.Any<ApiOptions>());
}
}
+32
View File
@@ -21,6 +21,16 @@ namespace Octokit
/// <returns>A <see cref="IReadOnlyPagedCollection{User}"/> of <see cref="User"/>s watching the passed repository.</returns>
Task<IReadOnlyList<User>> GetAllWatchers(string owner, string name);
/// <summary>
/// Retrieves all of the watchers for the passed 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 API's response.</param>
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
/// <returns>A <see cref="IReadOnlyPagedCollection{User}"/> of <see cref="User"/>s watching the passed repository.</returns>
Task<IReadOnlyList<User>> GetAllWatchers(string owner, string name, ApiOptions options);
/// <summary>
/// Retrieves all of the watched <see cref="Repository"/>(ies) for the current user.
/// </summary>
@@ -31,6 +41,17 @@ namespace Octokit
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
Task<IReadOnlyList<Repository>> GetAllForCurrent();
/// <summary>
/// Retrieves all of the watched <see cref="Repository"/>(ies) for the current user.
/// </summary>
/// <param name="options">Options for changing API's response.</param>
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
/// <returns>
/// A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>(ies) watched by the current authenticated user.
/// </returns>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
Task<IReadOnlyList<Repository>> GetAllForCurrent(ApiOptions options);
/// <summary>
/// Retrieves all of the <see cref="Repository"/>(ies) watched by the specified user.
/// </summary>
@@ -41,6 +62,17 @@ namespace Octokit
/// </returns>
Task<IReadOnlyList<Repository>> GetAllForUser(string user);
/// <summary>
/// Retrieves all of the <see cref="Repository"/>(ies) watched by the specified user.
/// </summary>
/// <param name="user">The login of the user</param>
/// <param name="options">Options for changing API's response.</param>
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
/// <returns>
/// A <see cref="IReadOnlyPagedCollection{Repository}"/>(ies) watched by the specified user.
/// </returns>
Task<IReadOnlyList<Repository>> GetAllForUser(string user, ApiOptions options);
/// <summary>
/// Check if a repository is watched by the current authenticated user.
/// </summary>
+52 -3
View File
@@ -33,7 +33,24 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return ApiConnection.GetAll<User>(ApiUrls.Watchers(owner, name));
return GetAllWatchers(owner, name, ApiOptions.None);
}
/// <summary>
/// Retrieves all of the watchers for the passed 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 API's response.</param>
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
/// <returns>A <see cref="IReadOnlyPagedCollection{User}"/> of <see cref="User"/>s watching the passed repository.</returns>
public Task<IReadOnlyList<User>> GetAllWatchers(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(options, "options");
return ApiConnection.GetAll<User>(ApiUrls.Watchers(owner, name), options);
}
/// <summary>
@@ -45,7 +62,22 @@ namespace Octokit
/// </returns>
public Task<IReadOnlyList<Repository>> GetAllForCurrent()
{
return ApiConnection.GetAll<Repository>(ApiUrls.Watched());
return GetAllForCurrent(ApiOptions.None);
}
/// <summary>
/// Retrieves all of the watched <see cref="Repository"/>(ies) for the current user.
/// </summary>
/// <param name="options">Options for changing API's response.</param>
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
/// <returns>
/// A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>(ies) watched by the current authenticated user.
/// </returns>
public Task<IReadOnlyList<Repository>> GetAllForCurrent(ApiOptions options)
{
Ensure.ArgumentNotNull(options, "options");
return ApiConnection.GetAll<Repository>(ApiUrls.Watched(), options);
}
/// <summary>
@@ -60,7 +92,24 @@ namespace Octokit
{
Ensure.ArgumentNotNullOrEmptyString(user, "user");
return ApiConnection.GetAll<Repository>(ApiUrls.WatchedByUser(user));
return GetAllForUser(user, ApiOptions.None);
}
/// <summary>
/// Retrieves all of the <see cref="Repository"/>(ies) watched by the specified user.
/// </summary>
/// <param name="user">The login of the user</param>
/// <param name="options">Options for changing API's response.</param>
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
/// <returns>
/// A <see cref="IReadOnlyPagedCollection{Repository}"/>(ies) watched by the specified user.
/// </returns>
public Task<IReadOnlyList<Repository>> GetAllForUser(string user, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(user, "user");
Ensure.ArgumentNotNull(options, "options");
return ApiConnection.GetAll<Repository>(ApiUrls.WatchedByUser(user), options);
}
/// <summary>