mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
Merge branch 'master' into deployments_client
This commit is contained in:
@@ -3,5 +3,7 @@
|
||||
public interface IObservableActivitiesClient
|
||||
{
|
||||
IObservableEventsClient Events { get; }
|
||||
IObservableWatchedClient Watched { get; }
|
||||
IObservableStarredClient Starred { get; }
|
||||
}
|
||||
}
|
||||
96
Octokit.Reactive/Clients/IObservableFollowersClient.cs
Normal file
96
Octokit.Reactive/Clients/IObservableFollowersClient.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Reactive;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public interface IObservableFollowersClient
|
||||
{
|
||||
/// <summary>
|
||||
/// List the authenticated user’s followers
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#list-followers-of-a-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <see cref="IReadOnlyList{User}"/> of <see cref="User"/>s that follow the authenticated user.</returns>
|
||||
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
|
||||
IObservable<User> GetAllForCurrent();
|
||||
|
||||
/// <summary>
|
||||
/// List a user’s followers
|
||||
/// </summary>
|
||||
/// <param name="login">The login name for the user</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#list-followers-of-a-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <see cref="IReadOnlyList{User}"/> of <see cref="User"/>s that follow the passed user.</returns>
|
||||
IObservable<User> GetAll(string login);
|
||||
|
||||
/// <summary>
|
||||
/// List who the authenticated user is following
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#list-users-followed-by-another-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <see cref="IReadOnlyList{User}"/> of <see cref="User"/>s that the authenticated user follows.</returns>
|
||||
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
|
||||
IObservable<User> GetFollowingForCurrent();
|
||||
|
||||
/// <summary>
|
||||
/// List who a user is following
|
||||
/// </summary>
|
||||
/// <param name="login">The login name of the user</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#list-users-followed-by-another-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <see cref="IReadOnlyList{User}"/> of <see cref="User"/>s that the passed user follows.</returns>
|
||||
IObservable<User> GetFollowing(string login);
|
||||
|
||||
/// <summary>
|
||||
/// Check if the authenticated user follows another user
|
||||
/// </summary>
|
||||
/// <param name="following">The login name of the other user</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#check-if-you-are-following-a-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation.</returns>
|
||||
IObservable<bool> IsFollowingForCurrent(string following);
|
||||
|
||||
/// <summary>
|
||||
/// Check if one user follows another user
|
||||
/// </summary>
|
||||
/// <param name="login">The login name of the user</param>
|
||||
/// <param name="following">The login name of the other user</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#check-if-one-user-follows-another">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation.</returns>
|
||||
IObservable<bool> IsFollowing(string login, string following);
|
||||
|
||||
/// <summary>
|
||||
/// Follow a user
|
||||
/// </summary>
|
||||
/// <param name="login">The login name of the user to follow</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#follow-a-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation.</returns>
|
||||
IObservable<bool> Follow(string login);
|
||||
|
||||
/// <summary>
|
||||
/// Unfollow a user
|
||||
/// </summary>
|
||||
/// <param name="login">The login name of the user to unfollow</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#unfollow-a-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Unfollow",
|
||||
Justification = "Unfollow is consistent with the GitHub website")]
|
||||
IObservable<Unit> Unfollow(string login);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
@@ -8,7 +7,7 @@ namespace Octokit.Reactive
|
||||
{
|
||||
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
|
||||
Justification = "Makes a network request")]
|
||||
IObservable<IReadOnlyDictionary<string, Uri>> GetEmojis();
|
||||
IObservable<Emoji> GetEmojis();
|
||||
|
||||
IObservable<string> RenderRawMarkdown(string markdown);
|
||||
}
|
||||
|
||||
61
Octokit.Reactive/Clients/IObservableWatchedClient.cs
Normal file
61
Octokit.Reactive/Clients/IObservableWatchedClient.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public interface IObservableWatchedClient
|
||||
{
|
||||
/// <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>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IObservable{User}"/> of <see cref="User"/>s watching the passed repository</returns>
|
||||
IObservable<User> GetAllWatchers(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the watched <see cref="Repository"/>(ies) for the current user
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IObservable{Repository}"/> of <see cref="Repository"/></returns>
|
||||
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
|
||||
IObservable<Repository> GetAllForCurrent();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) watched by the specified user
|
||||
/// </summary>
|
||||
/// <param name="user">The login of the user</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IObservable{Repository}"/> watched by the specified user</returns>
|
||||
IObservable<Repository> GetAllForUser(string user);
|
||||
|
||||
/// <summary>
|
||||
/// Check if a repository is watched by the current authenticated user
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation</returns>
|
||||
IObservable<bool> CheckStarred(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Stars a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository to star</param>
|
||||
/// <param name="name">The name of the repository to star</param>
|
||||
/// <param name="newSubscription">A <see cref="NewSubscription"/> instance describing the new subscription to create</param>
|
||||
/// <returns>A <c>bool</c> representing the success of starring</returns>
|
||||
IObservable<Subscription> WatchRepo(string owner, string name, NewSubscription newSubscription);
|
||||
|
||||
/// <summary>
|
||||
/// Unstars a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository to unstar</param>
|
||||
/// <param name="name">The name of the repository to unstar</param>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation</returns>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId="Unwatch",
|
||||
Justification = "Unwatch is consistent with the GitHub website")]
|
||||
IObservable<bool> UnwatchRepo(string owner, string name);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,13 @@
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
Events = new ObservableEventsClient(client);
|
||||
Watched = new ObservableWatchedClient(client);
|
||||
Starred = new ObservableStarredClient(client);
|
||||
}
|
||||
public IObservableEventsClient Events { get; private set; }
|
||||
|
||||
public IObservableWatchedClient Watched { get; private set; }
|
||||
|
||||
public IObservableStarredClient Starred { get; private set; }
|
||||
}
|
||||
}
|
||||
141
Octokit.Reactive/Clients/ObservableFollowersClient.cs
Normal file
141
Octokit.Reactive/Clients/ObservableFollowersClient.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
using System;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using Octokit.Reactive.Internal;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableFollowersClient : IObservableFollowersClient
|
||||
{
|
||||
readonly IFollowersClient _client;
|
||||
readonly IConnection _connection;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new User Followers API client.
|
||||
/// </summary>
|
||||
/// <param name="client">An <see cref="IGitHubClient" /> used to make the requests</param>
|
||||
public ObservableFollowersClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_client = client.User.Followers;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List the authenticated user’s followers
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#list-followers-of-a-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <see cref="IReadOnlyList{User}"/> of <see cref="User"/>s that follow the authenticated user.</returns>
|
||||
public IObservable<User> GetAllForCurrent()
|
||||
{
|
||||
return _connection.GetAndFlattenAllPages<User>(ApiUrls.Followers());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List a user’s followers
|
||||
/// </summary>
|
||||
/// <param name="login">The login name for the user</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#list-followers-of-a-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <see cref="IReadOnlyList{User}"/> of <see cref="User"/>s that follow the passed user.</returns>
|
||||
public IObservable<User> GetAll(string login)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(login, "login");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<User>(ApiUrls.Followers(login));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List who the authenticated user is following
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#list-users-followed-by-another-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <see cref="IReadOnlyList{User}"/> of <see cref="User"/>s that the authenticated user follows.</returns>
|
||||
public IObservable<User> GetFollowingForCurrent()
|
||||
{
|
||||
return _connection.GetAndFlattenAllPages<User>(ApiUrls.Following());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List who a user is following
|
||||
/// </summary>
|
||||
/// <param name="login">The login name of the user</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#list-users-followed-by-another-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <see cref="IReadOnlyList{User}"/> of <see cref="User"/>s that the passed user follows.</returns>
|
||||
public IObservable<User> GetFollowing(string login)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(login, "login");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<User>(ApiUrls.Following(login));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if the authenticated user follows another user
|
||||
/// </summary>
|
||||
/// <param name="following">The login name of the other user</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#check-if-you-are-following-a-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation.</returns>
|
||||
public IObservable<bool> IsFollowingForCurrent(string following)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(following, "following");
|
||||
|
||||
return _client.IsFollowingForCurrent(following).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if one user follows another user
|
||||
/// </summary>
|
||||
/// <param name="login">The login name of the user</param>
|
||||
/// <param name="following">The login name of the other user</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#check-if-one-user-follows-another">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation.</returns>
|
||||
public IObservable<bool> IsFollowing(string login, string following)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(login, "login");
|
||||
Ensure.ArgumentNotNullOrEmptyString(following, "following");
|
||||
|
||||
return _client.IsFollowing(login, following).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Follow a user
|
||||
/// </summary>
|
||||
/// <param name="login">The login name of the user to follow</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#follow-a-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation.</returns>
|
||||
public IObservable<bool> Follow(string login)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(login, "login");
|
||||
|
||||
return _client.Follow(login).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unfollow a user
|
||||
/// </summary>
|
||||
/// <param name="login">The login name of the user to unfollow</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#unfollow-a-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
public IObservable<Unit> Unfollow(string login)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(login, "login");
|
||||
|
||||
return _client.Unfollow(login).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reactive.Linq;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
@@ -15,9 +15,9 @@ namespace Octokit.Reactive
|
||||
_client = client;
|
||||
}
|
||||
|
||||
public IObservable<IReadOnlyDictionary<string, Uri>> GetEmojis()
|
||||
public IObservable<Emoji> GetEmojis()
|
||||
{
|
||||
return _client.GetEmojis().ToObservable();
|
||||
return _client.GetEmojis().ToObservable().SelectMany(e => e);
|
||||
}
|
||||
|
||||
public IObservable<string> RenderRawMarkdown(string markdown)
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Octokit.Reactive
|
||||
public IObservable<SearchCode> SearchCode(SearchCodeRequest request)
|
||||
{
|
||||
Ensure.ArgumentNotNull(request, "request");
|
||||
return _connection.GetAndFlattenAllPages<SearchCode>(ApiUrls.SearchCode(), request.ToParametersDictionary());
|
||||
return _connection.GetAndFlattenAllPages<SearchCode>(ApiUrls.SearchCode(), request.Parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using Octokit.Reactive.Internal;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableStarredClient
|
||||
public class ObservableStarredClient : IObservableStarredClient
|
||||
{
|
||||
private IStarredClient _client;
|
||||
private IConnection _connection;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Octokit.Reactive
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_client = client.Tree;
|
||||
_client = client.GitDatabase.Tree;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
103
Octokit.Reactive/Clients/ObservableWatchedClient.cs
Normal file
103
Octokit.Reactive/Clients/ObservableWatchedClient.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
|
||||
using Octokit.Reactive.Internal;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableWatchedClient : IObservableWatchedClient
|
||||
{
|
||||
private IWatchedClient _client;
|
||||
private IConnection _connection;
|
||||
|
||||
public ObservableWatchedClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_client = client.Activity.Watching;
|
||||
_connection = client.Connection;
|
||||
}
|
||||
|
||||
/// <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>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IObservable{User}"/> of <see cref="User"/>s watching the passed repository</returns>
|
||||
public IObservable<User> GetAllWatchers(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<User>(ApiUrls.Watchers(owner, name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the watched <see cref="Repository"/>(ies) for the current user
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IObservable{Repository}"/> of <see cref="Repository"/></returns>
|
||||
public IObservable<Repository> GetAllForCurrent()
|
||||
{
|
||||
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.Watched());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) watched by the specified user
|
||||
/// </summary>
|
||||
/// <param name="user">The login of the user</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <see cref="IObservable{Repository}"/> watched by the specified user</returns>
|
||||
public IObservable<Repository> GetAllForUser(string user)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.WatchedByUser(user));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if a repository is watched by the current authenticated user
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated</exception>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation</returns>
|
||||
public IObservable<bool> CheckStarred(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return _client.CheckWatched(owner, name).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stars a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository to star</param>
|
||||
/// <param name="name">The name of the repository to star</param>
|
||||
/// <param name="newSubscription">A <see cref="NewSubscription"/> instance describing the new subscription to create</param>
|
||||
/// <returns>A <c>bool</c> representing the success of starring</returns>
|
||||
public IObservable<Subscription> WatchRepo(string owner, string name, NewSubscription newSubscription)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return _client.WatchRepo(owner, name, newSubscription).ToObservable();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unstars a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository to unstar</param>
|
||||
/// <param name="name">The name of the repository to unstar</param>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation</returns>
|
||||
public IObservable<bool> UnwatchRepo(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return _client.UnwatchRepo(owner, name).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,6 +122,10 @@
|
||||
<Compile Include="Clients\IObservableDeploymentsClient.cs" />
|
||||
<Compile Include="Clients\IObservableDeploymentStatusClient.cs" />
|
||||
<Compile Include="Clients\ObservableDeploymentStatusClient.cs" />
|
||||
<Compile Include="Clients\IObservableWatchedClient.cs" />
|
||||
<Compile Include="Clients\ObservableWatchedClient.cs" />
|
||||
<Compile Include="Clients\IObservableFollowersClient.cs" />
|
||||
<Compile Include="Clients\ObservableFollowersClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
||||
@@ -131,6 +131,10 @@
|
||||
<Compile Include="Clients\IObservableDeploymentsClient.cs" />
|
||||
<Compile Include="Clients\IObservableDeploymentStatusClient.cs" />
|
||||
<Compile Include="Clients\ObservableDeploymentStatusClient.cs" />
|
||||
<Compile Include="Clients\IObservableWatchedClient.cs" />
|
||||
<Compile Include="Clients\ObservableWatchedClient.cs" />
|
||||
<Compile Include="Clients\IObservableFollowersClient.cs" />
|
||||
<Compile Include="Clients\ObservableFollowersClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
||||
@@ -126,6 +126,10 @@
|
||||
<Compile Include="Clients\IObservableDeploymentsClient.cs" />
|
||||
<Compile Include="Clients\IObservableDeploymentStatusClient.cs" />
|
||||
<Compile Include="Clients\ObservableDeploymentStatusClient.cs" />
|
||||
<Compile Include="Clients\IObservableWatchedClient.cs" />
|
||||
<Compile Include="Clients\ObservableWatchedClient.cs" />
|
||||
<Compile Include="Clients\IObservableFollowersClient.cs" />
|
||||
<Compile Include="Clients\ObservableFollowersClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
||||
@@ -77,6 +77,8 @@
|
||||
<Compile Include="Clients\IObservableDeploymentStatusClient.cs" />
|
||||
<Compile Include="Clients\ObservableDeploymentsClient.cs" />
|
||||
<Compile Include="Clients\ObservableDeploymentStatusClient.cs" />
|
||||
<Compile Include="Clients\IObservableWatchedClient.cs" />
|
||||
<Compile Include="Clients\IObservableFollowersClient.cs" />
|
||||
<Compile Include="Clients\ObservableSearchClient.cs" />
|
||||
<Compile Include="Clients\IObservableBlobClient.cs" />
|
||||
<Compile Include="Clients\IObservableGistCommentsClient.cs" />
|
||||
@@ -123,9 +125,11 @@
|
||||
<Compile Include="Clients\ObservableStarredClient.cs" />
|
||||
<Compile Include="Clients\ObservableTagsClient.cs" />
|
||||
<Compile Include="Clients\ObservableTreesClient.cs" />
|
||||
<Compile Include="Clients\ObservableFollowersClient.cs" />
|
||||
<Compile Include="Clients\ObservableUsersClient.cs" />
|
||||
<Compile Include="Clients\IObservableAssigneesClient.cs" />
|
||||
<Compile Include="Clients\IObservableNotificationsClient.cs" />
|
||||
<Compile Include="Clients\ObservableWatchedClient.cs" />
|
||||
<Compile Include="Helpers\AuthorizationExtensions.cs" />
|
||||
<Compile Include="Helpers\ConnectionExtensions.cs" />
|
||||
<Compile Include="Helpers\ObservableExtensions.cs" />
|
||||
|
||||
110
Octokit.Tests.Integration/Clients/FollowersClientTests.cs
Normal file
110
Octokit.Tests.Integration/Clients/FollowersClientTests.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit;
|
||||
using Octokit.Tests.Integration;
|
||||
using Xunit;
|
||||
|
||||
public class FollowersClientTests : IDisposable
|
||||
{
|
||||
readonly GitHubClient _github;
|
||||
readonly User _currentUser;
|
||||
|
||||
public FollowersClientTests()
|
||||
{
|
||||
_github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
{
|
||||
Credentials = Helper.Credentials
|
||||
};
|
||||
_currentUser = _github.User.Current().Result;
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsUsersTheCurrentUserIsFollowing()
|
||||
{
|
||||
await _github.User.Followers.Follow("alfhenrik");
|
||||
|
||||
var following = await _github.User.Followers.GetFollowingForCurrent();
|
||||
|
||||
Assert.NotNull(following);
|
||||
Assert.True(following.Any(f => f.Login == "alfhenrik"));
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsUsersTheUserIsFollowing()
|
||||
{
|
||||
var following = await _github.User.Followers.GetFollowing("alfhenrik");
|
||||
|
||||
Assert.NotNull(following);
|
||||
Assert.NotEmpty(following);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsUsersFollowingTheUser()
|
||||
{
|
||||
await _github.User.Followers.Follow("alfhenrik");
|
||||
|
||||
var followers = await _github.User.Followers.GetAll("alfhenrik");
|
||||
|
||||
Assert.NotEmpty(followers);
|
||||
Assert.True(followers.Any(f => f.Login == _currentUser.Login));
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ChecksIfIsFollowingUserWhenFollowingUser()
|
||||
{
|
||||
await _github.User.Followers.Follow("alfhenrik");
|
||||
|
||||
var isFollowing = await _github.User.Followers.IsFollowingForCurrent("alfhenrik");
|
||||
|
||||
Assert.True(isFollowing);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ChecksIfIsFollowingUserWhenNotFollowingUser()
|
||||
{
|
||||
var isFollowing = await _github.User.Followers.IsFollowingForCurrent("alfhenrik");
|
||||
|
||||
Assert.False(isFollowing);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task FollowUserNotBeingFollowedByTheUser()
|
||||
{
|
||||
var result = await _github.User.Followers.Follow("alfhenrik");
|
||||
var following = await _github.User.Followers.GetFollowingForCurrent();
|
||||
|
||||
Assert.True(result);
|
||||
Assert.NotEmpty(following);
|
||||
Assert.True(following.Any(f => f.Login == "alfhenrik"));
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task UnfollowUserBeingFollowedByTheUser()
|
||||
{
|
||||
await _github.User.Followers.Follow("alfhenrik");
|
||||
var followers = await _github.User.Followers.GetAll("alfhenrik");
|
||||
Assert.True(followers.Any(f => f.Login == _currentUser.Login));
|
||||
|
||||
await _github.User.Followers.Unfollow("alfhenrik");
|
||||
followers = await _github.User.Followers.GetAll("alfhenrik");
|
||||
Assert.False(followers.Any(f => f.Login == _currentUser.Login));
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task UnfollowUserNotBeingFollowedTheUser()
|
||||
{
|
||||
var followers = await _github.User.Followers.GetAll("alfhenrik");
|
||||
Assert.False(followers.Any(f => f.Login == _currentUser.Login));
|
||||
|
||||
await _github.User.Followers.Unfollow("alfhenrik");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_github.User.Followers.Unfollow("alfhenrik");
|
||||
}
|
||||
}
|
||||
@@ -102,6 +102,7 @@ public class UsersClientTests
|
||||
|
||||
public class TheGetEmailsMethod
|
||||
{
|
||||
[IntegrationTest]
|
||||
public async Task RetrievesEmailsForUser()
|
||||
{
|
||||
var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
@@ -111,10 +112,9 @@ public class UsersClientTests
|
||||
|
||||
var emails = await github.User.GetEmails();
|
||||
|
||||
Assert.Equal(1, emails.Count());
|
||||
Assert.Equal("test-octowin@example.com", emails.First().Email);
|
||||
Assert.True(emails.First().Primary);
|
||||
Assert.False(emails.First().Verified);
|
||||
Assert.NotEmpty(emails);
|
||||
var email = emails.First();
|
||||
Assert.True(email.Primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
<Compile Include="Clients\MilestonesClientTests.cs" />
|
||||
<Compile Include="Clients\ReferencesClientTests.cs" />
|
||||
<Compile Include="Clients\TreeClientTests.cs" />
|
||||
<Compile Include="Clients\FollowersClientTests.cs" />
|
||||
<Compile Include="IntegrationTestAttribute.cs" />
|
||||
<Compile Include="Clients\IssuesClientTests.cs" />
|
||||
<Compile Include="Clients\MiscellaneousClientTests.cs" />
|
||||
|
||||
274
Octokit.Tests/Clients/FollowersClientTests.cs
Normal file
274
Octokit.Tests/Clients/FollowersClientTests.cs
Normal file
@@ -0,0 +1,274 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Octokit.Internal;
|
||||
using Octokit.Tests;
|
||||
using Octokit.Tests.Helpers;
|
||||
using Xunit;
|
||||
using Xunit.Extensions;
|
||||
|
||||
namespace Octokit.Tests.Clients
|
||||
{
|
||||
/// <summary>
|
||||
/// Client tests mostly just need to make sure they call the IApiConnection with the correct
|
||||
/// relative Uri. No need to fake up the response. All *those* tests are in ApiConnectionTests.cs.
|
||||
/// </summary>
|
||||
public class FollowersClientTests
|
||||
{
|
||||
public class TheConstructor
|
||||
{
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
Assert.Throws<ArgumentNullException>(() => new FollowersClient(null));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllForCurrentMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsTheCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new FollowersClient(connection);
|
||||
|
||||
client.GetAllForCurrent();
|
||||
|
||||
connection.Received().GetAll<User>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "user/followers"));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsTheCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new FollowersClient(connection);
|
||||
|
||||
client.GetAll("alfhenrik");
|
||||
|
||||
connection.Received().GetAll<User>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "users/alfhenrik/followers"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsureNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new FollowersClient(connection);
|
||||
|
||||
AssertEx.Throws<ArgumentNullException>(async () => await client.GetAll(null));
|
||||
AssertEx.Throws<ArgumentException>(async () => await client.GetAll(""));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetFollowingForCurrentMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsTheCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new FollowersClient(connection);
|
||||
|
||||
client.GetFollowingForCurrent();
|
||||
|
||||
connection.Received().GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "user/following"));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetFollowingMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsTheCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new FollowersClient(connection);
|
||||
|
||||
client.GetFollowing("alfhenrik");
|
||||
|
||||
connection.Received().GetAll<User>(Arg.Is<Uri>(u => u.ToString() == "users/alfhenrik/following"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new FollowersClient(connection);
|
||||
|
||||
AssertEx.Throws<ArgumentNullException>(async () => await client.GetFollowing(null));
|
||||
AssertEx.Throws<ArgumentException>(async () => await client.GetFollowing(""));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheIsFollowingForCurrentMethod
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(HttpStatusCode.NoContent, true)]
|
||||
[InlineData(HttpStatusCode.NotFound, false)]
|
||||
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = status });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.GetAsync<object>(Arg.Is<Uri>(u => u.ToString() == "user/following/alfhenrik"),
|
||||
null, null).Returns(response);
|
||||
var apiConnection = Substitute.For<IApiConnection>();
|
||||
apiConnection.Connection.Returns(connection);
|
||||
var client = new FollowersClient(apiConnection);
|
||||
|
||||
var result = await client.IsFollowingForCurrent("alfhenrik");
|
||||
|
||||
Assert.Equal(expected, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ThrowsExceptionForInvalidStatusCode()
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = HttpStatusCode.Conflict });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.GetAsync<object>(Arg.Is<Uri>(u => u.ToString() == "user/following/alfhenrik"),
|
||||
null, null).Returns(response);
|
||||
var apiConnection = Substitute.For<IApiConnection>();
|
||||
apiConnection.Connection.Returns(connection);
|
||||
var client = new FollowersClient(apiConnection);
|
||||
|
||||
AssertEx.Throws<ApiException>(async () => await client.IsFollowingForCurrent("alfhenrik"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new FollowersClient(connection);
|
||||
|
||||
AssertEx.Throws<ArgumentNullException>(async () => await client.IsFollowingForCurrent(null));
|
||||
AssertEx.Throws<ArgumentException>(async () => await client.IsFollowingForCurrent(""));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheIsFollowingMethod
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(HttpStatusCode.NoContent, true)]
|
||||
[InlineData(HttpStatusCode.NotFound, false)]
|
||||
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = status });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.GetAsync<object>(Arg.Is<Uri>(u => u.ToString() == "users/alfhenrik/following/alfhenrik-test"),
|
||||
null, null).Returns(response);
|
||||
var apiConnection = Substitute.For<IApiConnection>();
|
||||
apiConnection.Connection.Returns(connection);
|
||||
var client = new FollowersClient(apiConnection);
|
||||
|
||||
var result = await client.IsFollowing("alfhenrik", "alfhenrik-test");
|
||||
|
||||
Assert.Equal(expected, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ThrowsExceptionForInvalidStatusCode()
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = HttpStatusCode.Conflict });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.GetAsync<object>(Arg.Is<Uri>(u => u.ToString() == "users/alfhenrik/following/alfhenrik-test"),
|
||||
null, null).Returns(response);
|
||||
var apiConnection = Substitute.For<IApiConnection>();
|
||||
apiConnection.Connection.Returns(connection);
|
||||
var client = new FollowersClient(apiConnection);
|
||||
|
||||
AssertEx.Throws<ApiException>(async () => await client.IsFollowing("alfhenrik", "alfhenrik-test"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new FollowersClient(connection);
|
||||
|
||||
AssertEx.Throws<ArgumentNullException>(async () => await client.IsFollowing(null, "alfhenrik-test"));
|
||||
AssertEx.Throws<ArgumentNullException>(async () => await client.IsFollowing("alfhenrik", null));
|
||||
AssertEx.Throws<ArgumentException>(async () => await client.IsFollowing("", "alfhenrik-text"));
|
||||
AssertEx.Throws<ArgumentException>(async () => await client.IsFollowing("alfhenrik", ""));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class TheFollowMethod
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(HttpStatusCode.NoContent, true)]
|
||||
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = status });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.PutAsync<object>(Arg.Is<Uri>(u => u.ToString() == "user/following/alfhenrik"),
|
||||
Args.Object).Returns(response);
|
||||
var apiConnection = Substitute.For<IApiConnection>();
|
||||
apiConnection.Connection.Returns(connection);
|
||||
var client = new FollowersClient(apiConnection);
|
||||
|
||||
var result = await client.Follow("alfhenrik");
|
||||
|
||||
Assert.Equal(expected, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ThrowsExceptionForInvalidStatusCode()
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = HttpStatusCode.Conflict });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.PutAsync<object>(Arg.Is<Uri>(u => u.ToString() == "user/following/alfhenrik"),
|
||||
new { }).Returns(response);
|
||||
var apiConnection = Substitute.For<IApiConnection>();
|
||||
apiConnection.Connection.Returns(connection);
|
||||
var client = new FollowersClient(apiConnection);
|
||||
|
||||
AssertEx.Throws<ApiException>(async () => await client.Follow("alfhenrik"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsureNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new FollowersClient(connection);
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Follow(null));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Follow(""));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheUnfollowMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsTheCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new FollowersClient(connection);
|
||||
|
||||
client.Unfollow("alfhenrik");
|
||||
|
||||
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "user/following/alfhenrik"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsureNonNullArguments()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new FollowersClient(connection);
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Unfollow(null));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Unfollow(""));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,6 +143,32 @@ public class IssueCommentsClientTests
|
||||
}
|
||||
}
|
||||
|
||||
public class TheDeleteMethod
|
||||
{
|
||||
[Fact]
|
||||
public void DeletesCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssueCommentsClient(connection);
|
||||
|
||||
client.Delete("fake", "repo", 42);
|
||||
|
||||
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/42"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresArgumentsNotNullOrEmpty()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssueCommentsClient(connection);
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Delete(null, "name", 42));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Delete("", "name", 42));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Delete("owner", null, 42));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Delete("owner", "", 42));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheCtor
|
||||
{
|
||||
[Fact]
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Octokit.Tests.Helpers;
|
||||
using Xunit;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Octokit.Tests.Clients
|
||||
{
|
||||
@@ -79,5 +80,127 @@ namespace Octokit.Tests.Clients
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Get("owner", null, "label"));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheAddToIssueMethod
|
||||
{
|
||||
readonly string[] labels = { "foo", "bar" };
|
||||
|
||||
[Fact]
|
||||
public void PostsToCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
client.AddToIssue("fake", "repo", 42, labels);
|
||||
|
||||
connection.Received().Post<IReadOnlyList<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Arg.Any<string[]>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new IssuesLabelsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.AddToIssue(null, "name", 42, labels));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.AddToIssue("owner", null, 42, labels));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.AddToIssue("owner", "name", 42, null));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheRemoveFromIssueMethod
|
||||
{
|
||||
[Fact]
|
||||
public void DeleteCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
client.RemoveFromIssue("fake", "repo", 42, "label");
|
||||
|
||||
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels/label"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new IssuesLabelsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.RemoveFromIssue(null, "name", 42, "label"));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.RemoveFromIssue("owner", null, 42, "label"));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.RemoveFromIssue("owner", "name", 42, null));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheReplaceForIssueMethod
|
||||
{
|
||||
readonly string[] labels = { "foo", "bar" };
|
||||
|
||||
[Fact]
|
||||
public void PutsToCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
client.ReplaceAllForIssue("fake", "repo", 42, labels);
|
||||
|
||||
connection.Received().Put<IReadOnlyList<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels"), Arg.Any<string[]>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new IssuesLabelsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.ReplaceAllForIssue(null, "name", 42, labels));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.ReplaceAllForIssue("owner", null, 42, labels));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.ReplaceAllForIssue("owner", "name", 42, null));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheRemoveAllFromIssueMethod
|
||||
{
|
||||
[Fact]
|
||||
public void DeletesCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
client.RemoveAllFromIssue("fake", "repo", 42);
|
||||
|
||||
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new IssuesLabelsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.RemoveAllFromIssue(null, "name", 42));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.RemoveAllFromIssue("owner", null, 42));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetForMilestoneMethod
|
||||
{
|
||||
[Fact]
|
||||
public void GetsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new IssuesLabelsClient(connection);
|
||||
|
||||
client.GetForMilestone("fake", "repo", 42);
|
||||
|
||||
connection.Received().GetAll<Label>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/milestones/42/labels"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new IssuesLabelsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.GetForMilestone(null, "name", 42));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.GetForMilestone("owner", null, 42));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ namespace Octokit.Tests.Clients
|
||||
var emojis = await client.GetEmojis();
|
||||
|
||||
Assert.Equal(2, emojis.Count);
|
||||
Assert.Equal("foo", emojis[0].Name);
|
||||
connection.Received()
|
||||
.GetAsync<Dictionary<string, string>>(Arg.Is<Uri>(u => u.ToString() == "emojis"), null, null);
|
||||
}
|
||||
|
||||
@@ -753,6 +753,281 @@ namespace Octokit.Tests.Clients
|
||||
var client = new SearchClient(Substitute.For<IApiConnection>());
|
||||
AssertEx.Throws<ArgumentNullException>(async () => await client.SearchCode(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestingTheTermParameter()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchCodeRequest("something");
|
||||
|
||||
client.SearchCode(request);
|
||||
|
||||
connection.Received().GetAll<SearchCode>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/code"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestingTheSortParameter()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchCodeRequest("something");
|
||||
request.SortField = CodeSearchSort.Indexed;
|
||||
|
||||
client.SearchCode(request);
|
||||
|
||||
connection.Received().GetAll<SearchCode>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/code"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["sort"] == "indexed"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestingTheOrderParameter()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchCodeRequest("something");
|
||||
request.SortField = CodeSearchSort.Indexed;
|
||||
request.Order = SortDirection.Ascending;
|
||||
|
||||
client.SearchCode(request);
|
||||
|
||||
connection.Received().GetAll<SearchCode>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/code"),
|
||||
Arg.Is<Dictionary<string, string>>(d =>
|
||||
d["sort"] == "indexed" &&
|
||||
d["order"] == "asc"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestingTheDefaultOrderParameter()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchCodeRequest("something");
|
||||
|
||||
client.SearchCode(request);
|
||||
|
||||
connection.Received().GetAll<SearchCode>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/code"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["order"] == "desc"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestingTheInQualifier()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchCodeRequest("something");
|
||||
request.In = new[] { CodeInQualifier.File };
|
||||
|
||||
|
||||
client.SearchCode(request);
|
||||
|
||||
connection.Received().GetAll<SearchCode>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/code"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+in:file"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestingTheInQualifier_Multiple()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchCodeRequest("something");
|
||||
request.In = new[] { CodeInQualifier.File, CodeInQualifier.Path };
|
||||
|
||||
client.SearchCode(request);
|
||||
|
||||
connection.Received().GetAll<SearchCode>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/code"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+in:file,path"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestingTheLanguageQualifier()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchCodeRequest("something");
|
||||
request.Language = Language.CSharp;
|
||||
|
||||
client.SearchCode(request);
|
||||
|
||||
connection.Received().GetAll<SearchCode>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/code"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+language:C#"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestingTheForksQualifier()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchCodeRequest("something");
|
||||
request.Forks = true;
|
||||
|
||||
client.SearchCode(request);
|
||||
|
||||
connection.Received().GetAll<SearchCode>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/code"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+fork:true"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestingTheSizeQualifier_GreaterThan()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchCodeRequest("something");
|
||||
request.Size = Range.GreaterThan(10);
|
||||
|
||||
client.SearchCode(request);
|
||||
|
||||
connection.Received().GetAll<SearchCode>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/code"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+size:>10"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestingTheSizeQualifier_GreaterThanOrEqual()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchCodeRequest("something");
|
||||
request.Size = Range.GreaterThanOrEquals(10);
|
||||
|
||||
client.SearchCode(request);
|
||||
|
||||
connection.Received().GetAll<SearchCode>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/code"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+size:>=10"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestingTheSizeQualifier_LessThan()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchCodeRequest("something");
|
||||
request.Size = Range.LessThan(10);
|
||||
|
||||
client.SearchCode(request);
|
||||
|
||||
connection.Received().GetAll<SearchCode>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/code"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+size:<10"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestingTheSizeQualifier_LessThanOrEqual()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchCodeRequest("something");
|
||||
request.Size = Range.LessThanOrEquals(10);
|
||||
|
||||
client.SearchCode(request);
|
||||
|
||||
connection.Received().GetAll<SearchCode>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/code"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+size:<=10"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestingTheSizeQualifier_Range()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchCodeRequest("something");
|
||||
request.Size = new Range(10, 100);
|
||||
|
||||
client.SearchCode(request);
|
||||
|
||||
connection.Received().GetAll<SearchCode>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/code"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+size:10..100"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestingThePathQualifier()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchCodeRequest("something");
|
||||
request.Path = "app/public";
|
||||
|
||||
client.SearchCode(request);
|
||||
|
||||
connection.Received().GetAll<SearchCode>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/code"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+path:app/public"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestingTheExtensionQualifier()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchCodeRequest("something");
|
||||
request.Extension = "cs";
|
||||
|
||||
client.SearchCode(request);
|
||||
|
||||
connection.Received().GetAll<SearchCode>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/code"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+extension:cs"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestingTheUserQualifier()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchCodeRequest("something");
|
||||
request.User = "alfhenrik";
|
||||
|
||||
client.SearchCode(request);
|
||||
|
||||
connection.Received().GetAll<SearchCode>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/code"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+user:alfhenrik"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestingTheRepoQualifier()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchCodeRequest("something");
|
||||
request.Repo = "octokit.net";
|
||||
|
||||
client.SearchCode(request);
|
||||
|
||||
connection.Received().GetAll<SearchCode>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/code"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["q"] == "something+repo:octokit.net"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestingTheRepoAndPathAndExtensionQualifiers()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new SearchClient(connection);
|
||||
var request = new SearchCodeRequest("something");
|
||||
request.Repo = "octokit.net";
|
||||
request.Path = "tools/FAKE.core";
|
||||
request.Extension = "fs";
|
||||
|
||||
client.SearchCode(request);
|
||||
|
||||
connection.Received().GetAll<SearchCode>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "search/code"),
|
||||
Arg.Is<Dictionary<string, string>>(d =>
|
||||
d["q"] == "something+path:tools/FAKE.core+extension:fs+repo:octokit.net"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
usersClient.GetEmails();
|
||||
|
||||
client.Received().Get<IReadOnlyCollection<EmailAddress>>(endpoint, null);
|
||||
client.Received().GetAll<EmailAddress>(endpoint, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
132
Octokit.Tests/Clients/WatchedClientTests.cs
Normal file
132
Octokit.Tests/Clients/WatchedClientTests.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Octokit.Internal;
|
||||
using Xunit;
|
||||
using Xunit.Extensions;
|
||||
|
||||
namespace Octokit.Tests.Clients
|
||||
{
|
||||
public class WatchedClientTests
|
||||
{
|
||||
public class TheGetAllForCurrentMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsCorrectUrl()
|
||||
{
|
||||
var endpoint = new Uri("user/subscriptions", UriKind.Relative);
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new WatchedClient(connection);
|
||||
|
||||
client.GetAllForCurrent();
|
||||
|
||||
connection.Received().GetAll<Repository>(endpoint);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllForUserMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsCorrectUrl()
|
||||
{
|
||||
var endpoint = new Uri("users/banana/subscriptions", UriKind.Relative);
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new WatchedClient(connection);
|
||||
|
||||
client.GetAllForUser("banana");
|
||||
|
||||
connection.Received().GetAll<Repository>(endpoint);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllWatchersForRepoMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsCorrectUrl()
|
||||
{
|
||||
var endpoint = new Uri("repos/fight/club/subscribers", UriKind.Relative);
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new WatchedClient(connection);
|
||||
|
||||
client.GetAllWatchers("fight", "club");
|
||||
|
||||
connection.Received().GetAll<User>(endpoint);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheCheckWatchedMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task ReturnsTrueOnValidResult()
|
||||
{
|
||||
var endpoint = new Uri("repos/fight/club/subscription", UriKind.Relative);
|
||||
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
connection.Get<Subscription>(endpoint).Returns(Task.FromResult(new Subscription()));
|
||||
|
||||
var client = new WatchedClient(connection);
|
||||
|
||||
var watched = await client.CheckWatched("fight", "club");
|
||||
|
||||
Assert.True(watched);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ReturnsFalseOnNotFoundException()
|
||||
{
|
||||
var endpoint = new Uri("repos/fight/club/subscription", UriKind.Relative);
|
||||
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var response = new ApiResponse<Subscription> { StatusCode = HttpStatusCode.NotFound };
|
||||
connection.Get<Subscription>(endpoint).Returns(x => { throw new NotFoundException(response); });
|
||||
|
||||
var client = new WatchedClient(connection);
|
||||
|
||||
var watched = await client.CheckWatched("fight", "club");
|
||||
|
||||
Assert.False(watched);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheWatchRepoMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsCorrectUrl()
|
||||
{
|
||||
var endpoint = new Uri("repos/fight/club/subscription", UriKind.Relative);
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new WatchedClient(connection);
|
||||
|
||||
var newSubscription = new NewSubscription();
|
||||
client.WatchRepo("fight", "club", newSubscription);
|
||||
|
||||
connection.Received().Put<Subscription>(endpoint, newSubscription);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheUnwatchRepoMethod
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(HttpStatusCode.NoContent, true)]
|
||||
[InlineData(HttpStatusCode.NotFound, false)]
|
||||
[InlineData(HttpStatusCode.OK, false)]
|
||||
public async Task ReturnsCorrectResultBasedOnStatus(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<HttpStatusCode>(() => status);
|
||||
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.DeleteAsync(Arg.Is<Uri>(u => u.ToString() == "repos/yes/no/subscription"))
|
||||
.Returns(response);
|
||||
|
||||
var apiConnection = Substitute.For<IApiConnection>();
|
||||
apiConnection.Connection.Returns(connection);
|
||||
|
||||
var client = new WatchedClient(apiConnection);
|
||||
var result = await client.UnwatchRepo("yes", "no");
|
||||
|
||||
Assert.Equal(expected, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@
|
||||
<ItemGroup>
|
||||
<Reference Include="NSubstitute, Version=1.6.1.0, Culture=neutral, PublicKeyToken=92dd2e9066daa5ca, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\NSubstitute.1.6.1.0\lib\NET40\NSubstitute.dll</HintPath>
|
||||
<HintPath>..\packages\NSubstitute.1.7.1.0\lib\NET40\NSubstitute.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
||||
@@ -32,9 +32,9 @@
|
||||
<NoWarn>4014, 1998</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="NSubstitute, Version=1.6.1.0, Culture=neutral, PublicKeyToken=92dd2e9066daa5ca, processorArchitecture=MSIL">
|
||||
<Reference Include="NSubstitute, Version=1.7.1.0, Culture=neutral, PublicKeyToken=92dd2e9066daa5ca, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\NSubstitute.1.6.1.0\lib\NET40\NSubstitute.dll</HintPath>
|
||||
<HintPath>..\packages\NSubstitute.1.7.1.0\lib\NET40\NSubstitute.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
@@ -88,6 +88,8 @@
|
||||
<Compile Include="Clients\ReleasesClientTests.cs" />
|
||||
<Compile Include="Clients\SshKeysClientTests.cs" />
|
||||
<Compile Include="Clients\TreesClientTests.cs" />
|
||||
<Compile Include="Clients\WatchedClientTests.cs" />
|
||||
<Compile Include="Clients\FollowersClientTests.cs" />
|
||||
<Compile Include="Exceptions\ApiExceptionTests.cs" />
|
||||
<Compile Include="Exceptions\ApiValidationExceptionTests.cs" />
|
||||
<Compile Include="Exceptions\TwoFactorChallengeFailedException.cs" />
|
||||
@@ -141,6 +143,7 @@
|
||||
<Compile Include="Reactive\ObservableRepositoriesClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableStarredClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableTreesClientTests.cs" />
|
||||
<Compile Include="Reactive\ObservableFollowersTest.cs" />
|
||||
<Compile Include="SimpleJsonSerializerTests.cs" />
|
||||
<Compile Include="Clients\UsersClientTests.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
192
Octokit.Tests/Reactive/ObservableFollowersTest.cs
Normal file
192
Octokit.Tests/Reactive/ObservableFollowersTest.cs
Normal file
@@ -0,0 +1,192 @@
|
||||
using NSubstitute;
|
||||
using Octokit;
|
||||
using Octokit.Internal;
|
||||
using Octokit.Reactive;
|
||||
using Octokit.Tests.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Reactive
|
||||
{
|
||||
public class ObservableFollowersTest
|
||||
{
|
||||
public class TheGetAllForCurrentMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsTheCorrectUrl()
|
||||
{
|
||||
var githubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableFollowersClient(githubClient);
|
||||
|
||||
client.GetAllForCurrent();
|
||||
|
||||
githubClient.Connection.GetAsync<IReadOnlyList<User>>(
|
||||
new Uri("user/followers", UriKind.Relative), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsTheCorrectUrl()
|
||||
{
|
||||
var githubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableFollowersClient(githubClient);
|
||||
|
||||
client.GetAll("alfhenrik");
|
||||
|
||||
githubClient.Connection.GetAsync<IReadOnlyList<User>>(
|
||||
new Uri("users/alfhenrik/followers", UriKind.Relative), null, null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ObservableFollowersClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.GetAll(null));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.GetAll(""));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetFollowingForCurrentMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsTheCorrectUrl()
|
||||
{
|
||||
var githubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableFollowersClient(githubClient);
|
||||
|
||||
client.GetFollowingForCurrent();
|
||||
|
||||
githubClient.Connection.GetAsync<IReadOnlyList<User>>(
|
||||
new Uri("user/following", UriKind.Relative), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetFollowingMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsTheCorrectUrl()
|
||||
{
|
||||
var githubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableFollowersClient(githubClient);
|
||||
|
||||
client.GetFollowing("alfhenrik");
|
||||
|
||||
githubClient.Connection.GetAsync<IReadOnlyList<User>>(
|
||||
new Uri("users/alfhenrik/following", UriKind.Relative), null, null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ObservableFollowersClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.GetFollowing(null));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.GetFollowing(""));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheIsFollowingForCurrentMethod
|
||||
{
|
||||
[Fact]
|
||||
public void IsFollowingForCurrentFromClientUserFollowers()
|
||||
{
|
||||
var githubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableFollowersClient(githubClient);
|
||||
|
||||
client.IsFollowingForCurrent("alfhenrik");
|
||||
|
||||
githubClient.User.Followers.Received()
|
||||
.IsFollowingForCurrent("alfhenrik");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ObservableFollowersClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.IsFollowingForCurrent(null));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.IsFollowingForCurrent(""));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheIsFollowingMethod
|
||||
{
|
||||
[Fact]
|
||||
public void IsFollowingFromClientUserFollowers()
|
||||
{
|
||||
var githubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableFollowersClient(githubClient);
|
||||
|
||||
client.IsFollowing("alfhenrik", "alfhenrik-test");
|
||||
|
||||
githubClient.User.Followers.Received()
|
||||
.IsFollowing("alfhenrik", "alfhenrik-test");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ObservableFollowersClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.IsFollowing(null, "alfhenrik-test"));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.IsFollowing("", "alfhenrik-test"));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.IsFollowing("alfhenrik", null));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.IsFollowing("alfhenrik", ""));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheFollowMethod
|
||||
{
|
||||
[Fact]
|
||||
public void FollowFromClientUserFollowers()
|
||||
{
|
||||
var githubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableFollowersClient(githubClient);
|
||||
|
||||
client.Follow("alfhenrik");
|
||||
|
||||
githubClient.User.Followers.Received()
|
||||
.Follow("alfhenrik");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ObservableFollowersClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Follow(null));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Follow(""));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheUnfollowMethod
|
||||
{
|
||||
[Fact]
|
||||
public void UnfollowFromClientUserFollowers()
|
||||
{
|
||||
var githubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableFollowersClient(githubClient);
|
||||
|
||||
client.Unfollow("alfhenrik");
|
||||
|
||||
githubClient.User.Followers.Received()
|
||||
.Unfollow("alfhenrik");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ObservableFollowersClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Unfollow(null));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Unfollow(""));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ namespace Octokit.Tests
|
||||
|
||||
client.Get("fake", "repo", "123456ABCD");
|
||||
|
||||
gitHubClient.Tree.Received().Get("fake", "repo", "123456ABCD");
|
||||
gitHubClient.GitDatabase.Tree.Received().Get("fake", "repo", "123456ABCD");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -48,7 +48,7 @@ namespace Octokit.Tests
|
||||
|
||||
client.Create("fake", "repo", newTree);
|
||||
|
||||
gitHubClient.Tree.Received().Create("fake", "repo", newTree);
|
||||
gitHubClient.GitDatabase.Tree.Received().Create("fake", "repo", newTree);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NSubstitute" version="1.6.1.0" targetFramework="net45" />
|
||||
<package id="NSubstitute" version="1.7.1.0" targetFramework="net45" />
|
||||
<package id="Rx-Core" version="2.1.30214.0" targetFramework="net45" />
|
||||
<package id="Rx-Interfaces" version="2.1.30214.0" targetFramework="net45" />
|
||||
<package id="Rx-Linq" version="2.1.30214.0" targetFramework="net45" />
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
{
|
||||
Events = new EventsClient(apiConnection);
|
||||
Starring = new StarredClient(apiConnection);
|
||||
Watching = new WatchedClient(apiConnection);
|
||||
}
|
||||
|
||||
public IEventsClient Events { get; private set; }
|
||||
public IStarredClient Starring { get; private set; }
|
||||
public IWatchedClient Watching { get; private set; }
|
||||
}
|
||||
}
|
||||
|
||||
182
Octokit/Clients/FollowersClient.cs
Normal file
182
Octokit/Clients/FollowersClient.cs
Normal file
@@ -0,0 +1,182 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's User Followers API
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/">Followers API documentation</a> for more information.
|
||||
///</remarks>
|
||||
public class FollowersClient : ApiClient, IFollowersClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new GitHub User Followers API client.
|
||||
/// </summary>
|
||||
/// <param name="apiConnection">An API connection</param>
|
||||
public FollowersClient(IApiConnection apiConnection) : base(apiConnection)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List the authenticated user’s followers
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#list-followers-of-a-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <see cref="IReadOnlyList{User}"/> of <see cref="User"/>s that follow the authenticated user.</returns>
|
||||
public Task<IReadOnlyList<User>> GetAllForCurrent()
|
||||
{
|
||||
return ApiConnection.GetAll<User>(ApiUrls.Followers());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List a user’s followers
|
||||
/// </summary>
|
||||
/// <param name="login">The login name for the user</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#list-followers-of-a-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <see cref="IReadOnlyList{User}"/> of <see cref="User"/>s that follow the passed user.</returns>
|
||||
public Task<IReadOnlyList<User>> GetAll(string login)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(login, "login");
|
||||
|
||||
return ApiConnection.GetAll<User>(ApiUrls.Followers(login));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List who the authenticated user is following
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#list-users-followed-by-another-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <see cref="IReadOnlyList{User}"/> of <see cref="User"/>s that the authenticated user follows.</returns>
|
||||
public Task<IReadOnlyList<User>> GetFollowingForCurrent()
|
||||
{
|
||||
return ApiConnection.GetAll<User>(ApiUrls.Following());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List who a user is following
|
||||
/// </summary>
|
||||
/// <param name="login">The login name of the user</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#list-users-followed-by-another-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <see cref="IReadOnlyList{User}"/> of <see cref="User"/>s that the passed user follows.</returns>
|
||||
public Task<IReadOnlyList<User>> GetFollowing(string login)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(login, "login");
|
||||
|
||||
return ApiConnection.GetAll<User>(ApiUrls.Following(login));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if the authenticated user follows another user
|
||||
/// </summary>
|
||||
/// <param name="following">The login name of the other user</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#check-if-you-are-following-a-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation.</returns>
|
||||
public async Task<bool> IsFollowingForCurrent(string following)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(following, "following");
|
||||
|
||||
try
|
||||
{
|
||||
var response = await Connection.GetAsync<object>(ApiUrls.IsFollowing(following), null, null)
|
||||
.ConfigureAwait(false);
|
||||
if(response.StatusCode != HttpStatusCode.NotFound && response.StatusCode != HttpStatusCode.NoContent)
|
||||
{
|
||||
throw new ApiException("Invalid Status Code returned. Expected a 204 or a 404", response.StatusCode);
|
||||
}
|
||||
return response.StatusCode == HttpStatusCode.NoContent;
|
||||
}
|
||||
catch (NotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if one user follows another user
|
||||
/// </summary>
|
||||
/// <param name="login">The login name of the user</param>
|
||||
/// <param name="following">The login name of the other user</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#check-if-one-user-follows-another">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation.</returns>
|
||||
public async Task<bool> IsFollowing(string login, string following)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(login, "login");
|
||||
Ensure.ArgumentNotNullOrEmptyString(following, "following");
|
||||
|
||||
try
|
||||
{
|
||||
var response = await Connection.GetAsync<object>(ApiUrls.IsFollowing(login, following), null, null)
|
||||
.ConfigureAwait(false);
|
||||
if (response.StatusCode != HttpStatusCode.NotFound && response.StatusCode != HttpStatusCode.NoContent)
|
||||
{
|
||||
throw new ApiException("Invalid Status Code returned. Expected a 204 or a 404", response.StatusCode);
|
||||
}
|
||||
return response.StatusCode == HttpStatusCode.NoContent;
|
||||
}
|
||||
catch (NotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Follow a user
|
||||
/// </summary>
|
||||
/// <param name="login">The login name of the user to follow</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#follow-a-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation.</returns>
|
||||
public async Task<bool> Follow(string login)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(login, "login");
|
||||
|
||||
try
|
||||
{
|
||||
var requestData = new { };
|
||||
var response = await Connection.PutAsync<object>(ApiUrls.IsFollowing(login), requestData)
|
||||
.ConfigureAwait(false);
|
||||
if (response.StatusCode != HttpStatusCode.NoContent)
|
||||
{
|
||||
throw new ApiException("Invalid Status Code returned. Expected a 204", response.StatusCode);
|
||||
}
|
||||
return response.StatusCode == HttpStatusCode.NoContent;
|
||||
}
|
||||
catch (NotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unfollow a user
|
||||
/// </summary>
|
||||
/// <param name="login">The login name of the user to unfollow</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#unfollow-a-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
public Task Unfollow(string login)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(login, "login");
|
||||
|
||||
return ApiConnection.Delete(ApiUrls.IsFollowing(login));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,5 +10,6 @@
|
||||
{
|
||||
IEventsClient Events { get; }
|
||||
IStarredClient Starring { get; }
|
||||
IWatchedClient Watching { get; }
|
||||
}
|
||||
}
|
||||
98
Octokit/Clients/IFollowersClient.cs
Normal file
98
Octokit/Clients/IFollowersClient.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// A client for GitHub's User Followers API
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/">Followers API documentation</a> for more information.
|
||||
///</remarks>
|
||||
public interface IFollowersClient
|
||||
{
|
||||
/// <summary>
|
||||
/// List the authenticated user’s followers
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#list-followers-of-a-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <see cref="IReadOnlyList{User}"/> of <see cref="User"/>s that follow the authenticated user.</returns>
|
||||
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
|
||||
Task<IReadOnlyList<User>> GetAllForCurrent();
|
||||
|
||||
/// <summary>
|
||||
/// List a user’s followers
|
||||
/// </summary>
|
||||
/// <param name="login">The login name for the user</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#list-followers-of-a-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <see cref="IReadOnlyList{User}"/> of <see cref="User"/>s that follow the passed user.</returns>
|
||||
Task<IReadOnlyList<User>> GetAll(string login);
|
||||
|
||||
/// <summary>
|
||||
/// List who the authenticated user is following
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#list-users-followed-by-another-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <see cref="IReadOnlyList{User}"/> of <see cref="User"/>s that the authenticated user follows.</returns>
|
||||
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
|
||||
Task<IReadOnlyList<User>> GetFollowingForCurrent();
|
||||
|
||||
/// <summary>
|
||||
/// List who a user is following
|
||||
/// </summary>
|
||||
/// <param name="login">The login name of the user</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#list-users-followed-by-another-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <see cref="IReadOnlyList{User}"/> of <see cref="User"/>s that the passed user follows.</returns>
|
||||
Task<IReadOnlyList<User>> GetFollowing(string login);
|
||||
|
||||
/// <summary>
|
||||
/// Check if the authenticated user follows another user
|
||||
/// </summary>
|
||||
/// <param name="following">The login name of the other user</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#check-if-you-are-following-a-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation.</returns>
|
||||
Task<bool> IsFollowingForCurrent(string following);
|
||||
|
||||
/// <summary>
|
||||
/// Check if one user follows another user
|
||||
/// </summary>
|
||||
/// <param name="login">The login name of the user</param>
|
||||
/// <param name="following">The login name of the other user</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#check-if-one-user-follows-another">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation.</returns>
|
||||
Task<bool> IsFollowing(string login, string following);
|
||||
|
||||
/// <summary>
|
||||
/// Follow a user
|
||||
/// </summary>
|
||||
/// <param name="login">The login name of the user to follow</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#follow-a-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation.</returns>
|
||||
Task<bool> Follow(string login);
|
||||
|
||||
/// <summary>
|
||||
/// Unfollow a user
|
||||
/// </summary>
|
||||
/// <param name="login">The login name of the user to unfollow</param>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/#unfollow-a-user">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Unfollow",
|
||||
Justification = "Unfollow is consistent with the GitHub website")]
|
||||
Task Unfollow(string login);
|
||||
}
|
||||
}
|
||||
@@ -64,5 +64,15 @@ namespace Octokit
|
||||
/// <param name="commentUpdate">The modified comment</param>
|
||||
/// <returns></returns>
|
||||
Task<IssueComment> Update(string owner, string name, int number, string commentUpdate);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the specified Issue Comment
|
||||
/// </summary>
|
||||
/// <remarks>http://developer.github.com/v3/issues/comments/#delete-a-comment</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The comment number</param>
|
||||
/// <returns></returns>
|
||||
Task Delete(string owner, string name, int number);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,5 +79,68 @@ namespace Octokit
|
||||
/// <param name="labelUpdate">The data for the label to be updated</param>
|
||||
/// <returns>The updated label</returns>
|
||||
Task<Label> Update(string owner, string repo, string name, LabelUpdate labelUpdate);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a label to an issue
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/issues/labels/#add-labels-to-an-issue">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repo">The name of the repository</param>
|
||||
/// <param name="number">The number of the issue</param>
|
||||
/// <param name="labels">The names of the labels to add</param>
|
||||
/// <returns></returns>
|
||||
Task<IReadOnlyList<Label>> AddToIssue(string owner, string repo, int number, string[] labels);
|
||||
|
||||
/// <summary>
|
||||
/// Removes a label from an issue
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repo">The name of the repository</param>
|
||||
/// <param name="number">The number of the issue</param>
|
||||
/// <param name="label">The name of the label to remove</param>
|
||||
/// <returns></returns>
|
||||
Task RemoveFromIssue(string owner, string repo, int number, string label);
|
||||
|
||||
/// <summary>
|
||||
/// Replaces all labels on the specified issues with the provided labels
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/issues/labels/#replace-all-labels-for-an-issue">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repo">The name of the repository</param>
|
||||
/// <param name="number">The number of the issue</param>
|
||||
/// <param name="labels">The names of the labels to set</param>
|
||||
/// <returns></returns>
|
||||
Task<IReadOnlyList<Label>> ReplaceAllForIssue(string owner, string repo, int number, string[] labels);
|
||||
|
||||
/// <summary>
|
||||
/// Removes all labels from an issue
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/issues/labels/#remove-all-labels-from-an-issue">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repo">The name of the repository</param>
|
||||
/// <param name="number">The number of the issue</param>
|
||||
/// <returns></returns>
|
||||
Task RemoveAllFromIssue(string owner, string repo, int number);
|
||||
|
||||
/// <summary>
|
||||
/// Gets labels for every issue in a milestone
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/issues/labels/#get-labels-for-every-issue-in-a-milestone">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repo">The name of the repository</param>
|
||||
/// <param name="number">The number of the milestone</param>
|
||||
/// <returns></returns>
|
||||
Task<IReadOnlyList<Label>> GetForMilestone(string owner, string repo, int number);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ namespace Octokit
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>An <see cref="IReadOnlyDictionary{TKey,TValue}"/> of emoji and their URI.</returns>
|
||||
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
|
||||
Task<IReadOnlyDictionary<string, Uri>> GetEmojis();
|
||||
Task<IReadOnlyList<Emoji>> GetEmojis();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the rendered Markdown for the specified plain-text Markdown document.
|
||||
|
||||
@@ -40,6 +40,14 @@ namespace Octokit
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
|
||||
Task<IReadOnlyCollection<EmailAddress>> GetEmails();
|
||||
Task<IReadOnlyList<EmailAddress>> GetEmails();
|
||||
|
||||
/// <summary>
|
||||
/// A client for GitHub's User Followers API
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/">Followers API documentation</a> for more information.
|
||||
///</remarks>
|
||||
IFollowersClient Followers { get; }
|
||||
}
|
||||
}
|
||||
|
||||
66
Octokit/Clients/IWatchedClient.cs
Normal file
66
Octokit/Clients/IWatchedClient.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public interface IWatchedClient
|
||||
{
|
||||
/// <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>
|
||||
/// <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);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the watched <see cref="Repository"/>(ies) for the current user.
|
||||
/// </summary>
|
||||
/// <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();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) watched by the specified user.
|
||||
/// </summary>
|
||||
/// <param name="user">The login of the user</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);
|
||||
|
||||
/// <summary>
|
||||
/// Check if a repository is watched by the current authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation</returns>
|
||||
Task<bool> CheckWatched(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Watches a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository to star</param>
|
||||
/// <param name="name">The name of the repository to star</param>
|
||||
/// <param name="newSubscription">A <see cref="NewSubscription"/> instance describing the new subscription to create</param>
|
||||
/// <returns>A <c>bool</c> representing the success of watching</returns>
|
||||
Task<Subscription> WatchRepo(string owner, string name, NewSubscription newSubscription);
|
||||
|
||||
/// <summary>
|
||||
/// Unwatches a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository to unstar</param>
|
||||
/// <param name="name">The name of the repository to unstar</param>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation</returns>
|
||||
[SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId="Unwatch",
|
||||
Justification = "Unwatch is consistent with the GitHub website")]
|
||||
Task<bool> UnwatchRepo(string owner, string name);
|
||||
}
|
||||
}
|
||||
@@ -102,5 +102,21 @@ namespace Octokit
|
||||
|
||||
return ApiConnection.Patch<IssueComment>(ApiUrls.IssueComment(owner, name, number), new BodyWrapper(commentUpdate));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the specified Issue Comment
|
||||
/// </summary>
|
||||
/// <remarks>http://developer.github.com/v3/issues/comments/#delete-a-comment</remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The comment number</param>
|
||||
/// <returns></returns>
|
||||
public Task Delete(string owner, string name, int number)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return ApiConnection.Delete(ApiUrls.IssueComment(owner, name, number));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
@@ -122,5 +123,101 @@ namespace Octokit
|
||||
|
||||
return ApiConnection.Post<Label>(ApiUrls.Label(owner, repo, name), labelUpdate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a label to an issue
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/issues/labels/#add-labels-to-an-issue">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repo">The name of the repository</param>
|
||||
/// <param name="number">The number of the issue</param>
|
||||
/// <param name="labels">The names of the labels to add</param>
|
||||
/// <returns></returns>
|
||||
public Task<IReadOnlyList<Label>> AddToIssue(string owner, string repo, int number, string[] labels)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(repo, "repo");
|
||||
Ensure.ArgumentNotNull(labels, "labels");
|
||||
|
||||
return ApiConnection.Post<IReadOnlyList<Label>>(ApiUrls.IssueLabels(owner, repo, number), labels);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a label from an issue
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repo">The name of the repository</param>
|
||||
/// <param name="number">The number of the issue</param>
|
||||
/// <param name="label">The name of the label to remove</param>
|
||||
/// <returns></returns>
|
||||
public Task RemoveFromIssue(string owner, string repo, int number, string label)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(repo, "repo");
|
||||
Ensure.ArgumentNotNullOrEmptyString(label, "label");
|
||||
|
||||
return ApiConnection.Delete(ApiUrls.IssueLabel(owner, repo, number, label));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces all labels on the specified issues with the provided labels
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/issues/labels/#replace-all-labels-for-an-issue">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repo">The name of the repository</param>
|
||||
/// <param name="number">The number of the issue</param>
|
||||
/// <param name="labels">The names of the labels to set</param>
|
||||
/// <returns></returns>
|
||||
public Task<IReadOnlyList<Label>> ReplaceAllForIssue(string owner, string repo, int number, string[] labels)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(repo, "repo");
|
||||
Ensure.ArgumentNotNull(labels, "labels");
|
||||
|
||||
return ApiConnection.Put<IReadOnlyList<Label>>(ApiUrls.IssueLabels(owner, repo, number), labels);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all labels from an issue
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/issues/labels/#remove-all-labels-from-an-issue">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repo">The name of the repository</param>
|
||||
/// <param name="number">The number of the issue</param>
|
||||
/// <returns></returns>
|
||||
public Task RemoveAllFromIssue(string owner, string repo, int number)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(repo, "repo");
|
||||
|
||||
return ApiConnection.Delete(ApiUrls.IssueLabels(owner, repo, number));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets labels for every issue in a milestone
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/issues/labels/#get-labels-for-every-issue-in-a-milestone">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repo">The name of the repository</param>
|
||||
/// <param name="number">The number of the milestone</param>
|
||||
/// <returns></returns>
|
||||
public Task<IReadOnlyList<Label>> GetForMilestone(string owner, string repo, int number)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(repo, "repo");
|
||||
|
||||
return ApiConnection.GetAll<Label>(ApiUrls.MilestoneLabels(owner, repo, number));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,13 +34,13 @@ namespace Octokit
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>An <see cref="IReadOnlyDictionary{TKey,TValue}"/> of emoji and their URI.</returns>
|
||||
public async Task<IReadOnlyDictionary<string, Uri>> GetEmojis()
|
||||
public async Task<IReadOnlyList<Emoji>> GetEmojis()
|
||||
{
|
||||
var endpoint = new Uri("emojis", UriKind.Relative);
|
||||
var response = await _connection.GetAsync<Dictionary<string, string>>(endpoint, null, null)
|
||||
.ConfigureAwait(false);
|
||||
return new ReadOnlyDictionary<string, Uri>(
|
||||
response.BodyAsObject.ToDictionary(kvp => kvp.Key, kvp => new Uri(kvp.Value)));
|
||||
return new ReadOnlyCollection<Emoji>(
|
||||
response.BodyAsObject.Select(kvp => new Emoji(kvp.Key, new Uri(kvp.Value))).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Octokit
|
||||
public Task<IReadOnlyList<SearchCode>> SearchCode(SearchCodeRequest search)
|
||||
{
|
||||
Ensure.ArgumentNotNull(search, "search");
|
||||
return ApiConnection.GetAll<SearchCode>(ApiUrls.SearchCode(), search.ToParametersDictionary());
|
||||
return ApiConnection.GetAll<SearchCode>(ApiUrls.SearchCode(), search.Parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ namespace Octokit
|
||||
/// <param name="apiConnection">An API connection</param>
|
||||
public UsersClient(IApiConnection apiConnection) : base(apiConnection)
|
||||
{
|
||||
Followers = new FollowersClient(apiConnection);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -64,9 +65,17 @@ namespace Octokit
|
||||
/// Returns emails for the current user.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<IReadOnlyCollection<EmailAddress>> GetEmails()
|
||||
public Task<IReadOnlyList<EmailAddress>> GetEmails()
|
||||
{
|
||||
return ApiConnection.Get<IReadOnlyCollection<EmailAddress>>(ApiUrls.Emails(), null);
|
||||
return ApiConnection.GetAll<EmailAddress>(ApiUrls.Emails(), null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A client for GitHub's User Followers API
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/users/followers/">Followers API documentation</a> for more information.
|
||||
///</remarks>
|
||||
public IFollowersClient Followers { get; private set; }
|
||||
}
|
||||
}
|
||||
|
||||
126
Octokit/Clients/WatchedClient.cs
Normal file
126
Octokit/Clients/WatchedClient.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public class WatchedClient : ApiClient, IWatchedClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Instantiates a new GitHub Activity Watching API client.
|
||||
/// </summary>
|
||||
/// <param name="apiConnection">An API connection</param>
|
||||
public WatchedClient(IApiConnection apiConnection)
|
||||
: base(apiConnection)
|
||||
{
|
||||
}
|
||||
|
||||
/// <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>
|
||||
/// <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)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return ApiConnection.GetAll<User>(ApiUrls.Watchers(owner, name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the watched <see cref="Repository"/>(ies) for the current user.
|
||||
/// </summary>
|
||||
/// <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()
|
||||
{
|
||||
return ApiConnection.GetAll<Repository>(ApiUrls.Watched());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) watched by the specified user.
|
||||
/// </summary>
|
||||
/// <param name="user">The login of the user</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)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
|
||||
return ApiConnection.GetAll<Repository>(ApiUrls.WatchedByUser(user));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if a repository is watched by the current authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation</returns>
|
||||
public async Task<bool> CheckWatched(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
try
|
||||
{
|
||||
var subscription = await ApiConnection.Get<Subscription>(ApiUrls.Watched(owner, name))
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return subscription != null;
|
||||
}
|
||||
catch (NotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Watches a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository to star</param>
|
||||
/// <param name="name">The name of the repository to star</param>
|
||||
/// <param name="newSubscription">A <see cref="NewSubscription"/> instance describing the new subscription to create</param>
|
||||
/// <returns>A <c>bool</c> representing the success of watching</returns>
|
||||
public Task<Subscription> WatchRepo(string owner, string name, NewSubscription newSubscription)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNull(newSubscription, "newSubscription");
|
||||
|
||||
return ApiConnection.Put<Subscription>(ApiUrls.Watched(owner, name), newSubscription);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unwatches a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository to unstar</param>
|
||||
/// <param name="name">The name of the repository to unstar</param>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation</returns>
|
||||
public async Task<bool> UnwatchRepo(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
try
|
||||
{
|
||||
var statusCode = await Connection.DeleteAsync(ApiUrls.Watched(owner, name))
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return statusCode == HttpStatusCode.NoContent;
|
||||
}
|
||||
catch (NotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,6 @@ namespace Octokit
|
||||
User = new UsersClient(apiConnection);
|
||||
SshKey = new SshKeysClient(apiConnection);
|
||||
GitDatabase = new GitDatabaseClient(apiConnection);
|
||||
Tree = new TreesClient(apiConnection);
|
||||
Search = new SearchClient(apiConnection);
|
||||
Deployment = new DeploymentsClient(apiConnection);
|
||||
}
|
||||
@@ -142,7 +141,6 @@ namespace Octokit
|
||||
public IUsersClient User { get; private set; }
|
||||
public INotificationsClient Notification { get; private set; }
|
||||
public IGitDatabaseClient GitDatabase { get; private set; }
|
||||
public ITreesClient Tree { get; private set; }
|
||||
public ISearchClient Search { get; private set; }
|
||||
public IDeploymentsClient Deployment { get; private set; }
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace Octokit
|
||||
static readonly Uri _currentUserOrganizationsUrl = new Uri("user/orgs", UriKind.Relative);
|
||||
static readonly Uri _currentUserSshKeys = new Uri("user/keys", UriKind.Relative);
|
||||
static readonly Uri _currentUserStars = new Uri("user/starred", UriKind.Relative);
|
||||
static readonly Uri _currentUserWatched = new Uri("user/subscriptions", UriKind.Relative);
|
||||
static readonly Uri _currentUserEmailsEndpoint = new Uri("user/emails", UriKind.Relative);
|
||||
static readonly Uri _currentUserAuthorizationsEndpoint = new Uri("authorizations", UriKind.Relative);
|
||||
static readonly Uri _currentUserNotificationsEndpoint = new Uri("notifications", UriKind.Relative);
|
||||
@@ -390,7 +391,7 @@ namespace Octokit
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that returns all of the labels for the specified issue.
|
||||
/// Returns the <see cref="Uri"/> that returns the named label for the specified issue.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repo">The name of the repository</param>
|
||||
@@ -399,7 +400,7 @@ namespace Octokit
|
||||
/// <returns></returns>
|
||||
public static Uri IssueLabel(string owner, string repo, int number, string name)
|
||||
{
|
||||
return "repos/{0}/{1}/issues/{2}/label/{3}".FormatUri(owner, repo, number, name);
|
||||
return "repos/{0}/{1}/issues/{2}/labels/{3}".FormatUri(owner, repo, number, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -414,6 +415,18 @@ namespace Octokit
|
||||
return "repos/{0}/{1}/issues/{2}/labels".FormatUri(owner, repo, number);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that returns all of the labels for all issues in the specified milestone.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repo">The name of the repository</param>
|
||||
/// <param name="number">The milestone number</param>
|
||||
/// <returns></returns>
|
||||
public static Uri MilestoneLabels(string owner, string repo, int number)
|
||||
{
|
||||
return "repos/{0}/{1}/milestones/{2}/labels".FormatUri(owner, repo, number);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that lists the commit statuses for the specified reference.
|
||||
/// </summary>
|
||||
@@ -426,6 +439,44 @@ namespace Octokit
|
||||
return "repos/{0}/{1}/statuses/{2}".FormatUri(owner, name, reference);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that lists the watched repositories for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
public static Uri Watchers(string owner, string name)
|
||||
{
|
||||
return "repos/{0}/{1}/subscribers".FormatUri(owner, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that lists the watched repositories for the authenticated user.
|
||||
/// </summary>
|
||||
public static Uri Watched()
|
||||
{
|
||||
return _currentUserWatched;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that lists the watched repositories for the specified user.
|
||||
/// </summary>
|
||||
/// <param name="user">The user that has the watches</param>
|
||||
public static Uri WatchedByUser(string user)
|
||||
{
|
||||
return "users/{0}/subscriptions".FormatUri(user);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that shows whether the repo is starred by the current user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <returns></returns>
|
||||
public static Uri Watched(string owner, string name)
|
||||
{
|
||||
return "repos/{0}/{1}/subscription".FormatUri(owner, name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that lists the starred repositories for the authenticated user.
|
||||
/// </summary>
|
||||
@@ -804,6 +855,68 @@ namespace Octokit
|
||||
public static Uri DeploymentStatuses(string owner, string name, int deploymentId)
|
||||
{
|
||||
return "repos/{0}/{1}/deployments/{2}/statuses".FormatUri(owner, name, deploymentId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the relative <see cref="Uri"/> for retrieving the
|
||||
/// current users followers
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="Uri"/> for retrieving the current users followers</returns>
|
||||
public static Uri Followers()
|
||||
{
|
||||
return "user/followers".FormatUri();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the relative <see cref="Uri"/> for retrieving
|
||||
/// the followers for the specified user
|
||||
/// </summary>
|
||||
/// <param name="login">name of the user</param>
|
||||
/// <returns>The <see cref="Uri"/> for retrieving the specified users followers</returns>
|
||||
public static Uri Followers(string login)
|
||||
{
|
||||
return "users/{0}/followers".FormatUri(login);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the relative <see cref="Uri"/> for retrieving the users the current user follows
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="Uri"/> for retrieiving the users the current user follows</returns>
|
||||
public static Uri Following()
|
||||
{
|
||||
return "user/following".FormatUri();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the relative <see cref="Uri"/> for retrieving the users the specified user follows
|
||||
/// </summary>
|
||||
/// <param name="login">name of the user</param>
|
||||
/// <returns>The <see cref="Uri"/> for retrieving the users the specified user follows</returns>
|
||||
public static Uri Following(string login)
|
||||
{
|
||||
return "users/{0}/following".FormatUri(login);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the relative <see cref="Uri"/> for checking is the current user is following
|
||||
/// another user
|
||||
/// </summary>
|
||||
/// <param name="following">name of the user followed</param>
|
||||
/// <returns>The <see cref="Uri"/> for checking if the current user follows the specified user.</returns>
|
||||
public static Uri IsFollowing(string following)
|
||||
{
|
||||
return "user/following/{0}".FormatUri(following);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the relative <see cref="Uri"/> for checking if a user is following another user
|
||||
/// </summary>
|
||||
/// <param name="login">name of the user following</param>
|
||||
/// <param name="following">name of the user followed</param>
|
||||
/// <returns>The <see cref="Uri"/> for checking if the specified user follows another user</returns>
|
||||
public static Uri IsFollowing(string login, string following)
|
||||
{
|
||||
return "users/{0}/following/{1}".FormatUri(login, following);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Octokit.Reflection;
|
||||
|
||||
namespace Octokit.Internal
|
||||
{
|
||||
@@ -64,15 +65,6 @@ namespace Octokit.Internal
|
||||
var stringValue = value as string;
|
||||
if (stringValue != null)
|
||||
{
|
||||
if (ReflectionUtils.IsUri(type))
|
||||
{
|
||||
Uri result;
|
||||
if (Uri.TryCreate(stringValue, UriKind.RelativeOrAbsolute, out result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (ReflectionUtils.GetTypeInfo(type).IsEnum)
|
||||
{
|
||||
// remove '-' from values coming in to be able to enum utf-8
|
||||
|
||||
@@ -21,7 +21,6 @@ namespace Octokit
|
||||
IUsersClient User { get; }
|
||||
INotificationsClient Notification { get; }
|
||||
IGitDatabaseClient GitDatabase { get; }
|
||||
ITreesClient Tree { get; }
|
||||
ISearchClient Search { get; }
|
||||
IDeploymentsClient Deployment { get; }
|
||||
}
|
||||
|
||||
17
Octokit/Models/Request/NewSubscription.cs
Normal file
17
Octokit/Models/Request/NewSubscription.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public class NewSubscription
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines if notifications should be received from this repository.
|
||||
/// </summary>
|
||||
public bool Subscribed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines if all notifications should be blocked from this repository.
|
||||
/// </summary>
|
||||
public bool Ignored { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
using Octokit.Internal;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit.Internal;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
@@ -11,42 +11,165 @@ namespace Octokit
|
||||
/// Searching Code/Files
|
||||
/// http://developer.github.com/v3/search/#search-code
|
||||
/// </summary>
|
||||
public class SearchCodeRequest : RequestParameters
|
||||
public class SearchCodeRequest : BaseSearchRequest
|
||||
{
|
||||
public SearchCodeRequest(string term)
|
||||
public SearchCodeRequest(string term) : base(term) { }
|
||||
|
||||
/// <summary>
|
||||
/// Optional Sort field. Can only be indexed, which indicates how recently
|
||||
/// a file has been indexed by the GitHub search infrastructure.
|
||||
/// If not provided, results are sorted by best match.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/search/#search-code
|
||||
/// </remarks>
|
||||
public CodeSearchSort? SortField { get; set; }
|
||||
public override string Sort
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(term, "term");
|
||||
Term = term;
|
||||
Page = 1;
|
||||
PerPage = 100;
|
||||
Order = SortDirection.Descending;
|
||||
get { return SortField.ToParameter(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The search term
|
||||
/// Qualifies which fields are searched. With this qualifier you can restrict
|
||||
/// the search to just the file contents, the file path, or both.
|
||||
/// </summary>
|
||||
[Parameter(Key = "q")]
|
||||
public string Term { get; private set; }
|
||||
/// <remarks>
|
||||
/// https://help.github.com/articles/searching-code#search-in
|
||||
/// </remarks>
|
||||
private IEnumerable<CodeInQualifier> _inQualifier;
|
||||
public IEnumerable<CodeInQualifier> In
|
||||
{
|
||||
get { return _inQualifier; }
|
||||
set
|
||||
{
|
||||
if (value != null && value.Any())
|
||||
{
|
||||
_inQualifier = value.Distinct().ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Optional Sort field. Can only be indexed, which indicates how recently a file has been indexed by the GitHub search infrastructure. If not provided, results are sorted by best match.
|
||||
/// Searches code based on the language it’s written in.
|
||||
/// </summary>
|
||||
//public string Sort { get; set; } //this will need to be re-added
|
||||
/// <remarks>
|
||||
/// https://help.github.com/articles/searching-code#language
|
||||
/// </remarks>
|
||||
public Language? Language { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional Sort order if sort parameter is provided. One of asc or desc; the default is desc.
|
||||
/// Specifies that code from forked repositories should be searched.
|
||||
/// Repository forks will not be searchable unless the fork has more
|
||||
/// stars than the parent repository.
|
||||
/// </summary>
|
||||
public SortDirection Order { get; set; }
|
||||
/// <remarks>
|
||||
/// https://help.github.com/articles/searching-code#forks
|
||||
/// </remarks>
|
||||
public bool? Forks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Page of paginated results
|
||||
/// Finds files that match a certain size (in bytes).
|
||||
/// </summary>
|
||||
public int Page { get; set; }
|
||||
/// <remarks>
|
||||
/// https://help.github.com/articles/searching-code#size
|
||||
/// </remarks>
|
||||
public Range Size { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of items per page
|
||||
/// Specifies the path that the resulting file must be at.
|
||||
/// </summary>
|
||||
[Parameter(Key = "per_page")]
|
||||
public int PerPage { get; set; }
|
||||
/// <remarks>
|
||||
/// https://help.github.com/articles/searching-code#path
|
||||
/// </remarks>
|
||||
public string Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Matches files with a certain extension.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://help.github.com/articles/searching-code#extension
|
||||
/// </remarks>
|
||||
public string Extension { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Limits searches to a specific user.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://help.github.com/articles/searching-code#users-organizations-and-repositories
|
||||
/// </remarks>
|
||||
public string User { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Limits searches to a specific repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// https://help.github.com/articles/searching-code#users-organizations-and-repositories
|
||||
/// </remarks>
|
||||
public string Repo { get; set; }
|
||||
|
||||
[SuppressMessage("Microsoft.Globalization", "CA1304:SpecifyCultureInfo", MessageId = "System.String.ToLower")]
|
||||
public override IReadOnlyCollection<string> MergedQualifiers()
|
||||
{
|
||||
var parameters = new List<string>();
|
||||
|
||||
if (In != null)
|
||||
{
|
||||
parameters.Add(String.Format(CultureInfo.InvariantCulture, "in:{0}",
|
||||
String.Join(",", In.Select(i => i.ToParameter()))));
|
||||
}
|
||||
|
||||
if (Language != null)
|
||||
{
|
||||
parameters.Add(String.Format(CultureInfo.InvariantCulture, "language:{0}", Language.ToParameter()));
|
||||
}
|
||||
|
||||
if (Forks != null)
|
||||
{
|
||||
// API is expecting 'true', bool.ToString() returns 'True', if there is a better way,
|
||||
// please, oh please let me know...
|
||||
parameters.Add(String.Format(CultureInfo.InvariantCulture, "fork:{0}", Forks.Value.ToString().ToLower()));
|
||||
}
|
||||
|
||||
if (Size != null)
|
||||
{
|
||||
parameters.Add(String.Format(CultureInfo.InvariantCulture, "size:{0}", Size));
|
||||
}
|
||||
|
||||
if (Path.IsNotBlank())
|
||||
{
|
||||
parameters.Add(String.Format(CultureInfo.InvariantCulture, "path:{0}", Path));
|
||||
}
|
||||
|
||||
if (Extension.IsNotBlank())
|
||||
{
|
||||
parameters.Add(String.Format(CultureInfo.InvariantCulture, "extension:{0}", Extension));
|
||||
}
|
||||
|
||||
if (User.IsNotBlank())
|
||||
{
|
||||
parameters.Add(String.Format(CultureInfo.InvariantCulture, "user:{0}", User));
|
||||
}
|
||||
|
||||
if (Repo.IsNotBlank())
|
||||
{
|
||||
parameters.Add(String.Format(CultureInfo.InvariantCulture, "repo:{0}", Repo));
|
||||
}
|
||||
|
||||
return parameters;
|
||||
}
|
||||
}
|
||||
|
||||
public enum CodeSearchSort
|
||||
{
|
||||
[Parameter(Value = "indexed")]
|
||||
Indexed
|
||||
}
|
||||
|
||||
public enum CodeInQualifier
|
||||
{
|
||||
[Parameter(Value = "file")]
|
||||
File,
|
||||
[Parameter(Value = "path")]
|
||||
Path
|
||||
}
|
||||
}
|
||||
|
||||
19
Octokit/Models/Response/Emoji.cs
Normal file
19
Octokit/Models/Response/Emoji.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public class Emoji
|
||||
{
|
||||
public Emoji(string name, Uri url)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNull(url, "url");
|
||||
|
||||
Name = name;
|
||||
Url = url;
|
||||
}
|
||||
|
||||
public string Name { get; private set; }
|
||||
public Uri Url { get; private set; }
|
||||
}
|
||||
}
|
||||
37
Octokit/Models/Response/Subscription.cs
Normal file
37
Octokit/Models/Response/Subscription.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public class Subscription
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines if notifications should be received from this repository.
|
||||
/// </summary>
|
||||
public bool Subscribed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines if all notifications should be blocked from this repository.
|
||||
/// </summary>
|
||||
public bool Ignored { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Url of the label
|
||||
/// </summary>
|
||||
public string Reason { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DateTimeOffset"/> for when this <see cref="Subscription"/> was created.
|
||||
/// </summary>
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The API URL for this <see cref="Subscription"/>.
|
||||
/// </summary>
|
||||
public Uri Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The API URL for this <see cref="Repository"/>.
|
||||
/// </summary>
|
||||
public Uri RepositoryUrl { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -68,6 +68,7 @@
|
||||
<Compile Include="Clients\ITagsClient.cs" />
|
||||
<Compile Include="Clients\ITreesClient.cs" />
|
||||
<Compile Include="Clients\ITeamsClient.cs" />
|
||||
<Compile Include="Clients\IWatchedClient.cs" />
|
||||
<Compile Include="Clients\MilestonesClient.cs" />
|
||||
<Compile Include="Clients\OrganizationMembersClient.cs" />
|
||||
<Compile Include="Clients\ReferencesClient.cs" />
|
||||
@@ -75,6 +76,7 @@
|
||||
<Compile Include="Clients\TagsClient.cs" />
|
||||
<Compile Include="Clients\TreesClient.cs" />
|
||||
<Compile Include="Clients\TeamsClient.cs" />
|
||||
<Compile Include="Clients\WatchedClient.cs" />
|
||||
<Compile Include="Exceptions\NotFoundException.cs" />
|
||||
<Compile Include="Clients\IAssigneesClient.cs" />
|
||||
<Compile Include="Clients\IIssuesClient.cs" />
|
||||
@@ -89,6 +91,7 @@
|
||||
<Compile Include="Models\Request\NewLabel.cs" />
|
||||
<Compile Include="Models\Request\NewMilestone.cs" />
|
||||
<Compile Include="Models\Request\NewReference.cs" />
|
||||
<Compile Include="Models\Request\NewSubscription.cs" />
|
||||
<Compile Include="Models\Request\NewTag.cs" />
|
||||
<Compile Include="Models\Request\NewTree.cs" />
|
||||
<Compile Include="Models\Request\NewTreeItem.cs" />
|
||||
@@ -126,6 +129,7 @@
|
||||
<Compile Include="Models\Request\MilestoneRequest.cs" />
|
||||
<Compile Include="Models\Response\Reference.cs" />
|
||||
<Compile Include="Models\Response\Signature.cs" />
|
||||
<Compile Include="Models\Response\Subscription.cs" />
|
||||
<Compile Include="Models\Response\TagObject.cs" />
|
||||
<Compile Include="Models\Response\TreeItem.cs" />
|
||||
<Compile Include="Models\Response\TreeResponse.cs" />
|
||||
@@ -256,6 +260,9 @@
|
||||
<Compile Include="Models\Response\Deployment.cs" />
|
||||
<Compile Include="Models\Request\BaseSearchRequest.cs" />
|
||||
<Compile Include="Helpers\EnumExtensions.cs" />
|
||||
<Compile Include="Models\Response\Emoji.cs" />
|
||||
<Compile Include="Clients\FollowersClient.cs" />
|
||||
<Compile Include="Clients\IFollowersClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -266,6 +266,13 @@
|
||||
<Compile Include="Models\Response\Deployment.cs" />
|
||||
<Compile Include="Models\Request\BaseSearchRequest.cs" />
|
||||
<Compile Include="Helpers\EnumExtensions.cs" />
|
||||
<Compile Include="Clients\IWatchedClient.cs" />
|
||||
<Compile Include="Clients\WatchedClient.cs" />
|
||||
<Compile Include="Models\Request\NewSubscription.cs" />
|
||||
<Compile Include="Models\Response\Subscription.cs" />
|
||||
<Compile Include="Models\Response\Emoji.cs" />
|
||||
<Compile Include="Clients\FollowersClient.cs" />
|
||||
<Compile Include="Clients\IFollowersClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -261,6 +261,13 @@
|
||||
<Compile Include="Models\Response\Deployment.cs" />
|
||||
<Compile Include="Models\Request\BaseSearchRequest.cs" />
|
||||
<Compile Include="Helpers\EnumExtensions.cs" />
|
||||
<Compile Include="Clients\IWatchedClient.cs" />
|
||||
<Compile Include="Clients\WatchedClient.cs" />
|
||||
<Compile Include="Models\Request\NewSubscription.cs" />
|
||||
<Compile Include="Models\Response\Subscription.cs" />
|
||||
<Compile Include="Models\Response\Emoji.cs" />
|
||||
<Compile Include="Clients\FollowersClient.cs" />
|
||||
<Compile Include="Clients\IFollowersClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -57,6 +57,7 @@
|
||||
<Compile Include="Clients\CommitsClient.cs" />
|
||||
<Compile Include="Clients\CommitStatusClient.cs" />
|
||||
<Compile Include="Clients\EventsClient.cs" />
|
||||
<Compile Include="Clients\FollowersClient.cs" />
|
||||
<Compile Include="Clients\GistsClient.cs" />
|
||||
<Compile Include="Clients\GitDatabaseClient.cs" />
|
||||
<Compile Include="Clients\IActivitiesClient.cs" />
|
||||
@@ -66,6 +67,7 @@
|
||||
<Compile Include="Clients\ICommitsClient.cs" />
|
||||
<Compile Include="Clients\ICommitStatusClient.cs" />
|
||||
<Compile Include="Clients\IEventsClient.cs" />
|
||||
<Compile Include="Clients\IFollowersClient.cs" />
|
||||
<Compile Include="Clients\IGistsClient.cs" />
|
||||
<Compile Include="Clients\IGitDatabaseClient.cs" />
|
||||
<Compile Include="Clients\IIssueCommentsClient.cs" />
|
||||
@@ -90,6 +92,7 @@
|
||||
<Compile Include="Clients\ITreesClient.cs" />
|
||||
<Compile Include="Clients\ITeamsClient.cs" />
|
||||
<Compile Include="Clients\IUsersClient.cs" />
|
||||
<Compile Include="Clients\IWatchedClient.cs" />
|
||||
<Compile Include="Clients\MilestonesClient.cs" />
|
||||
<Compile Include="Clients\MiscellaneousClient.cs" />
|
||||
<Compile Include="Clients\NotificationsClient.cs" />
|
||||
@@ -104,6 +107,7 @@
|
||||
<Compile Include="Clients\TreesClient.cs" />
|
||||
<Compile Include="Clients\TeamsClient.cs" />
|
||||
<Compile Include="Clients\UsersClient.cs" />
|
||||
<Compile Include="Clients\WatchedClient.cs" />
|
||||
<Compile Include="Exceptions\ApiException.cs" />
|
||||
<Compile Include="Exceptions\ApiValidationException.cs" />
|
||||
<Compile Include="Exceptions\AuthorizationException.cs" />
|
||||
@@ -170,6 +174,7 @@
|
||||
<Compile Include="Models\Request\NewMilestone.cs" />
|
||||
<Compile Include="Models\Request\NewReference.cs" />
|
||||
<Compile Include="Models\Request\NewRepository.cs" />
|
||||
<Compile Include="Models\Request\NewSubscription.cs" />
|
||||
<Compile Include="Models\Request\NewTag.cs" />
|
||||
<Compile Include="Models\Request\NewTree.cs" />
|
||||
<Compile Include="Models\Request\NewTreeItem.cs" />
|
||||
@@ -222,6 +227,7 @@
|
||||
<Compile Include="Models\Response\Signature.cs" />
|
||||
<Compile Include="Models\Response\SshKey.cs" />
|
||||
<Compile Include="Models\Response\SshKeyInfo.cs" />
|
||||
<Compile Include="Models\Response\Subscription.cs" />
|
||||
<Compile Include="Models\Response\TagObject.cs" />
|
||||
<Compile Include="Models\Response\TreeItem.cs" />
|
||||
<Compile Include="Models\Response\TreeResponse.cs" />
|
||||
@@ -254,6 +260,7 @@
|
||||
<Compile Include="Models\Response\DeploymentStatus.cs" />
|
||||
<Compile Include="Models\Response\Deployment.cs" />
|
||||
<Compile Include="Models\Request\BaseSearchRequest.cs" />
|
||||
<Compile Include="Models\Response\Emoji.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CodeAnalysisDictionary Include="..\CustomDictionary.xml">
|
||||
|
||||
@@ -62,12 +62,17 @@
|
||||
<Compile Include="Models\Response\Deployment.cs" />
|
||||
<Compile Include="Clients\DeploymentsClient.cs" />
|
||||
<Compile Include="Clients\IDeploymentsClient.cs" />
|
||||
<Compile Include="Clients\IWatchedClient.cs" />
|
||||
<Compile Include="Clients\SearchClient.cs" />
|
||||
<Compile Include="Clients\ISearchClient.cs" />
|
||||
<Compile Include="Clients\WatchedClient.cs" />
|
||||
<Compile Include="Clients\IFollowersClient.cs" />
|
||||
<Compile Include="Clients\FollowersClient.cs" />
|
||||
<Compile Include="Models\Request\BaseSearchRequest.cs" />
|
||||
<Compile Include="Helpers\EnumExtensions.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Models\Request\NewSubscription.cs" />
|
||||
<Compile Include="Models\Request\SearchCodeRequest.cs" />
|
||||
<Compile Include="Models\Request\SearchIssuesRequest.cs" />
|
||||
<Compile Include="Models\Request\SearchQualifierOperator.cs" />
|
||||
@@ -100,8 +105,10 @@
|
||||
<Compile Include="Models\Request\NewTree.cs" />
|
||||
<Compile Include="Clients\TreesClient.cs" />
|
||||
<Compile Include="Models\Response\Branch.cs" />
|
||||
<Compile Include="Models\Response\Emoji.cs" />
|
||||
<Compile Include="Models\Response\GistComment.cs" />
|
||||
<Compile Include="Models\Response\Reference.cs" />
|
||||
<Compile Include="Models\Response\Subscription.cs" />
|
||||
<Compile Include="Models\Response\TreeItem.cs" />
|
||||
<Compile Include="Models\Response\TreeResponse.cs" />
|
||||
<Compile Include="Models\Response\Activity.cs" />
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
// <website>https://github.com/facebook-csharp-sdk/simple-json</website>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
// VERSION: 0.28.0
|
||||
// VERSION: 0.30.0
|
||||
|
||||
// NOTE: uncomment the following line to make SimpleJson class internal.
|
||||
//#define SIMPLE_JSON_INTERNAL
|
||||
@@ -51,6 +51,7 @@ using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#if !SIMPLE_JSON_NO_LINQ_EXPRESSION
|
||||
using System.Linq.Expressions;
|
||||
#endif
|
||||
@@ -63,7 +64,7 @@ using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using Octokit.Internal;
|
||||
using Octokit.Reflection;
|
||||
|
||||
// ReSharper disable LoopCanBeConvertedToQuery
|
||||
// ReSharper disable RedundantExplicitArrayCreation
|
||||
@@ -1308,6 +1309,14 @@ namespace Octokit
|
||||
return DateTimeOffset.ParseExact(str, Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal);
|
||||
if (type == typeof(Guid) || (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(Guid)))
|
||||
return new Guid(str);
|
||||
if (type == typeof(Uri))
|
||||
{
|
||||
bool isValid = Uri.IsWellFormedUriString(str, UriKind.RelativeOrAbsolute);
|
||||
|
||||
Uri result;
|
||||
if (isValid && Uri.TryCreate(str, UriKind.RelativeOrAbsolute, out result))
|
||||
return result;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
else
|
||||
@@ -1539,7 +1548,7 @@ namespace Octokit
|
||||
|
||||
#endif
|
||||
|
||||
namespace Internal
|
||||
namespace Reflection
|
||||
{
|
||||
// This class is meant to be copied into other libraries. So we want to exclude it from Code Analysis rules
|
||||
// that might be in place in the target project.
|
||||
@@ -1667,11 +1676,6 @@ namespace Octokit
|
||||
return GetTypeInfo(type).IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>);
|
||||
}
|
||||
|
||||
public static bool IsUri(Type type)
|
||||
{
|
||||
return GetTypeInfo(type) == GetTypeInfo(typeof(Uri));
|
||||
}
|
||||
|
||||
public static object ToNullableType(object obj, Type nullableType)
|
||||
{
|
||||
return obj == null ? null : Convert.ChangeType(obj, Nullable.GetUnderlyingType(nullableType), CultureInfo.InvariantCulture);
|
||||
@@ -1723,41 +1727,18 @@ namespace Octokit
|
||||
public static IEnumerable<PropertyInfo> GetProperties(Type type)
|
||||
{
|
||||
#if SIMPLE_JSON_TYPEINFO
|
||||
var typeInfo = type.GetTypeInfo();
|
||||
var properties = typeInfo.DeclaredProperties;
|
||||
if(typeInfo.BaseType == null)
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
var info = type.GetTypeInfo();
|
||||
|
||||
var result = new List<PropertyInfo>();
|
||||
foreach (var property in properties)
|
||||
{
|
||||
result.Add(property);
|
||||
}
|
||||
var baseProperties = info.BaseType != null && info.BaseType != typeof(Object)
|
||||
? GetProperties(info.BaseType)
|
||||
: new PropertyInfo[0];
|
||||
|
||||
var baseProperties = GetProperties(typeInfo.BaseType);
|
||||
foreach (var property in baseProperties)
|
||||
{
|
||||
result.Add(property);
|
||||
}
|
||||
|
||||
return result;
|
||||
return info.DeclaredProperties.Concat(baseProperties);
|
||||
#else
|
||||
return type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static IList<PropertyInfo> Build(IEnumerable<PropertyInfo> properties)
|
||||
{
|
||||
var propertyList = new List<PropertyInfo>();
|
||||
foreach (var property in properties)
|
||||
{
|
||||
propertyList.Add(property);
|
||||
}
|
||||
return propertyList;
|
||||
}
|
||||
|
||||
public static IEnumerable<FieldInfo> GetFields(Type type)
|
||||
{
|
||||
#if SIMPLE_JSON_TYPEINFO
|
||||
|
||||
@@ -5,5 +5,5 @@
|
||||
<package id="Rx-Linq" version="2.1.30214.0" targetFramework="net40" requireReinstallation="True" />
|
||||
<package id="Rx-Main" version="2.1.30214.0" targetFramework="net40" />
|
||||
<package id="Rx-PlatformServices" version="2.1.30214.0" targetFramework="net40" requireReinstallation="True" />
|
||||
<package id="SimpleJson" version="0.28.0" targetFramework="net40" developmentDependency="true" />
|
||||
<package id="SimpleJson" version="0.30.0" targetFramework="net45" developmentDependency="true" />
|
||||
</packages>
|
||||
@@ -1,3 +1,18 @@
|
||||
### New in 0.1.8 (Released 2014/01/22)
|
||||
* Added IRepositoryClient.GetAllBranches - #270 via @goalie7960
|
||||
* Install-Package should add reference to System.Net.Http - #286 via @alfhenrik
|
||||
* Return a more helpful error if invalid refs path provided - #288 via @alfhenrik
|
||||
* Refactor SearchIssuesRequest to match the API - #290 via @alfhenrik
|
||||
* Deprecate custom Releases Accept header - #291 via @shiftkey
|
||||
* Fix date format used in DateRange - #293 via @alfhenrik
|
||||
* Add base class for search requests - #301 via @hahmed
|
||||
* Deprecate IGitHubClient.Blob - #305 via @shiftkey
|
||||
* Improving Proxy Server support - #306 via @shiftkey
|
||||
* Add integration tests for IRepositoryClient.GetAllBranches - #309 via @lbargaoanu
|
||||
* Refactor SearchCodeRequest to match the API - #311 from @alfhenrik
|
||||
* Implemented Delete for IssueCommentsClient - #315 from @pmacn
|
||||
* Implemented missing methods for IssueLabels - #316 from @pmacn
|
||||
|
||||
### New in 0.1.7 (Released 2013/12/27)
|
||||
* New client for repository search - #226 and @273 via @hahmed
|
||||
* Bugfix for creating/updating issue comments - #262 via @tpeczek
|
||||
|
||||
@@ -3,11 +3,11 @@ using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyProductAttribute("Octokit")]
|
||||
[assembly: AssemblyVersionAttribute("0.1.7")]
|
||||
[assembly: AssemblyFileVersionAttribute("0.1.7")]
|
||||
[assembly: AssemblyVersionAttribute("0.1.8")]
|
||||
[assembly: AssemblyFileVersionAttribute("0.1.8")]
|
||||
[assembly: ComVisibleAttribute(false)]
|
||||
namespace System {
|
||||
internal static class AssemblyVersionInformation {
|
||||
internal const string Version = "0.1.7";
|
||||
internal const string Version = "0.1.8";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@ IF NOT [%2]==[] (set BUILDMODE="%2")
|
||||
:: we need to break the dependency chain
|
||||
:: this ensures we do a build before running any tests
|
||||
|
||||
if TARGET=="Default" (SET RunBuild=1)
|
||||
if TARGET=="RunUnitTests" (SET RunBuild=1)
|
||||
if TARGET=="RunIntegrationTests" (SET RunBuild=1)
|
||||
if TARGET=="CreatePackages" (SET RunBuild=1)
|
||||
if %TARGET%=="Default" (SET RunBuild=1)
|
||||
if %TARGET%=="RunUnitTests" (SET RunBuild=1)
|
||||
if %TARGET%=="RunIntegrationTests" (SET RunBuild=1)
|
||||
if %TARGET%=="CreatePackages" (SET RunBuild=1)
|
||||
|
||||
if NOT "%RunBuild%"=="" (
|
||||
"tools\FAKE.Core\tools\Fake.exe" "build.fsx" "target=BuildApp" "buildMode=%BUILDMODE%"
|
||||
|
||||
@@ -67,6 +67,7 @@ Target "UnitTests" (fun _ ->
|
||||
|> xUnit (fun p ->
|
||||
{p with
|
||||
XmlOutput = true
|
||||
Verbose = false
|
||||
OutputDir = testResultsDir })
|
||||
)
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,3 +1,33 @@
|
||||
|
||||
================================================================================================
|
||||
1.7.0 Release
|
||||
================================================================================================
|
||||
|
||||
Auto-substitute for pure virtual classes with at least one public static method, which
|
||||
means some methods and properties on substitutes that used to return null by default will now
|
||||
return a new substitute of that type.
|
||||
|
||||
Reason:
|
||||
Keep consistency with the behaviour of other pure virtual classes.
|
||||
|
||||
Fix:
|
||||
Explicitly return null from methods and property getters when required for a test.
|
||||
e.g. sub.Method().Returns(x => null);
|
||||
|
||||
------------------------------------------------------------------------------------------------
|
||||
|
||||
Moved `Received.InOrder` feature from `NSubstitute.Experimental` to main `NSubstitute` namespace.
|
||||
Obsoleted original `NSubstitute.Experimental.Received`.
|
||||
|
||||
This can result in ambiguous reference compiler errors and obsolete member compiler earnings.
|
||||
|
||||
Reason:
|
||||
Promoted experimental Received feature to core library.
|
||||
|
||||
Fix:
|
||||
Import `NSubstitute` namespace instead of `NSubstitute.Experimental`.
|
||||
(If `NSubstitute` is already imported just delete the `using NSubstitute.Experimental;` line from your fixtures.)
|
||||
|
||||
================================================================================================
|
||||
1.5.0 Release
|
||||
================================================================================================
|
||||
@@ -1,3 +1,13 @@
|
||||
1.7.1 (January 2014)
|
||||
* [FIX] Ambiguous arg exception with out/ref parameters. Thanks to Alexandr Nikitin. (#129)
|
||||
|
||||
1.7.0 (January 2014)
|
||||
* [NEW] Partial subs (Substitute.ForPartsOf<T>()). Thanks to Alexandr Nikitin for tonnes of hard work on this feature (and for putting up with a vacillating project owner :)).
|
||||
* [UPDATE] Received.InOrder moved out of Experimental namespace.
|
||||
* [FIX] Argument matching with optional parameters. Thanks to Peter Wiles. (#111)
|
||||
* [FIX] Argument matching with out/ref. Thanks to Kevin Bosman. (#111)
|
||||
* [FIX] The default return value for any call that returns a concrete type that is purely virtual, but also has at least one public static method in it will be a substitute rather than null. Thanks to Robert Moore (@robdmoore) for this contribution. (#118)
|
||||
|
||||
1.6.1 (June 2013)
|
||||
* [FIX] Detect and throw on type mismatches in Returns() caused by Returns(ConfigureOtherSub()).
|
||||
* [FIX] Support raising exceptions that do not implement a serialisation constructor (#110). Thanks to Alexandr Nikitin for this contribution.
|
||||
BIN
packages/NSubstitute.1.7.1.0/NSubstitute.1.7.1.0.nupkg
vendored
Normal file
BIN
packages/NSubstitute.1.7.1.0/NSubstitute.1.7.1.0.nupkg
vendored
Normal file
Binary file not shown.
@@ -2,7 +2,7 @@
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>NSubstitute</id>
|
||||
<version>1.6.1.0</version>
|
||||
<version>1.7.1.0</version>
|
||||
<authors>Anthony Egerton, David Tchepak</authors>
|
||||
<owners>Anthony Egerton, David Tchepak</owners>
|
||||
<licenseUrl>https://github.com/nsubstitute/NSubstitute/raw/master/LICENSE.txt</licenseUrl>
|
||||
@@ -108,12 +108,6 @@ Finally, we can raise events on our substitutes (unfortunately C# dramatically r
|
||||
|
||||
### Building
|
||||
|
||||
If you have Visual Studio 2008 or 2010 you should be able to compile NSubstitute and run the unit tests using the NUnit GUI or console test runner (see the ThirdParty directory).
|
||||
If you have Visual Studio 2008, 2010, 2012, or 2013 you should be able to compile NSubstitute and run the unit tests using the NUnit GUI or console test runner (see the ThirdParty directory).
|
||||
To do full builds you'll also need Ruby and rake to run the rakefile.
|
||||
|
||||
### NOTE: Framework Multi-Targeting
|
||||
|
||||
[Brendan](https://github.com/shiftkey) is updating the build process to [support multiple framework versions](https://github.com/nsubstitute/NSubstitute/wiki/Silverlight-port), including Silverlight. See the [Silverlight port](https://github.com/nsubstitute/NSubstitute/wiki/Silverlight-port) wiki page for current status.
|
||||
|
||||
|
||||
|
||||
@@ -100,13 +100,13 @@
|
||||
<param name="useArgument"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:NSubstitute.IArgumentMatcher">
|
||||
<member name="T:NSubstitute.Core.Arguments.IArgumentMatcher">
|
||||
<summary>
|
||||
Provides a specification for arguments for use with <see ctype="Arg.Matches (IArgumentMatcher)" />.
|
||||
Can additionally implement <see ctype="IDescribeNonMatches" /> to give descriptions when arguments do not match.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:NSubstitute.IArgumentMatcher.IsSatisfiedBy(System.Object)">
|
||||
<member name="M:NSubstitute.Core.Arguments.IArgumentMatcher.IsSatisfiedBy(System.Object)">
|
||||
<summary>
|
||||
Checks whether the <paramref name="argument"/> satisfies the condition of the matcher.
|
||||
If this throws an exception the argument will be treated as non-matching.
|
||||
@@ -114,7 +114,7 @@
|
||||
<param name="argument"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:NSubstitute.IDescribeNonMatches.DescribeFor(System.Object)">
|
||||
<member name="M:NSubstitute.Core.IDescribeNonMatches.DescribeFor(System.Object)">
|
||||
<summary>
|
||||
Describes how the <paramref name="argument"/> does not match the condition specified by this class, or <see cref="F:System.String.Empty"/>
|
||||
if a detailed description can not be provided for the argument.
|
||||
@@ -162,6 +162,14 @@
|
||||
<param name="seperator"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:NSubstitute.Core.Maybe`1">
|
||||
<summary>
|
||||
Particularly poor implementation of Maybe/Option type.
|
||||
This is just filling an immediate need; use FSharpOption or XSharpx or similar for a
|
||||
real implementation.
|
||||
</summary>
|
||||
<typeparam name="T"></typeparam>
|
||||
</member>
|
||||
<member name="T:NSubstitute.Core.RobustThreadLocal`1">
|
||||
<summary>
|
||||
Delegates to ThreadLocal<T>, but wraps Value property access in try/catch to swallow ObjectDisposedExceptions.
|
||||
@@ -170,6 +178,16 @@
|
||||
</summary>
|
||||
<typeparam name="T"></typeparam>
|
||||
</member>
|
||||
<member name="F:NSubstitute.Core.SubstituteConfig.OverrideAllCalls">
|
||||
<summary>
|
||||
Standard substitute behaviour; replace all calls with substituted behaviour.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:NSubstitute.Core.SubstituteConfig.CallBaseByDefault">
|
||||
<summary>
|
||||
Partial substitute; use base behaviour unless explicitly overriden.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Experimental.Received.InOrder(System.Action)">
|
||||
<summary>
|
||||
*EXPERIMENTAL* Asserts the calls to the substitutes contained in the given Action were
|
||||
@@ -178,14 +196,14 @@
|
||||
</summary>
|
||||
<param name="calls">Action containing calls to substitutes in the expected order</param>
|
||||
</member>
|
||||
<member name="T:NSubstitute.IArgumentMatcher`1">
|
||||
<member name="T:NSubstitute.Core.Arguments.IArgumentMatcher`1">
|
||||
<summary>
|
||||
Provides a specification for arguments for use with <see ctype="Arg.Matches < T >(IArgumentMatcher)" />.
|
||||
Can additionally implement <see ctype="IDescribeNonMatches" /> to give descriptions when arguments do not match.
|
||||
</summary>
|
||||
<typeparam name="T">Matches arguments of type <typeparamref name="T"/> or compatible type.</typeparam>
|
||||
</member>
|
||||
<member name="M:NSubstitute.IArgumentMatcher`1.IsSatisfiedBy(`0)">
|
||||
<member name="M:NSubstitute.Core.Arguments.IArgumentMatcher`1.IsSatisfiedBy(`0)">
|
||||
<summary>
|
||||
Checks whether the <paramref name="argument"/> satisfies the condition of the matcher.
|
||||
If this throws an exception the argument will be treated as non-matching.
|
||||
@@ -193,6 +211,14 @@
|
||||
<param name="argument"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Received.InOrder(System.Action)">
|
||||
<summary>
|
||||
Asserts the calls to the substitutes contained in the given Action were
|
||||
received by these substitutes in the same order. Calls to property getters are not included
|
||||
in the assertion.
|
||||
</summary>
|
||||
<param name="calls">Action containing calls to substitutes in the expected order</param>
|
||||
</member>
|
||||
<member name="T:NSubstitute.Routing.Handlers.ClearLastCallRouterHandler">
|
||||
<summary>
|
||||
Clears last call router on SubstitutionContext for routes that do not require it.
|
||||
@@ -201,6 +227,33 @@
|
||||
This is to help prevent static state bleeding over into future calls.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Core.CallInfo.Args">
|
||||
<summary>
|
||||
Get the arguments passed to this call.
|
||||
</summary>
|
||||
<returns>Array of all arguments passed to this call</returns>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Core.CallInfo.ArgTypes">
|
||||
<summary>
|
||||
Gets the types of all the arguments passed to this call.
|
||||
</summary>
|
||||
<returns>Array of types of all arguments passed to this call</returns>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Core.CallInfo.Arg``1">
|
||||
<summary>
|
||||
Gets the argument of type `T` passed to this call. This will throw if there are no arguments
|
||||
of this type, or if there is more than one matching argument.
|
||||
</summary>
|
||||
<typeparam name="T">The type of the argument to retrieve</typeparam>
|
||||
<returns>The argument passed to the call, or throws if there is not exactly one argument of this type</returns>
|
||||
</member>
|
||||
<member name="P:NSubstitute.Core.CallInfo.Item(System.Int32)">
|
||||
<summary>
|
||||
Gets the nth argument to this call.
|
||||
</summary>
|
||||
<param name="index">Index of argument</param>
|
||||
<returns>The value of the argument at the given index</returns>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Raise.EventWith``1(System.Object,``0)">
|
||||
<summary>
|
||||
Raise an event for an <c>EventHandler<TEventArgs></c> event with the provided <paramref name="sender"/> and <paramref name="eventArgs"/>.
|
||||
@@ -258,7 +311,7 @@
|
||||
<member name="M:NSubstitute.Substitute.For``3(System.Object[])">
|
||||
<summary>
|
||||
<para>Substitute for multiple interfaces or a class that implements multiple interfaces. At most one class can be specified.</para>
|
||||
If additional interfaces are required use the <see cref="M:For(System.Type[], System.Object[])" /> overload.
|
||||
If additional interfaces are required use the <see cref="M:NSubstitute.Substitute.For(System.Type[],System.Object[])"/> overload.
|
||||
<para>Be careful when specifying a class, as all non-virtual members will actually be executed. Only virtual members
|
||||
can be recorded or have return values specified.</para>
|
||||
</summary>
|
||||
@@ -278,6 +331,18 @@
|
||||
<param name="constructorArguments">Arguments required to construct a class being substituted. Not required for interfaces or classes with default constructors.</param>
|
||||
<returns>A substitute implementing the specified types.</returns>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Substitute.ForPartsOf``1(System.Object[])">
|
||||
<summary>
|
||||
Create a substitute for a class that behaves just like a real instance of the class, but also
|
||||
records calls made to its virtual members and allows for specific members to be substituted
|
||||
by using <see cref="M:NSubstitute.Core.WhenCalled`1.DoNotCallBase">When(() => call).DoNotCallBase()</see> or by
|
||||
<see cref="M:NSubstitute.SubstituteExtensions.Returns``1(``0,``0,``0[])">setting a value to return value</see> for that member.
|
||||
</summary>
|
||||
<typeparam name="T">The type to substitute for parts of. Must be a class; not a delegate or interface.</typeparam>
|
||||
<param name="constructorArguments"></param>
|
||||
<returns>An instance of the class that will execute real methods when called, but allows parts to be selectively
|
||||
overridden via `Returns` and `When..DoNotCallBase`.</returns>
|
||||
</member>
|
||||
<member name="M:NSubstitute.SubstituteExtensions.Returns``1(``0,``0,``0[])">
|
||||
<summary>
|
||||
Set a return value for this call.
|
||||
@@ -406,11 +471,34 @@
|
||||
<param name="substitute"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Core.SubstituteFactory.Create(System.Type[],System.Object[])">
|
||||
<summary>
|
||||
Create a substitute for the given types.
|
||||
</summary>
|
||||
<param name="typesToProxy"></param>
|
||||
<param name="constructorArguments"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Core.SubstituteFactory.CreatePartial(System.Type[],System.Object[])">
|
||||
<summary>
|
||||
Create an instance of the given types, with calls configured to call the base implementation
|
||||
where possible. Parts of the instance can be substituted using
|
||||
<see cref="M:NSubstitute.SubstituteExtensions.Returns``1(``0,``0,``0[])">Returns()</see>.
|
||||
</summary>
|
||||
<param name="typesToProxy"></param>
|
||||
<param name="constructorArguments"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Core.WhenCalled`1.Do(System.Action{NSubstitute.Core.CallInfo})">
|
||||
<summary>
|
||||
Perform this action when called.
|
||||
</summary>
|
||||
<param name="callbackWithArguments"></param>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Core.WhenCalled`1.DoNotCallBase">
|
||||
<summary>
|
||||
Do not call the base implementation on future calls. For us with partial substitutes.
|
||||
</summary>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
BIN
packages/NSubstitute.1.7.1.0/lib/NET35/NSubstitute.dll
vendored
Normal file
BIN
packages/NSubstitute.1.7.1.0/lib/NET35/NSubstitute.dll
vendored
Normal file
Binary file not shown.
@@ -100,13 +100,13 @@
|
||||
<param name="useArgument"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:NSubstitute.IArgumentMatcher">
|
||||
<member name="T:NSubstitute.Core.Arguments.IArgumentMatcher">
|
||||
<summary>
|
||||
Provides a specification for arguments for use with <see ctype="Arg.Matches (IArgumentMatcher)" />.
|
||||
Can additionally implement <see ctype="IDescribeNonMatches" /> to give descriptions when arguments do not match.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:NSubstitute.IArgumentMatcher.IsSatisfiedBy(System.Object)">
|
||||
<member name="M:NSubstitute.Core.Arguments.IArgumentMatcher.IsSatisfiedBy(System.Object)">
|
||||
<summary>
|
||||
Checks whether the <paramref name="argument"/> satisfies the condition of the matcher.
|
||||
If this throws an exception the argument will be treated as non-matching.
|
||||
@@ -114,7 +114,7 @@
|
||||
<param name="argument"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:NSubstitute.IDescribeNonMatches.DescribeFor(System.Object)">
|
||||
<member name="M:NSubstitute.Core.IDescribeNonMatches.DescribeFor(System.Object)">
|
||||
<summary>
|
||||
Describes how the <paramref name="argument"/> does not match the condition specified by this class, or <see cref="F:System.String.Empty"/>
|
||||
if a detailed description can not be provided for the argument.
|
||||
@@ -162,6 +162,14 @@
|
||||
<param name="seperator"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:NSubstitute.Core.Maybe`1">
|
||||
<summary>
|
||||
Particularly poor implementation of Maybe/Option type.
|
||||
This is just filling an immediate need; use FSharpOption or XSharpx or similar for a
|
||||
real implementation.
|
||||
</summary>
|
||||
<typeparam name="T"></typeparam>
|
||||
</member>
|
||||
<member name="T:NSubstitute.Core.RobustThreadLocal`1">
|
||||
<summary>
|
||||
Delegates to ThreadLocal<T>, but wraps Value property access in try/catch to swallow ObjectDisposedExceptions.
|
||||
@@ -170,6 +178,16 @@
|
||||
</summary>
|
||||
<typeparam name="T"></typeparam>
|
||||
</member>
|
||||
<member name="F:NSubstitute.Core.SubstituteConfig.OverrideAllCalls">
|
||||
<summary>
|
||||
Standard substitute behaviour; replace all calls with substituted behaviour.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:NSubstitute.Core.SubstituteConfig.CallBaseByDefault">
|
||||
<summary>
|
||||
Partial substitute; use base behaviour unless explicitly overriden.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Experimental.Received.InOrder(System.Action)">
|
||||
<summary>
|
||||
*EXPERIMENTAL* Asserts the calls to the substitutes contained in the given Action were
|
||||
@@ -178,14 +196,14 @@
|
||||
</summary>
|
||||
<param name="calls">Action containing calls to substitutes in the expected order</param>
|
||||
</member>
|
||||
<member name="T:NSubstitute.IArgumentMatcher`1">
|
||||
<member name="T:NSubstitute.Core.Arguments.IArgumentMatcher`1">
|
||||
<summary>
|
||||
Provides a specification for arguments for use with <see ctype="Arg.Matches < T >(IArgumentMatcher)" />.
|
||||
Can additionally implement <see ctype="IDescribeNonMatches" /> to give descriptions when arguments do not match.
|
||||
</summary>
|
||||
<typeparam name="T">Matches arguments of type <typeparamref name="T"/> or compatible type.</typeparam>
|
||||
</member>
|
||||
<member name="M:NSubstitute.IArgumentMatcher`1.IsSatisfiedBy(`0)">
|
||||
<member name="M:NSubstitute.Core.Arguments.IArgumentMatcher`1.IsSatisfiedBy(`0)">
|
||||
<summary>
|
||||
Checks whether the <paramref name="argument"/> satisfies the condition of the matcher.
|
||||
If this throws an exception the argument will be treated as non-matching.
|
||||
@@ -193,6 +211,14 @@
|
||||
<param name="argument"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Received.InOrder(System.Action)">
|
||||
<summary>
|
||||
Asserts the calls to the substitutes contained in the given Action were
|
||||
received by these substitutes in the same order. Calls to property getters are not included
|
||||
in the assertion.
|
||||
</summary>
|
||||
<param name="calls">Action containing calls to substitutes in the expected order</param>
|
||||
</member>
|
||||
<member name="T:NSubstitute.Routing.Handlers.ClearLastCallRouterHandler">
|
||||
<summary>
|
||||
Clears last call router on SubstitutionContext for routes that do not require it.
|
||||
@@ -201,6 +227,33 @@
|
||||
This is to help prevent static state bleeding over into future calls.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Core.CallInfo.Args">
|
||||
<summary>
|
||||
Get the arguments passed to this call.
|
||||
</summary>
|
||||
<returns>Array of all arguments passed to this call</returns>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Core.CallInfo.ArgTypes">
|
||||
<summary>
|
||||
Gets the types of all the arguments passed to this call.
|
||||
</summary>
|
||||
<returns>Array of types of all arguments passed to this call</returns>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Core.CallInfo.Arg``1">
|
||||
<summary>
|
||||
Gets the argument of type `T` passed to this call. This will throw if there are no arguments
|
||||
of this type, or if there is more than one matching argument.
|
||||
</summary>
|
||||
<typeparam name="T">The type of the argument to retrieve</typeparam>
|
||||
<returns>The argument passed to the call, or throws if there is not exactly one argument of this type</returns>
|
||||
</member>
|
||||
<member name="P:NSubstitute.Core.CallInfo.Item(System.Int32)">
|
||||
<summary>
|
||||
Gets the nth argument to this call.
|
||||
</summary>
|
||||
<param name="index">Index of argument</param>
|
||||
<returns>The value of the argument at the given index</returns>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Raise.EventWith``1(System.Object,``0)">
|
||||
<summary>
|
||||
Raise an event for an <c>EventHandler<TEventArgs></c> event with the provided <paramref name="sender"/> and <paramref name="eventArgs"/>.
|
||||
@@ -258,7 +311,7 @@
|
||||
<member name="M:NSubstitute.Substitute.For``3(System.Object[])">
|
||||
<summary>
|
||||
<para>Substitute for multiple interfaces or a class that implements multiple interfaces. At most one class can be specified.</para>
|
||||
If additional interfaces are required use the <see cref="M:For(System.Type[], System.Object[])" /> overload.
|
||||
If additional interfaces are required use the <see cref="M:NSubstitute.Substitute.For(System.Type[],System.Object[])"/> overload.
|
||||
<para>Be careful when specifying a class, as all non-virtual members will actually be executed. Only virtual members
|
||||
can be recorded or have return values specified.</para>
|
||||
</summary>
|
||||
@@ -278,6 +331,18 @@
|
||||
<param name="constructorArguments">Arguments required to construct a class being substituted. Not required for interfaces or classes with default constructors.</param>
|
||||
<returns>A substitute implementing the specified types.</returns>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Substitute.ForPartsOf``1(System.Object[])">
|
||||
<summary>
|
||||
Create a substitute for a class that behaves just like a real instance of the class, but also
|
||||
records calls made to its virtual members and allows for specific members to be substituted
|
||||
by using <see cref="M:NSubstitute.Core.WhenCalled`1.DoNotCallBase">When(() => call).DoNotCallBase()</see> or by
|
||||
<see cref="M:NSubstitute.SubstituteExtensions.Returns``1(``0,``0,``0[])">setting a value to return value</see> for that member.
|
||||
</summary>
|
||||
<typeparam name="T">The type to substitute for parts of. Must be a class; not a delegate or interface.</typeparam>
|
||||
<param name="constructorArguments"></param>
|
||||
<returns>An instance of the class that will execute real methods when called, but allows parts to be selectively
|
||||
overridden via `Returns` and `When..DoNotCallBase`.</returns>
|
||||
</member>
|
||||
<member name="M:NSubstitute.SubstituteExtensions.Returns``1(``0,``0,``0[])">
|
||||
<summary>
|
||||
Set a return value for this call.
|
||||
@@ -406,11 +471,34 @@
|
||||
<param name="substitute"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Core.SubstituteFactory.Create(System.Type[],System.Object[])">
|
||||
<summary>
|
||||
Create a substitute for the given types.
|
||||
</summary>
|
||||
<param name="typesToProxy"></param>
|
||||
<param name="constructorArguments"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Core.SubstituteFactory.CreatePartial(System.Type[],System.Object[])">
|
||||
<summary>
|
||||
Create an instance of the given types, with calls configured to call the base implementation
|
||||
where possible. Parts of the instance can be substituted using
|
||||
<see cref="M:NSubstitute.SubstituteExtensions.Returns``1(``0,``0,``0[])">Returns()</see>.
|
||||
</summary>
|
||||
<param name="typesToProxy"></param>
|
||||
<param name="constructorArguments"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Core.WhenCalled`1.Do(System.Action{NSubstitute.Core.CallInfo})">
|
||||
<summary>
|
||||
Perform this action when called.
|
||||
</summary>
|
||||
<param name="callbackWithArguments"></param>
|
||||
</member>
|
||||
<member name="M:NSubstitute.Core.WhenCalled`1.DoNotCallBase">
|
||||
<summary>
|
||||
Do not call the base implementation on future calls. For us with partial substitutes.
|
||||
</summary>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
BIN
packages/NSubstitute.1.7.1.0/lib/NET40/NSubstitute.dll
vendored
Normal file
BIN
packages/NSubstitute.1.7.1.0/lib/NET40/NSubstitute.dll
vendored
Normal file
Binary file not shown.
BIN
packages/SimpleJson.0.28.0/SimpleJson.0.28.0.nupkg
vendored
BIN
packages/SimpleJson.0.28.0/SimpleJson.0.28.0.nupkg
vendored
Binary file not shown.
BIN
packages/SimpleJson.0.30.0/SimpleJson.0.30.0.nupkg
vendored
Normal file
BIN
packages/SimpleJson.0.30.0/SimpleJson.0.30.0.nupkg
vendored
Normal file
Binary file not shown.
@@ -2,7 +2,7 @@
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>SimpleJson</id>
|
||||
<version>0.28.0</version>
|
||||
<version>0.30.0</version>
|
||||
<authors>Jim Zimmerman, Nathan Totten, Prabir Shrestha</authors>
|
||||
<owners>Jim Zimmerman, Nathan Totten, Prabir Shrestha</owners>
|
||||
<licenseUrl>https://raw.github.com/facebook-csharp-sdk/simple-json/master/LICENSE.txt</licenseUrl>
|
||||
@@ -1,6 +1,6 @@
|
||||
# SimpleJson https://github.com/facebook-csharp-sdk/simple-json
|
||||
# License: MIT License
|
||||
# Version: 0.28.0
|
||||
# Version: 0.30.0
|
||||
|
||||
function ConvertFrom-Json
|
||||
{
|
||||
@@ -87,7 +87,7 @@ $source = @"
|
||||
// <website>https://github.com/facebook-csharp-sdk/simple-json</website>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
// VERSION: 0.28.0
|
||||
// VERSION: 0.30.0
|
||||
|
||||
// NOTE: uncomment the following line to make SimpleJson class internal.
|
||||
//#define SIMPLE_JSON_INTERNAL
|
||||
@@ -1378,6 +1378,14 @@ namespace SimpleJson
|
||||
return DateTimeOffset.ParseExact(str, Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal);
|
||||
if (type == typeof(Guid) || (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(Guid)))
|
||||
return new Guid(str);
|
||||
if (type == typeof(Uri))
|
||||
{
|
||||
bool isValid = Uri.IsWellFormedUriString(str, UriKind.RelativeOrAbsolute);
|
||||
|
||||
Uri result;
|
||||
if (isValid && Uri.TryCreate(str, UriKind.RelativeOrAbsolute, out result))
|
||||
return result;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
else
|
||||
@@ -17,7 +17,7 @@
|
||||
// <website>https://github.com/facebook-csharp-sdk/simple-json</website>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
// VERSION: 0.28.0
|
||||
// VERSION: 0.30.0
|
||||
|
||||
// NOTE: uncomment the following line to make SimpleJson class internal.
|
||||
//#define SIMPLE_JSON_INTERNAL
|
||||
@@ -1308,6 +1308,14 @@ namespace $rootnamespace$
|
||||
return DateTimeOffset.ParseExact(str, Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal);
|
||||
if (type == typeof(Guid) || (ReflectionUtils.IsNullableType(type) && Nullable.GetUnderlyingType(type) == typeof(Guid)))
|
||||
return new Guid(str);
|
||||
if (type == typeof(Uri))
|
||||
{
|
||||
bool isValid = Uri.IsWellFormedUriString(str, UriKind.RelativeOrAbsolute);
|
||||
|
||||
Uri result;
|
||||
if (isValid && Uri.TryCreate(str, UriKind.RelativeOrAbsolute, out result))
|
||||
return result;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
else
|
||||
Binary file not shown.
Reference in New Issue
Block a user