From f2a53c6a88e038a12686280115940c06b9ca4b79 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Mon, 27 Jan 2014 07:19:23 +1000 Subject: [PATCH 01/11] Stub out User Followers API --- Octokit/Clients/IUserFollowersClient.cs | 87 +++++++++++++++++++++++++ Octokit/Clients/IUsersClient.cs | 8 +++ Octokit/Clients/UsersClient.cs | 8 +++ Octokit/Octokit-Mono.csproj | 1 + Octokit/Octokit-MonoAndroid.csproj | 1 + Octokit/Octokit-Monotouch.csproj | 1 + Octokit/Octokit-netcore45.csproj | 1 + Octokit/Octokit.csproj | 1 + 8 files changed, 108 insertions(+) create mode 100644 Octokit/Clients/IUserFollowersClient.cs diff --git a/Octokit/Clients/IUserFollowersClient.cs b/Octokit/Clients/IUserFollowersClient.cs new file mode 100644 index 0000000000..3fb857873f --- /dev/null +++ b/Octokit/Clients/IUserFollowersClient.cs @@ -0,0 +1,87 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; + +namespace Octokit +{ + /// + /// A client for GitHub's User Followers API + /// + /// + /// See the Followers API documentation for more information. + /// + public interface IUserFollowersClient + { + /// + /// List the authenticated user’s followers + /// + /// + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + Task> GetAllForCurrent(); + + /// + /// List a user’s followers + /// + /// The login name for the user + /// + Task> GetAll(string login); + + /// + /// List who the authenticated user is following + /// + /// + Task> GetFollowingForCurrent(); + + /// + /// List who a user is following + /// + /// The login name of the user + /// + Task> GetFollowing(string login); + + /// + /// Check if the authenticated user follows another user + /// + /// The login name of the other user + /// + Task CheckFollowingForCurrent(string following); + + /// + /// Check if one user follows another user + /// + /// The login name of the user + /// The login name of the other user + /// + Task CheckFollowing(string login, string following); + + /// + /// Check if the authenticated user is followed by another user + /// + /// The login name of the other user + /// + Task CheckFollowerForCurrent(string following); + + /// + /// Check if a user is followed by another user + /// + /// The login name of the user + /// The login name of the other user + /// + Task CheckFollower(string login, string following); + + /// + /// Follow a user + /// + /// The login name of the user to follow + /// + Task Follow(string login); + + /// + /// Unfollow a user + /// + /// The login name of the user to unfollow + /// + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Unfollow")] + Task Unfollow(string login); + } +} diff --git a/Octokit/Clients/IUsersClient.cs b/Octokit/Clients/IUsersClient.cs index e5c91a88c7..119ca011e7 100644 --- a/Octokit/Clients/IUsersClient.cs +++ b/Octokit/Clients/IUsersClient.cs @@ -41,5 +41,13 @@ public interface IUsersClient /// [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] Task> GetEmails(); + + /// + /// A client for GitHub's User Followers API + /// + /// + /// See the Followers API documentation for more information. + /// + IUserFollowersClient Followers { get; } } } diff --git a/Octokit/Clients/UsersClient.cs b/Octokit/Clients/UsersClient.cs index 48ff6746fc..4eaaee1250 100644 --- a/Octokit/Clients/UsersClient.cs +++ b/Octokit/Clients/UsersClient.cs @@ -68,5 +68,13 @@ public Task> GetEmails() { return ApiConnection.GetAll(ApiUrls.Emails(), null); } + + /// + /// A client for GitHub's User Followers API + /// + /// + /// See the Followers API documentation for more information. + /// + public IUserFollowersClient Followers { get; private set; } } } diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index 9d18a928ab..70b26e4447 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -253,6 +253,7 @@ + \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index 67fed48458..2a88175bb1 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -263,6 +263,7 @@ + \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index f34fd75ebd..368492aabd 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -258,6 +258,7 @@ + \ No newline at end of file diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index b8c62ad0f6..fb7df2478c 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -89,6 +89,7 @@ + diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index a1e1e691c1..10944484ff 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -55,6 +55,7 @@ + From 9e892a2d06a70b395b8cd466997f2459a927024a Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Mon, 27 Jan 2014 08:10:06 +1000 Subject: [PATCH 02/11] Implement the User Followers API Update comments with links to API documentation Remove API methods that were invalid --- Octokit/Clients/IUserFollowersClient.cs | 40 +++--- Octokit/Clients/UserFollowersClient.cs | 168 ++++++++++++++++++++++++ Octokit/Clients/UsersClient.cs | 1 + Octokit/Octokit-Mono.csproj | 1 + Octokit/Octokit-MonoAndroid.csproj | 1 + Octokit/Octokit-Monotouch.csproj | 1 + Octokit/Octokit-netcore45.csproj | 1 + Octokit/Octokit.csproj | 1 + 8 files changed, 199 insertions(+), 15 deletions(-) create mode 100644 Octokit/Clients/UserFollowersClient.cs diff --git a/Octokit/Clients/IUserFollowersClient.cs b/Octokit/Clients/IUserFollowersClient.cs index 3fb857873f..f10361a75d 100644 --- a/Octokit/Clients/IUserFollowersClient.cs +++ b/Octokit/Clients/IUserFollowersClient.cs @@ -15,6 +15,9 @@ public interface IUserFollowersClient /// /// List the authenticated user’s followers /// + /// + /// See the API documentation for more information. + /// /// [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] Task> GetAllForCurrent(); @@ -23,19 +26,29 @@ public interface IUserFollowersClient /// List a user’s followers /// /// The login name for the user + /// + /// See the API documentation for more information. + /// /// Task> GetAll(string login); /// /// List who the authenticated user is following /// + /// + /// See the API documentation for more information. + /// /// + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] Task> GetFollowingForCurrent(); /// /// List who a user is following /// /// The login name of the user + /// + /// See the API documentation for more information. + /// /// Task> GetFollowing(string login); @@ -43,6 +56,9 @@ public interface IUserFollowersClient /// Check if the authenticated user follows another user /// /// The login name of the other user + /// + /// See the API documentation for more information. + /// /// Task CheckFollowingForCurrent(string following); @@ -51,28 +67,19 @@ public interface IUserFollowersClient /// /// The login name of the user /// The login name of the other user + /// + /// See the API documentation for more information. + /// /// Task CheckFollowing(string login, string following); - /// - /// Check if the authenticated user is followed by another user - /// - /// The login name of the other user - /// - Task CheckFollowerForCurrent(string following); - - /// - /// Check if a user is followed by another user - /// - /// The login name of the user - /// The login name of the other user - /// - Task CheckFollower(string login, string following); - /// /// Follow a user /// /// The login name of the user to follow + /// + /// See the API documentation for more information. + /// /// Task Follow(string login); @@ -80,6 +87,9 @@ public interface IUserFollowersClient /// Unfollow a user /// /// The login name of the user to unfollow + /// + /// See the API documentation for more information. + /// /// [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Unfollow")] Task Unfollow(string login); diff --git a/Octokit/Clients/UserFollowersClient.cs b/Octokit/Clients/UserFollowersClient.cs new file mode 100644 index 0000000000..d0f6279b78 --- /dev/null +++ b/Octokit/Clients/UserFollowersClient.cs @@ -0,0 +1,168 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace Octokit +{ + /// + /// A client for GitHub's User Followers API + /// + /// + /// See the Followers API documentation for more information. + /// + public class UserFollowersClient : ApiClient, IUserFollowersClient + { + /// + /// Initializes a new GitHub User Followers API client. + /// + /// An API connection + public UserFollowersClient(IApiConnection apiConnection) : base(apiConnection) + { + } + + /// + /// List the authenticated user’s followers + /// + /// + /// See the API documentation for more information. + /// + /// + public Task> GetAllForCurrent() + { + return ApiConnection.GetAll(new Uri("/user/followers")); + } + + /// + /// List a user’s followers + /// + /// The login name for the user + /// + /// See the API documentation for more information. + /// + /// + public Task> GetAll(string login) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + + return ApiConnection.GetAll(new Uri(String.Format("/users/{0}/followers", login))); + } + + /// + /// List who the authenticated user is following + /// + /// + /// See the API documentation for more information. + /// + /// + public Task> GetFollowingForCurrent() + { + return ApiConnection.GetAll(new Uri("/user/following")); + } + + /// + /// List who a user is following + /// + /// The login name of the user + /// + /// See the API documentation for more information. + /// + /// + public Task> GetFollowing(string login) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + + return ApiConnection.GetAll(new Uri(String.Format("/users/{0}/following", login))); + } + + /// + /// Check if the authenticated user follows another user + /// + /// The login name of the other user + /// + /// See the API documentation for more information. + /// + /// + public async Task CheckFollowingForCurrent(string following) + { + Ensure.ArgumentNotNullOrEmptyString(following, "following"); + + try + { + var response = await Connection.GetAsync(new Uri(String.Format("/user/following/{0}", 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; + } + } + + /// + /// Check if one user follows another user + /// + /// The login name of the user + /// The login name of the other user + /// + /// See the API documentation for more information. + /// + /// + public async Task CheckFollowing(string login, string following) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + Ensure.ArgumentNotNullOrEmptyString(following, "following"); + + try + { + var response = await Connection.GetAsync(new Uri(String.Format("/users/{0}/following/{1}", 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; + } + } + + /// + /// Follow a user + /// + /// The login name of the user to follow + /// + /// See the API documentation for more information. + /// + /// + public Task Follow(string login) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + + return ApiConnection.Put(new Uri(String.Format("/user/following/{0}", login))); + } + + /// + /// Unfollow a user + /// + /// The login name of the user to unfollow + /// + /// See the API documentation for more information. + /// + /// + public Task Unfollow(string login) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + + return ApiConnection.Delete(new Uri(String.Format("/user/following/{0}", login))); + } + } +} diff --git a/Octokit/Clients/UsersClient.cs b/Octokit/Clients/UsersClient.cs index 4eaaee1250..4baf52039b 100644 --- a/Octokit/Clients/UsersClient.cs +++ b/Octokit/Clients/UsersClient.cs @@ -23,6 +23,7 @@ public class UsersClient : ApiClient, IUsersClient /// An API connection public UsersClient(IApiConnection apiConnection) : base(apiConnection) { + Followers = new UserFollowersClient(apiConnection); } /// diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index 70b26e4447..1ed9a1e1c9 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -254,6 +254,7 @@ + \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index 2a88175bb1..9e04b8d567 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -264,6 +264,7 @@ + \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index 368492aabd..10972e28a1 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -259,6 +259,7 @@ + \ No newline at end of file diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index fb7df2478c..527d7489fd 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -105,6 +105,7 @@ + diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 10944484ff..3785beb5f9 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -59,6 +59,7 @@ + Code From 83b6331c9f3d9c44fd9366c6068d91332daf4278 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Mon, 27 Jan 2014 12:11:34 +1000 Subject: [PATCH 03/11] Refactor User Followers Client Create ApiUrls methods for base Uri's --- Octokit/Clients/IUserFollowersClient.cs | 6 ++-- Octokit/Clients/UserFollowersClient.cs | 38 ++++++++++++++++++------- Octokit/Helpers/ApiUrls.cs | 30 +++++++++++++++++++ 3 files changed, 60 insertions(+), 14 deletions(-) diff --git a/Octokit/Clients/IUserFollowersClient.cs b/Octokit/Clients/IUserFollowersClient.cs index f10361a75d..b5b7487a66 100644 --- a/Octokit/Clients/IUserFollowersClient.cs +++ b/Octokit/Clients/IUserFollowersClient.cs @@ -60,7 +60,7 @@ public interface IUserFollowersClient /// See the API documentation for more information. /// /// - Task CheckFollowingForCurrent(string following); + Task IsFollowingForCurrent(string following); /// /// Check if one user follows another user @@ -71,7 +71,7 @@ public interface IUserFollowersClient /// See the API documentation for more information. /// /// - Task CheckFollowing(string login, string following); + Task IsFollowing(string login, string following); /// /// Follow a user @@ -92,6 +92,6 @@ public interface IUserFollowersClient /// /// [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Unfollow")] - Task Unfollow(string login); + Task Unfollow(string login); } } diff --git a/Octokit/Clients/UserFollowersClient.cs b/Octokit/Clients/UserFollowersClient.cs index d0f6279b78..ebd3c9a364 100644 --- a/Octokit/Clients/UserFollowersClient.cs +++ b/Octokit/Clients/UserFollowersClient.cs @@ -32,7 +32,7 @@ public UserFollowersClient(IApiConnection apiConnection) : base(apiConnection) /// public Task> GetAllForCurrent() { - return ApiConnection.GetAll(new Uri("/user/followers")); + return ApiConnection.GetAll(ApiUrls.Followers()); } /// @@ -43,11 +43,12 @@ public Task> GetAllForCurrent() /// See the API documentation for more information. /// /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.String.Format(System.String,System.Object[])"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.String.Format(System.String,System.Object)")] public Task> GetAll(string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); - return ApiConnection.GetAll(new Uri(String.Format("/users/{0}/followers", login))); + return ApiConnection.GetAll(ApiUrls.Followers(login)); } /// @@ -59,7 +60,7 @@ public Task> GetAll(string login) /// public Task> GetFollowingForCurrent() { - return ApiConnection.GetAll(new Uri("/user/following")); + return ApiConnection.GetAll(ApiUrls.Following()); } /// @@ -70,11 +71,12 @@ public Task> GetFollowingForCurrent() /// See the API documentation for more information. /// /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.String.Format(System.String,System.Object[])"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.String.Format(System.String,System.Object)")] public Task> GetFollowing(string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); - return ApiConnection.GetAll(new Uri(String.Format("/users/{0}/following", login))); + return ApiConnection.GetAll(ApiUrls.Following(login)); } /// @@ -85,13 +87,13 @@ public Task> GetFollowing(string login) /// See the API documentation for more information. /// /// - public async Task CheckFollowingForCurrent(string following) + public async Task IsFollowingForCurrent(string following) { Ensure.ArgumentNotNullOrEmptyString(following, "following"); try { - var response = await Connection.GetAsync(new Uri(String.Format("/user/following/{0}", following)), null, null) + var response = await Connection.GetAsync(ApiUrls.IsFollowing(following), null, null) .ConfigureAwait(false); if(response.StatusCode != HttpStatusCode.NotFound && response.StatusCode != HttpStatusCode.NoContent) { @@ -114,14 +116,14 @@ public async Task CheckFollowingForCurrent(string following) /// See the API documentation for more information. /// /// - public async Task CheckFollowing(string login, string following) + public async Task IsFollowing(string login, string following) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); Ensure.ArgumentNotNullOrEmptyString(following, "following"); try { - var response = await Connection.GetAsync(new Uri(String.Format("/users/{0}/following/{1}", login, following)), null, null) + var response = await Connection.GetAsync(ApiUrls.IsFollowing(login, following), null, null) .ConfigureAwait(false); if (response.StatusCode != HttpStatusCode.NotFound && response.StatusCode != HttpStatusCode.NoContent) { @@ -143,11 +145,25 @@ public async Task CheckFollowing(string login, string following) /// See the API documentation for more information. /// /// - public Task Follow(string login) + public async Task Follow(string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); - return ApiConnection.Put(new Uri(String.Format("/user/following/{0}", login))); + try + { + var requestData = new { }; + var response = await Connection.PutAsync(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; + } } /// @@ -162,7 +178,7 @@ public Task Unfollow(string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); - return ApiConnection.Delete(new Uri(String.Format("/user/following/{0}", login))); + return ApiConnection.Delete(ApiUrls.IsFollowing(login)); } } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index acede7739c..de29e397b3 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -833,5 +833,35 @@ public static Uri SearchCode() { return "search/code".FormatUri(); } + + public static Uri Followers() + { + return "user/followers".FormatUri(); + } + + public static Uri Followers(string login) + { + return "users/{0}/followers".FormatUri(login); + } + + public static Uri Following() + { + return "user/following".FormatUri(); + } + + public static Uri Following(string login) + { + return "users/{0}/following".FormatUri(login); + } + + public static Uri IsFollowing(string following) + { + return "user/following/{0}".FormatUri(following); + } + + public static Uri IsFollowing(string login, string following) + { + return "users/{0}/following/{1}".FormatUri(login, following); + } } } From 46815784ce77123ff7fa2d9fe561e3beced41120 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Mon, 27 Jan 2014 12:11:50 +1000 Subject: [PATCH 04/11] Add unit tests --- .../Clients/UserFollowersClientTests.cs | 274 ++++++++++++++++++ Octokit.Tests/Octokit.Tests.csproj | 1 + 2 files changed, 275 insertions(+) create mode 100644 Octokit.Tests/Clients/UserFollowersClientTests.cs diff --git a/Octokit.Tests/Clients/UserFollowersClientTests.cs b/Octokit.Tests/Clients/UserFollowersClientTests.cs new file mode 100644 index 0000000000..d80083c6c8 --- /dev/null +++ b/Octokit.Tests/Clients/UserFollowersClientTests.cs @@ -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 +{ + /// + /// 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. + /// + public class UserFollowersClientTests + { + public class TheConstructor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new UserFollowersClient(null)); + } + } + + public class TheGetAllForCurrentMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var connection = Substitute.For(); + var client = new UserFollowersClient(connection); + + client.GetAllForCurrent(); + + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "user/followers")); + } + } + + public class TheGetAllMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var connection = Substitute.For(); + var client = new UserFollowersClient(connection); + + client.GetAll("alfhenrik"); + + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "users/alfhenrik/followers")); + } + + [Fact] + public void EnsureNonNullArguments() + { + var connection = Substitute.For(); + var client = new UserFollowersClient(connection); + + AssertEx.Throws(async () => await client.GetAll(null)); + AssertEx.Throws(async () => await client.GetAll("")); + } + } + + public class TheGetFollowingForCurrentMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var connection = Substitute.For(); + var client = new UserFollowersClient(connection); + + client.GetFollowingForCurrent(); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "user/following")); + } + } + + public class TheGetFollowingMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var connection = Substitute.For(); + var client = new UserFollowersClient(connection); + + client.GetFollowing("alfhenrik"); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/alfhenrik/following")); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new UserFollowersClient(connection); + + AssertEx.Throws(async () => await client.GetFollowing(null)); + AssertEx.Throws(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>(() => + new ApiResponse { StatusCode = status }); + var connection = Substitute.For(); + connection.GetAsync(Arg.Is(u => u.ToString() == "user/following/alfhenrik"), + null, null).Returns(response); + var apiConnection = Substitute.For(); + apiConnection.Connection.Returns(connection); + var client = new UserFollowersClient(apiConnection); + + var result = await client.IsFollowingForCurrent("alfhenrik"); + + Assert.Equal(expected, result); + } + + [Fact] + public async Task ThrowsExceptionForInvalidStatusCode() + { + var response = Task.Factory.StartNew>(() => + new ApiResponse { StatusCode = HttpStatusCode.Conflict }); + var connection = Substitute.For(); + connection.GetAsync(Arg.Is(u => u.ToString() == "user/following/alfhenrik"), + null, null).Returns(response); + var apiConnection = Substitute.For(); + apiConnection.Connection.Returns(connection); + var client = new UserFollowersClient(apiConnection); + + AssertEx.Throws(async () => await client.IsFollowingForCurrent("alfhenrik")); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new UserFollowersClient(connection); + + AssertEx.Throws(async () => await client.IsFollowingForCurrent(null)); + AssertEx.Throws(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>(() => + new ApiResponse { StatusCode = status }); + var connection = Substitute.For(); + connection.GetAsync(Arg.Is(u => u.ToString() == "users/alfhenrik/following/alfhenrik-test"), + null, null).Returns(response); + var apiConnection = Substitute.For(); + apiConnection.Connection.Returns(connection); + var client = new UserFollowersClient(apiConnection); + + var result = await client.IsFollowing("alfhenrik", "alfhenrik-test"); + + Assert.Equal(expected, result); + } + + [Fact] + public async Task ThrowsExceptionForInvalidStatusCode() + { + var response = Task.Factory.StartNew>(() => + new ApiResponse { StatusCode = HttpStatusCode.Conflict }); + var connection = Substitute.For(); + connection.GetAsync(Arg.Is(u => u.ToString() == "users/alfhenrik/following/alfhenrik-test"), + null, null).Returns(response); + var apiConnection = Substitute.For(); + apiConnection.Connection.Returns(connection); + var client = new UserFollowersClient(apiConnection); + + AssertEx.Throws(async () => await client.IsFollowing("alfhenrik", "alfhenrik-test")); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new UserFollowersClient(connection); + + AssertEx.Throws(async () => await client.IsFollowing(null, "alfhenrik-test")); + AssertEx.Throws(async () => await client.IsFollowing("alfhenrik", null)); + AssertEx.Throws(async () => await client.IsFollowing("", "alfhenrik-text")); + AssertEx.Throws(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>(() => + new ApiResponse { StatusCode = status }); + var connection = Substitute.For(); + connection.PutAsync(Arg.Is(u => u.ToString() == "user/following/alfhenrik"), + Args.Object).Returns(response); + var apiConnection = Substitute.For(); + apiConnection.Connection.Returns(connection); + var client = new UserFollowersClient(apiConnection); + + var result = await client.Follow("alfhenrik"); + + Assert.Equal(expected, result); + } + + [Fact] + public async Task ThrowsExceptionForInvalidStatusCode() + { + var response = Task.Factory.StartNew>(() => + new ApiResponse { StatusCode = HttpStatusCode.Conflict }); + var connection = Substitute.For(); + connection.PutAsync(Arg.Is(u => u.ToString() == "user/following/alfhenrik"), + new { }).Returns(response); + var apiConnection = Substitute.For(); + apiConnection.Connection.Returns(connection); + var client = new UserFollowersClient(apiConnection); + + AssertEx.Throws(async () => await client.Follow("alfhenrik")); + } + + [Fact] + public async Task EnsureNonNullArguments() + { + var connection = Substitute.For(); + var client = new UserFollowersClient(connection); + + await AssertEx.Throws(async () => await client.Follow(null)); + await AssertEx.Throws(async () => await client.Follow("")); + } + } + + public class TheUnfollowMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var connection = Substitute.For(); + var client = new UserFollowersClient(connection); + + client.Unfollow("alfhenrik"); + + connection.Received().Delete(Arg.Is(u => u.ToString() == "user/following/alfhenrik")); + } + + [Fact] + public async Task EnsureNonNullArguments() + { + var connection = Substitute.For(); + var client = new UserFollowersClient(connection); + + await AssertEx.Throws(async () => await client.Unfollow(null)); + await AssertEx.Throws(async () => await client.Unfollow("")); + } + } + } +} diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index e0e8b4730c..ad08472559 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -87,6 +87,7 @@ + From 1737834a591a4f5f43ce22950ad0dc73318decaf Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Mon, 27 Jan 2014 13:38:01 +1000 Subject: [PATCH 05/11] Stub out observable User Followers API --- .../Clients/IObservableUserFollowersClient.cs | 91 +++++++++++++++++++ Octokit.Reactive/Octokit.Reactive.csproj | 1 + 2 files changed, 92 insertions(+) create mode 100644 Octokit.Reactive/Clients/IObservableUserFollowersClient.cs diff --git a/Octokit.Reactive/Clients/IObservableUserFollowersClient.cs b/Octokit.Reactive/Clients/IObservableUserFollowersClient.cs new file mode 100644 index 0000000000..ad2bc4a4d6 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableUserFollowersClient.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reactive; +using System.Text; +using System.Threading.Tasks; + +namespace Octokit.Reactive.Clients +{ + public interface IObservableUserFollowersClient + { + /// + /// List the authenticated user’s followers + /// + /// + /// See the API documentation for more information. + /// + /// + IObservable GetAllForCurrent(); + + /// + /// List a user’s followers + /// + /// The login name for the user + /// + /// See the API documentation for more information. + /// + /// + IObservable GetAll(string login); + + /// + /// List who the authenticated user is following + /// + /// + /// See the API documentation for more information. + /// + /// + IObservable GetFollowingForCurrent(); + + /// + /// List who a user is following + /// + /// The login name of the user + /// + /// See the API documentation for more information. + /// + /// + IObservable GetFollowing(string login); + + /// + /// Check if the authenticated user follows another user + /// + /// The login name of the other user + /// + /// See the API documentation for more information. + /// + /// + IObservable IsFollowingForCurrent(string following); + + /// + /// Check if one user follows another user + /// + /// The login name of the user + /// The login name of the other user + /// + /// See the API documentation for more information. + /// + /// + IObservable IsFollowing(string login, string following); + + /// + /// Follow a user + /// + /// The login name of the user to follow + /// + /// See the API documentation for more information. + /// + /// + IObservable Follow(string login); + + /// + /// Unfollow a user + /// + /// The login name of the user to unfollow + /// + /// See the API documentation for more information. + /// + /// + IObservable Unfollow(string login); + } +} diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index 75e3a0ef7b..ec29762271 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -74,6 +74,7 @@ Properties\SolutionInfo.cs + From c40739c9585f047d01e9fe28c76d1094ce846788 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Mon, 27 Jan 2014 13:52:20 +1000 Subject: [PATCH 06/11] Implement Observable User Followers API Fix up Code Analysis errors --- .../Clients/IObservableUserFollowersClient.cs | 6 +- .../Clients/ObservableUserFollowersClient.cs | 141 ++++++++++++++++++ Octokit.Reactive/Octokit.Reactive.csproj | 1 + 3 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 Octokit.Reactive/Clients/ObservableUserFollowersClient.cs diff --git a/Octokit.Reactive/Clients/IObservableUserFollowersClient.cs b/Octokit.Reactive/Clients/IObservableUserFollowersClient.cs index ad2bc4a4d6..b6232c32b5 100644 --- a/Octokit.Reactive/Clients/IObservableUserFollowersClient.cs +++ b/Octokit.Reactive/Clients/IObservableUserFollowersClient.cs @@ -1,11 +1,12 @@ 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.Clients +namespace Octokit.Reactive { public interface IObservableUserFollowersClient { @@ -16,6 +17,7 @@ public interface IObservableUserFollowersClient /// See the API documentation for more information. /// /// + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] IObservable GetAllForCurrent(); /// @@ -35,6 +37,7 @@ public interface IObservableUserFollowersClient /// See the API documentation for more information. /// /// + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] IObservable GetFollowingForCurrent(); /// @@ -86,6 +89,7 @@ public interface IObservableUserFollowersClient /// See the API documentation for more information. /// /// + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Unfollow")] IObservable Unfollow(string login); } } diff --git a/Octokit.Reactive/Clients/ObservableUserFollowersClient.cs b/Octokit.Reactive/Clients/ObservableUserFollowersClient.cs new file mode 100644 index 0000000000..066a9474f7 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableUserFollowersClient.cs @@ -0,0 +1,141 @@ +using System; +using System.Reactive; +using System.Reactive.Threading.Tasks; +using Octokit.Reactive.Internal; + +namespace Octokit.Reactive +{ + public class ObservableUserFollowersClient : IObservableUserFollowersClient + { + readonly IUserFollowersClient _client; + readonly IConnection _connection; + + /// + /// Initializes a new User Followers API client. + /// + /// An used to make the requests + public ObservableUserFollowersClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, "client"); + + _client = client.User.Followers; + _connection = client.Connection; + } + + /// + /// List the authenticated user’s followers + /// + /// + /// See the API documentation for more information. + /// + /// + public IObservable GetAllForCurrent() + { + return _connection.GetAndFlattenAllPages(ApiUrls.Followers()); + } + + /// + /// List a user’s followers + /// + /// The login name for the user + /// + /// See the API documentation for more information. + /// + /// + public IObservable GetAll(string login) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + + return _connection.GetAndFlattenAllPages(ApiUrls.Followers(login)); + } + + /// + /// List who the authenticated user is following + /// + /// + /// See the API documentation for more information. + /// + /// + public IObservable GetFollowingForCurrent() + { + return _connection.GetAndFlattenAllPages(ApiUrls.Following()); + } + + /// + /// List who a user is following + /// + /// The login name of the user + /// + /// See the API documentation for more information. + /// + /// + public IObservable GetFollowing(string login) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + + return _connection.GetAndFlattenAllPages(ApiUrls.Following(login)); + } + + /// + /// Check if the authenticated user follows another user + /// + /// The login name of the other user + /// + /// See the API documentation for more information. + /// + /// + public IObservable IsFollowingForCurrent(string following) + { + Ensure.ArgumentNotNullOrEmptyString(following, "following"); + + return _client.IsFollowingForCurrent(following).ToObservable(); + } + + /// + /// Check if one user follows another user + /// + /// The login name of the user + /// The login name of the other user + /// + /// See the API documentation for more information. + /// + /// + public IObservable IsFollowing(string login, string following) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + Ensure.ArgumentNotNullOrEmptyString(following, "following"); + + return _client.IsFollowing(login, following).ToObservable(); + } + + /// + /// Follow a user + /// + /// The login name of the user to follow + /// + /// See the API documentation for more information. + /// + /// + public IObservable Follow(string login) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + + return _client.Follow(login).ToObservable(); + } + + /// + /// Unfollow a user + /// + /// The login name of the user to unfollow + /// + /// See the API documentation for more information. + /// + /// + public IObservable Unfollow(string login) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + + return _client.Unfollow(login).ToObservable(); + } + } +} diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index ec29762271..f14b813c27 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -121,6 +121,7 @@ + From 7b2043d151801d75537c51e00aeb9f4c995a318f Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Mon, 27 Jan 2014 14:47:47 +1000 Subject: [PATCH 07/11] Add unit tests for the observable client --- Octokit.Tests/Octokit.Tests.csproj | 1 + .../Reactive/ObservableUserFollowersTest.cs | 192 ++++++++++++++++++ 2 files changed, 193 insertions(+) create mode 100644 Octokit.Tests/Reactive/ObservableUserFollowersTest.cs diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index ad08472559..8681b07361 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -137,6 +137,7 @@ + diff --git a/Octokit.Tests/Reactive/ObservableUserFollowersTest.cs b/Octokit.Tests/Reactive/ObservableUserFollowersTest.cs new file mode 100644 index 0000000000..d751c22860 --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableUserFollowersTest.cs @@ -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 ObservableUserFollowersTest + { + public class TheGetAllForCurrentMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var githubClient = Substitute.For(); + var client = new ObservableUserFollowersClient(githubClient); + + client.GetAllForCurrent(); + + githubClient.Connection.GetAsync>( + new Uri("user/followers", UriKind.Relative), null, null); + } + } + + public class TheGetAllMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var githubClient = Substitute.For(); + var client = new ObservableUserFollowersClient(githubClient); + + client.GetAll("alfhenrik"); + + githubClient.Connection.GetAsync>( + new Uri("users/alfhenrik/followers", UriKind.Relative), null, null); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableUserFollowersClient(Substitute.For()); + + await AssertEx.Throws(async () => await client.GetAll(null)); + await AssertEx.Throws(async () => await client.GetAll("")); + } + } + + public class TheGetFollowingForCurrentMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var githubClient = Substitute.For(); + var client = new ObservableUserFollowersClient(githubClient); + + client.GetFollowingForCurrent(); + + githubClient.Connection.GetAsync>( + new Uri("user/following", UriKind.Relative), null, null); + } + } + + public class TheGetFollowingMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var githubClient = Substitute.For(); + var client = new ObservableUserFollowersClient(githubClient); + + client.GetFollowing("alfhenrik"); + + githubClient.Connection.GetAsync>( + new Uri("users/alfhenrik/following", UriKind.Relative), null, null); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableUserFollowersClient(Substitute.For()); + + await AssertEx.Throws(async () => await client.GetFollowing(null)); + await AssertEx.Throws(async () => await client.GetFollowing("")); + } + } + + public class TheIsFollowingForCurrentMethod + { + [Fact] + public void IsFollowingForCurrentFromClientUserFollowers() + { + var githubClient = Substitute.For(); + var client = new ObservableUserFollowersClient(githubClient); + + client.IsFollowingForCurrent("alfhenrik"); + + githubClient.User.Followers.Received() + .IsFollowingForCurrent("alfhenrik"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableUserFollowersClient(Substitute.For()); + + await AssertEx.Throws(async () => await client.IsFollowingForCurrent(null)); + await AssertEx.Throws(async () => await client.IsFollowingForCurrent("")); + } + } + + public class TheIsFollowingMethod + { + [Fact] + public void IsFollowingFromClientUserFollowers() + { + var githubClient = Substitute.For(); + var client = new ObservableUserFollowersClient(githubClient); + + client.IsFollowing("alfhenrik", "alfhenrik-test"); + + githubClient.User.Followers.Received() + .IsFollowing("alfhenrik", "alfhenrik-test"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableUserFollowersClient(Substitute.For()); + + await AssertEx.Throws(async () => await client.IsFollowing(null, "alfhenrik-test")); + await AssertEx.Throws(async () => await client.IsFollowing("", "alfhenrik-test")); + await AssertEx.Throws(async () => await client.IsFollowing("alfhenrik", null)); + await AssertEx.Throws(async () => await client.IsFollowing("alfhenrik", "")); + } + } + + public class TheFollowMethod + { + [Fact] + public void FollowFromClientUserFollowers() + { + var githubClient = Substitute.For(); + var client = new ObservableUserFollowersClient(githubClient); + + client.Follow("alfhenrik"); + + githubClient.User.Followers.Received() + .Follow("alfhenrik"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableUserFollowersClient(Substitute.For()); + + await AssertEx.Throws(async () => await client.Follow(null)); + await AssertEx.Throws(async () => await client.Follow("")); + } + } + + public class TheUnfollowMethod + { + [Fact] + public void UnfollowFromClientUserFollowers() + { + var githubClient = Substitute.For(); + var client = new ObservableUserFollowersClient(githubClient); + + client.Unfollow("alfhenrik"); + + githubClient.User.Followers.Received() + .Unfollow("alfhenrik"); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableUserFollowersClient(Substitute.For()); + + await AssertEx.Throws(async () => await client.Unfollow(null)); + await AssertEx.Throws(async () => await client.Unfollow("")); + } + } + } +} From e05cd9df2c41b0b54a59253f759adc402b0d64fe Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Mon, 27 Jan 2014 16:47:28 +1000 Subject: [PATCH 08/11] Add integration tests --- .../Clients/UserFollowersClientTests.cs | 110 ++++++++++++++++++ .../Octokit.Tests.Integration.csproj | 1 + 2 files changed, 111 insertions(+) create mode 100644 Octokit.Tests.Integration/Clients/UserFollowersClientTests.cs diff --git a/Octokit.Tests.Integration/Clients/UserFollowersClientTests.cs b/Octokit.Tests.Integration/Clients/UserFollowersClientTests.cs new file mode 100644 index 0000000000..70341d1657 --- /dev/null +++ b/Octokit.Tests.Integration/Clients/UserFollowersClientTests.cs @@ -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 UserFollowersClientTests : IDisposable +{ + readonly GitHubClient _github; + readonly User _currentUser; + + public UserFollowersClientTests() + { + _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"); + } +} diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index cf1aa4aad6..d9f3b73193 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -69,6 +69,7 @@ + From f368645da522c08e21ad7c8f2ff2584f97125c2b Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Wed, 29 Jan 2014 21:51:49 +1000 Subject: [PATCH 09/11] Rename UserFollowersClient to FollowersClient --- ...lient.cs => IObservableFollowersClient.cs} | 2 +- ...Client.cs => ObservableFollowersClient.cs} | 6 +-- Octokit.Reactive/Octokit.Reactive-Mono.csproj | 2 + .../Octokit.Reactive-MonoAndroid.csproj | 2 + .../Octokit.Reactive-Monotouch.csproj | 2 + Octokit.Reactive/Octokit.Reactive.csproj | 4 +- ...ClientTests.cs => FollowersClientTests.cs} | 4 +- .../Octokit.Tests.Integration.csproj | 2 +- ...ClientTests.cs => FollowersClientTests.cs} | 38 +++++++++---------- Octokit.Tests/Octokit.Tests.csproj | 4 +- ...wersTest.cs => ObservableFollowersTest.cs} | 30 +++++++-------- ...rFollowersClient.cs => FollowersClient.cs} | 4 +- ...FollowersClient.cs => IFollowersClient.cs} | 2 +- Octokit/Clients/IUsersClient.cs | 2 +- Octokit/Clients/UsersClient.cs | 4 +- Octokit/Octokit-Mono.csproj | 2 + Octokit/Octokit-MonoAndroid.csproj | 2 + Octokit/Octokit-Monotouch.csproj | 2 + Octokit/Octokit-netcore45.csproj | 4 +- Octokit/Octokit.csproj | 4 +- 20 files changed, 67 insertions(+), 55 deletions(-) rename Octokit.Reactive/Clients/{IObservableUserFollowersClient.cs => IObservableFollowersClient.cs} (98%) rename Octokit.Reactive/Clients/{ObservableUserFollowersClient.cs => ObservableFollowersClient.cs} (96%) rename Octokit.Tests.Integration/Clients/{UserFollowersClientTests.cs => FollowersClientTests.cs} (97%) rename Octokit.Tests/Clients/{UserFollowersClientTests.cs => FollowersClientTests.cs} (88%) rename Octokit.Tests/Reactive/{ObservableUserFollowersTest.cs => ObservableFollowersTest.cs} (82%) rename Octokit/Clients/{UserFollowersClient.cs => FollowersClient.cs} (98%) rename Octokit/Clients/{IUserFollowersClient.cs => IFollowersClient.cs} (99%) diff --git a/Octokit.Reactive/Clients/IObservableUserFollowersClient.cs b/Octokit.Reactive/Clients/IObservableFollowersClient.cs similarity index 98% rename from Octokit.Reactive/Clients/IObservableUserFollowersClient.cs rename to Octokit.Reactive/Clients/IObservableFollowersClient.cs index b6232c32b5..295e03eaa1 100644 --- a/Octokit.Reactive/Clients/IObservableUserFollowersClient.cs +++ b/Octokit.Reactive/Clients/IObservableFollowersClient.cs @@ -8,7 +8,7 @@ namespace Octokit.Reactive { - public interface IObservableUserFollowersClient + public interface IObservableFollowersClient { /// /// List the authenticated user’s followers diff --git a/Octokit.Reactive/Clients/ObservableUserFollowersClient.cs b/Octokit.Reactive/Clients/ObservableFollowersClient.cs similarity index 96% rename from Octokit.Reactive/Clients/ObservableUserFollowersClient.cs rename to Octokit.Reactive/Clients/ObservableFollowersClient.cs index 066a9474f7..c5ee6a201d 100644 --- a/Octokit.Reactive/Clients/ObservableUserFollowersClient.cs +++ b/Octokit.Reactive/Clients/ObservableFollowersClient.cs @@ -5,16 +5,16 @@ namespace Octokit.Reactive { - public class ObservableUserFollowersClient : IObservableUserFollowersClient + public class ObservableFollowersClient : IObservableFollowersClient { - readonly IUserFollowersClient _client; + readonly IFollowersClient _client; readonly IConnection _connection; /// /// Initializes a new User Followers API client. /// /// An used to make the requests - public ObservableUserFollowersClient(IGitHubClient client) + public ObservableFollowersClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); diff --git a/Octokit.Reactive/Octokit.Reactive-Mono.csproj b/Octokit.Reactive/Octokit.Reactive-Mono.csproj index e2db17ad7f..2f21b5e66a 100644 --- a/Octokit.Reactive/Octokit.Reactive-Mono.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Mono.csproj @@ -120,6 +120,8 @@ + + diff --git a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj index d3ffec270d..cd6ab187ea 100644 --- a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj +++ b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj @@ -129,6 +129,8 @@ + + diff --git a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj index c593c7dd2c..0f441e351f 100644 --- a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj @@ -124,6 +124,8 @@ + + diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index f14b813c27..6c5c7e71fc 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -74,7 +74,7 @@ Properties\SolutionInfo.cs - + @@ -121,7 +121,7 @@ - + diff --git a/Octokit.Tests.Integration/Clients/UserFollowersClientTests.cs b/Octokit.Tests.Integration/Clients/FollowersClientTests.cs similarity index 97% rename from Octokit.Tests.Integration/Clients/UserFollowersClientTests.cs rename to Octokit.Tests.Integration/Clients/FollowersClientTests.cs index 70341d1657..4d7f1e0f5b 100644 --- a/Octokit.Tests.Integration/Clients/UserFollowersClientTests.cs +++ b/Octokit.Tests.Integration/Clients/FollowersClientTests.cs @@ -8,12 +8,12 @@ using Octokit.Tests.Integration; using Xunit; -public class UserFollowersClientTests : IDisposable +public class FollowersClientTests : IDisposable { readonly GitHubClient _github; readonly User _currentUser; - public UserFollowersClientTests() + public FollowersClientTests() { _github = new GitHubClient(new ProductHeaderValue("OctokitTests")) { diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index d9f3b73193..9587edf948 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -69,7 +69,7 @@ - + diff --git a/Octokit.Tests/Clients/UserFollowersClientTests.cs b/Octokit.Tests/Clients/FollowersClientTests.cs similarity index 88% rename from Octokit.Tests/Clients/UserFollowersClientTests.cs rename to Octokit.Tests/Clients/FollowersClientTests.cs index d80083c6c8..9c24b83951 100644 --- a/Octokit.Tests/Clients/UserFollowersClientTests.cs +++ b/Octokit.Tests/Clients/FollowersClientTests.cs @@ -15,14 +15,14 @@ namespace Octokit.Tests.Clients /// 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. /// - public class UserFollowersClientTests + public class FollowersClientTests { public class TheConstructor { [Fact] public void EnsuresNonNullArguments() { - Assert.Throws(() => new UserFollowersClient(null)); + Assert.Throws(() => new FollowersClient(null)); } } @@ -32,7 +32,7 @@ public class TheGetAllForCurrentMethod public void RequestsTheCorrectUrl() { var connection = Substitute.For(); - var client = new UserFollowersClient(connection); + var client = new FollowersClient(connection); client.GetAllForCurrent(); @@ -47,7 +47,7 @@ public class TheGetAllMethod public void RequestsTheCorrectUrl() { var connection = Substitute.For(); - var client = new UserFollowersClient(connection); + var client = new FollowersClient(connection); client.GetAll("alfhenrik"); @@ -59,7 +59,7 @@ public void RequestsTheCorrectUrl() public void EnsureNonNullArguments() { var connection = Substitute.For(); - var client = new UserFollowersClient(connection); + var client = new FollowersClient(connection); AssertEx.Throws(async () => await client.GetAll(null)); AssertEx.Throws(async () => await client.GetAll("")); @@ -72,7 +72,7 @@ public class TheGetFollowingForCurrentMethod public void RequestsTheCorrectUrl() { var connection = Substitute.For(); - var client = new UserFollowersClient(connection); + var client = new FollowersClient(connection); client.GetFollowingForCurrent(); @@ -86,7 +86,7 @@ public class TheGetFollowingMethod public void RequestsTheCorrectUrl() { var connection = Substitute.For(); - var client = new UserFollowersClient(connection); + var client = new FollowersClient(connection); client.GetFollowing("alfhenrik"); @@ -97,7 +97,7 @@ public void RequestsTheCorrectUrl() public void EnsuresNonNullArguments() { var connection = Substitute.For(); - var client = new UserFollowersClient(connection); + var client = new FollowersClient(connection); AssertEx.Throws(async () => await client.GetFollowing(null)); AssertEx.Throws(async () => await client.GetFollowing("")); @@ -118,7 +118,7 @@ public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool null, null).Returns(response); var apiConnection = Substitute.For(); apiConnection.Connection.Returns(connection); - var client = new UserFollowersClient(apiConnection); + var client = new FollowersClient(apiConnection); var result = await client.IsFollowingForCurrent("alfhenrik"); @@ -135,7 +135,7 @@ public async Task ThrowsExceptionForInvalidStatusCode() null, null).Returns(response); var apiConnection = Substitute.For(); apiConnection.Connection.Returns(connection); - var client = new UserFollowersClient(apiConnection); + var client = new FollowersClient(apiConnection); AssertEx.Throws(async () => await client.IsFollowingForCurrent("alfhenrik")); } @@ -144,7 +144,7 @@ public async Task ThrowsExceptionForInvalidStatusCode() public void EnsuresNonNullArguments() { var connection = Substitute.For(); - var client = new UserFollowersClient(connection); + var client = new FollowersClient(connection); AssertEx.Throws(async () => await client.IsFollowingForCurrent(null)); AssertEx.Throws(async () => await client.IsFollowingForCurrent("")); @@ -165,7 +165,7 @@ public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool null, null).Returns(response); var apiConnection = Substitute.For(); apiConnection.Connection.Returns(connection); - var client = new UserFollowersClient(apiConnection); + var client = new FollowersClient(apiConnection); var result = await client.IsFollowing("alfhenrik", "alfhenrik-test"); @@ -182,7 +182,7 @@ public async Task ThrowsExceptionForInvalidStatusCode() null, null).Returns(response); var apiConnection = Substitute.For(); apiConnection.Connection.Returns(connection); - var client = new UserFollowersClient(apiConnection); + var client = new FollowersClient(apiConnection); AssertEx.Throws(async () => await client.IsFollowing("alfhenrik", "alfhenrik-test")); } @@ -191,7 +191,7 @@ public async Task ThrowsExceptionForInvalidStatusCode() public void EnsuresNonNullArguments() { var connection = Substitute.For(); - var client = new UserFollowersClient(connection); + var client = new FollowersClient(connection); AssertEx.Throws(async () => await client.IsFollowing(null, "alfhenrik-test")); AssertEx.Throws(async () => await client.IsFollowing("alfhenrik", null)); @@ -214,7 +214,7 @@ public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool Args.Object).Returns(response); var apiConnection = Substitute.For(); apiConnection.Connection.Returns(connection); - var client = new UserFollowersClient(apiConnection); + var client = new FollowersClient(apiConnection); var result = await client.Follow("alfhenrik"); @@ -231,7 +231,7 @@ public async Task ThrowsExceptionForInvalidStatusCode() new { }).Returns(response); var apiConnection = Substitute.For(); apiConnection.Connection.Returns(connection); - var client = new UserFollowersClient(apiConnection); + var client = new FollowersClient(apiConnection); AssertEx.Throws(async () => await client.Follow("alfhenrik")); } @@ -240,7 +240,7 @@ public async Task ThrowsExceptionForInvalidStatusCode() public async Task EnsureNonNullArguments() { var connection = Substitute.For(); - var client = new UserFollowersClient(connection); + var client = new FollowersClient(connection); await AssertEx.Throws(async () => await client.Follow(null)); await AssertEx.Throws(async () => await client.Follow("")); @@ -253,7 +253,7 @@ public class TheUnfollowMethod public void RequestsTheCorrectUrl() { var connection = Substitute.For(); - var client = new UserFollowersClient(connection); + var client = new FollowersClient(connection); client.Unfollow("alfhenrik"); @@ -264,7 +264,7 @@ public void RequestsTheCorrectUrl() public async Task EnsureNonNullArguments() { var connection = Substitute.For(); - var client = new UserFollowersClient(connection); + var client = new FollowersClient(connection); await AssertEx.Throws(async () => await client.Unfollow(null)); await AssertEx.Throws(async () => await client.Unfollow("")); diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 8681b07361..9b4eda2c2a 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -87,7 +87,7 @@ - + @@ -137,7 +137,7 @@ - + diff --git a/Octokit.Tests/Reactive/ObservableUserFollowersTest.cs b/Octokit.Tests/Reactive/ObservableFollowersTest.cs similarity index 82% rename from Octokit.Tests/Reactive/ObservableUserFollowersTest.cs rename to Octokit.Tests/Reactive/ObservableFollowersTest.cs index d751c22860..145c4dbc05 100644 --- a/Octokit.Tests/Reactive/ObservableUserFollowersTest.cs +++ b/Octokit.Tests/Reactive/ObservableFollowersTest.cs @@ -11,7 +11,7 @@ namespace Octokit.Tests.Reactive { - public class ObservableUserFollowersTest + public class ObservableFollowersTest { public class TheGetAllForCurrentMethod { @@ -19,7 +19,7 @@ public class TheGetAllForCurrentMethod public void RequestsTheCorrectUrl() { var githubClient = Substitute.For(); - var client = new ObservableUserFollowersClient(githubClient); + var client = new ObservableFollowersClient(githubClient); client.GetAllForCurrent(); @@ -34,7 +34,7 @@ public class TheGetAllMethod public void RequestsTheCorrectUrl() { var githubClient = Substitute.For(); - var client = new ObservableUserFollowersClient(githubClient); + var client = new ObservableFollowersClient(githubClient); client.GetAll("alfhenrik"); @@ -45,7 +45,7 @@ public void RequestsTheCorrectUrl() [Fact] public async Task EnsuresNonNullArguments() { - var client = new ObservableUserFollowersClient(Substitute.For()); + var client = new ObservableFollowersClient(Substitute.For()); await AssertEx.Throws(async () => await client.GetAll(null)); await AssertEx.Throws(async () => await client.GetAll("")); @@ -58,7 +58,7 @@ public class TheGetFollowingForCurrentMethod public void RequestsTheCorrectUrl() { var githubClient = Substitute.For(); - var client = new ObservableUserFollowersClient(githubClient); + var client = new ObservableFollowersClient(githubClient); client.GetFollowingForCurrent(); @@ -73,7 +73,7 @@ public class TheGetFollowingMethod public void RequestsTheCorrectUrl() { var githubClient = Substitute.For(); - var client = new ObservableUserFollowersClient(githubClient); + var client = new ObservableFollowersClient(githubClient); client.GetFollowing("alfhenrik"); @@ -84,7 +84,7 @@ public void RequestsTheCorrectUrl() [Fact] public async Task EnsuresNonNullArguments() { - var client = new ObservableUserFollowersClient(Substitute.For()); + var client = new ObservableFollowersClient(Substitute.For()); await AssertEx.Throws(async () => await client.GetFollowing(null)); await AssertEx.Throws(async () => await client.GetFollowing("")); @@ -97,7 +97,7 @@ public class TheIsFollowingForCurrentMethod public void IsFollowingForCurrentFromClientUserFollowers() { var githubClient = Substitute.For(); - var client = new ObservableUserFollowersClient(githubClient); + var client = new ObservableFollowersClient(githubClient); client.IsFollowingForCurrent("alfhenrik"); @@ -108,7 +108,7 @@ public void IsFollowingForCurrentFromClientUserFollowers() [Fact] public async Task EnsuresNonNullArguments() { - var client = new ObservableUserFollowersClient(Substitute.For()); + var client = new ObservableFollowersClient(Substitute.For()); await AssertEx.Throws(async () => await client.IsFollowingForCurrent(null)); await AssertEx.Throws(async () => await client.IsFollowingForCurrent("")); @@ -121,7 +121,7 @@ public class TheIsFollowingMethod public void IsFollowingFromClientUserFollowers() { var githubClient = Substitute.For(); - var client = new ObservableUserFollowersClient(githubClient); + var client = new ObservableFollowersClient(githubClient); client.IsFollowing("alfhenrik", "alfhenrik-test"); @@ -132,7 +132,7 @@ public void IsFollowingFromClientUserFollowers() [Fact] public async Task EnsuresNonNullArguments() { - var client = new ObservableUserFollowersClient(Substitute.For()); + var client = new ObservableFollowersClient(Substitute.For()); await AssertEx.Throws(async () => await client.IsFollowing(null, "alfhenrik-test")); await AssertEx.Throws(async () => await client.IsFollowing("", "alfhenrik-test")); @@ -147,7 +147,7 @@ public class TheFollowMethod public void FollowFromClientUserFollowers() { var githubClient = Substitute.For(); - var client = new ObservableUserFollowersClient(githubClient); + var client = new ObservableFollowersClient(githubClient); client.Follow("alfhenrik"); @@ -158,7 +158,7 @@ public void FollowFromClientUserFollowers() [Fact] public async Task EnsuresNonNullArguments() { - var client = new ObservableUserFollowersClient(Substitute.For()); + var client = new ObservableFollowersClient(Substitute.For()); await AssertEx.Throws(async () => await client.Follow(null)); await AssertEx.Throws(async () => await client.Follow("")); @@ -171,7 +171,7 @@ public class TheUnfollowMethod public void UnfollowFromClientUserFollowers() { var githubClient = Substitute.For(); - var client = new ObservableUserFollowersClient(githubClient); + var client = new ObservableFollowersClient(githubClient); client.Unfollow("alfhenrik"); @@ -182,7 +182,7 @@ public void UnfollowFromClientUserFollowers() [Fact] public async Task EnsuresNonNullArguments() { - var client = new ObservableUserFollowersClient(Substitute.For()); + var client = new ObservableFollowersClient(Substitute.For()); await AssertEx.Throws(async () => await client.Unfollow(null)); await AssertEx.Throws(async () => await client.Unfollow("")); diff --git a/Octokit/Clients/UserFollowersClient.cs b/Octokit/Clients/FollowersClient.cs similarity index 98% rename from Octokit/Clients/UserFollowersClient.cs rename to Octokit/Clients/FollowersClient.cs index ebd3c9a364..c4ba64dc71 100644 --- a/Octokit/Clients/UserFollowersClient.cs +++ b/Octokit/Clients/FollowersClient.cs @@ -13,13 +13,13 @@ namespace Octokit /// /// See the Followers API documentation for more information. /// - public class UserFollowersClient : ApiClient, IUserFollowersClient + public class FollowersClient : ApiClient, IFollowersClient { /// /// Initializes a new GitHub User Followers API client. /// /// An API connection - public UserFollowersClient(IApiConnection apiConnection) : base(apiConnection) + public FollowersClient(IApiConnection apiConnection) : base(apiConnection) { } diff --git a/Octokit/Clients/IUserFollowersClient.cs b/Octokit/Clients/IFollowersClient.cs similarity index 99% rename from Octokit/Clients/IUserFollowersClient.cs rename to Octokit/Clients/IFollowersClient.cs index b5b7487a66..1813354ee2 100644 --- a/Octokit/Clients/IUserFollowersClient.cs +++ b/Octokit/Clients/IFollowersClient.cs @@ -10,7 +10,7 @@ namespace Octokit /// /// See the Followers API documentation for more information. /// - public interface IUserFollowersClient + public interface IFollowersClient { /// /// List the authenticated user’s followers diff --git a/Octokit/Clients/IUsersClient.cs b/Octokit/Clients/IUsersClient.cs index 119ca011e7..eddc0039ae 100644 --- a/Octokit/Clients/IUsersClient.cs +++ b/Octokit/Clients/IUsersClient.cs @@ -48,6 +48,6 @@ public interface IUsersClient /// /// See the Followers API documentation for more information. /// - IUserFollowersClient Followers { get; } + IFollowersClient Followers { get; } } } diff --git a/Octokit/Clients/UsersClient.cs b/Octokit/Clients/UsersClient.cs index 4baf52039b..c68ece71f5 100644 --- a/Octokit/Clients/UsersClient.cs +++ b/Octokit/Clients/UsersClient.cs @@ -23,7 +23,7 @@ public class UsersClient : ApiClient, IUsersClient /// An API connection public UsersClient(IApiConnection apiConnection) : base(apiConnection) { - Followers = new UserFollowersClient(apiConnection); + Followers = new FollowersClient(apiConnection); } /// @@ -76,6 +76,6 @@ public Task> GetEmails() /// /// See the Followers API documentation for more information. /// - public IUserFollowersClient Followers { get; private set; } + public IFollowersClient Followers { get; private set; } } } diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index 1ed9a1e1c9..e04ec6ec54 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -255,6 +255,8 @@ + + \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index 9e04b8d567..0f8c4cf63b 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -265,6 +265,8 @@ + + \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index 10972e28a1..40fb75ce36 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -260,6 +260,8 @@ + + \ No newline at end of file diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index 527d7489fd..c855b507ca 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -57,6 +57,7 @@ + @@ -66,6 +67,7 @@ + @@ -89,7 +91,6 @@ - @@ -105,7 +106,6 @@ - diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 3785beb5f9..6402442c89 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -55,11 +55,11 @@ - - + + Code From 2fe86c3c4e7caebf083cc975987c2cfd11c684c8 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Thu, 30 Jan 2014 19:36:27 +1000 Subject: [PATCH 10/11] Tidy up doc comments Remove unused CodeAnalysis Suppress messages --- .../Clients/IObservableFollowersClient.cs | 17 +++++++++-------- .../Clients/ObservableFollowersClient.cs | 14 +++++++------- Octokit/Clients/FollowersClient.cs | 16 +++++++--------- Octokit/Clients/IFollowersClient.cs | 17 +++++++++-------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableFollowersClient.cs b/Octokit.Reactive/Clients/IObservableFollowersClient.cs index 295e03eaa1..f959b833bd 100644 --- a/Octokit.Reactive/Clients/IObservableFollowersClient.cs +++ b/Octokit.Reactive/Clients/IObservableFollowersClient.cs @@ -16,7 +16,7 @@ public interface IObservableFollowersClient /// /// See the API documentation for more information. /// - /// + /// A of s that follow the authenticated user. [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] IObservable GetAllForCurrent(); @@ -27,7 +27,7 @@ public interface IObservableFollowersClient /// /// See the API documentation for more information. /// - /// + /// A of s that follow the passed user. IObservable GetAll(string login); /// @@ -36,7 +36,7 @@ public interface IObservableFollowersClient /// /// See the API documentation for more information. /// - /// + /// A of s that the authenticated user follows. [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] IObservable GetFollowingForCurrent(); @@ -47,7 +47,7 @@ public interface IObservableFollowersClient /// /// See the API documentation for more information. /// - /// + /// A of s that the passed user follows. IObservable GetFollowing(string login); /// @@ -57,7 +57,7 @@ public interface IObservableFollowersClient /// /// See the API documentation for more information. /// - /// + /// A bool representing the success of the operation. IObservable IsFollowingForCurrent(string following); /// @@ -68,7 +68,7 @@ public interface IObservableFollowersClient /// /// See the API documentation for more information. /// - /// + /// A bool representing the success of the operation. IObservable IsFollowing(string login, string following); /// @@ -78,7 +78,7 @@ public interface IObservableFollowersClient /// /// See the API documentation for more information. /// - /// + /// A bool representing the success of the operation. IObservable Follow(string login); /// @@ -89,7 +89,8 @@ public interface IObservableFollowersClient /// See the API documentation for more information. /// /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Unfollow")] + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Unfollow", + Justification = "Unfollow is consistent with the GitHub website")] IObservable Unfollow(string login); } } diff --git a/Octokit.Reactive/Clients/ObservableFollowersClient.cs b/Octokit.Reactive/Clients/ObservableFollowersClient.cs index c5ee6a201d..88e3159caf 100644 --- a/Octokit.Reactive/Clients/ObservableFollowersClient.cs +++ b/Octokit.Reactive/Clients/ObservableFollowersClient.cs @@ -28,7 +28,7 @@ public ObservableFollowersClient(IGitHubClient client) /// /// See the API documentation for more information. /// - /// + /// A of s that follow the authenticated user. public IObservable GetAllForCurrent() { return _connection.GetAndFlattenAllPages(ApiUrls.Followers()); @@ -41,7 +41,7 @@ public IObservable GetAllForCurrent() /// /// See the API documentation for more information. /// - /// + /// A of s that follow the passed user. public IObservable GetAll(string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); @@ -55,7 +55,7 @@ public IObservable GetAll(string login) /// /// See the API documentation for more information. /// - /// + /// A of s that the authenticated user follows. public IObservable GetFollowingForCurrent() { return _connection.GetAndFlattenAllPages(ApiUrls.Following()); @@ -68,7 +68,7 @@ public IObservable GetFollowingForCurrent() /// /// See the API documentation for more information. /// - /// + /// A of s that the passed user follows. public IObservable GetFollowing(string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); @@ -83,7 +83,7 @@ public IObservable GetFollowing(string login) /// /// See the API documentation for more information. /// - /// + /// A bool representing the success of the operation. public IObservable IsFollowingForCurrent(string following) { Ensure.ArgumentNotNullOrEmptyString(following, "following"); @@ -99,7 +99,7 @@ public IObservable IsFollowingForCurrent(string following) /// /// See the API documentation for more information. /// - /// + /// A bool representing the success of the operation. public IObservable IsFollowing(string login, string following) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); @@ -115,7 +115,7 @@ public IObservable IsFollowing(string login, string following) /// /// See the API documentation for more information. /// - /// + /// A bool representing the success of the operation. public IObservable Follow(string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); diff --git a/Octokit/Clients/FollowersClient.cs b/Octokit/Clients/FollowersClient.cs index c4ba64dc71..76f1851d56 100644 --- a/Octokit/Clients/FollowersClient.cs +++ b/Octokit/Clients/FollowersClient.cs @@ -29,7 +29,7 @@ public FollowersClient(IApiConnection apiConnection) : base(apiConnection) /// /// See the API documentation for more information. /// - /// + /// A of s that follow the authenticated user. public Task> GetAllForCurrent() { return ApiConnection.GetAll(ApiUrls.Followers()); @@ -42,8 +42,7 @@ public Task> GetAllForCurrent() /// /// See the API documentation for more information. /// - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.String.Format(System.String,System.Object[])"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.String.Format(System.String,System.Object)")] + /// A of s that follow the passed user. public Task> GetAll(string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); @@ -57,7 +56,7 @@ public Task> GetAll(string login) /// /// See the API documentation for more information. /// - /// + /// A of s that the authenticated user follows. public Task> GetFollowingForCurrent() { return ApiConnection.GetAll(ApiUrls.Following()); @@ -70,8 +69,7 @@ public Task> GetFollowingForCurrent() /// /// See the API documentation for more information. /// - /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.String.Format(System.String,System.Object[])"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.String.Format(System.String,System.Object)")] + /// A of s that the passed user follows. public Task> GetFollowing(string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); @@ -86,7 +84,7 @@ public Task> GetFollowing(string login) /// /// See the API documentation for more information. /// - /// + /// A bool representing the success of the operation. public async Task IsFollowingForCurrent(string following) { Ensure.ArgumentNotNullOrEmptyString(following, "following"); @@ -115,7 +113,7 @@ public async Task IsFollowingForCurrent(string following) /// /// See the API documentation for more information. /// - /// + /// A bool representing the success of the operation. public async Task IsFollowing(string login, string following) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); @@ -144,7 +142,7 @@ public async Task IsFollowing(string login, string following) /// /// See the API documentation for more information. /// - /// + /// A bool representing the success of the operation. public async Task Follow(string login) { Ensure.ArgumentNotNullOrEmptyString(login, "login"); diff --git a/Octokit/Clients/IFollowersClient.cs b/Octokit/Clients/IFollowersClient.cs index 1813354ee2..b73dc5833c 100644 --- a/Octokit/Clients/IFollowersClient.cs +++ b/Octokit/Clients/IFollowersClient.cs @@ -18,7 +18,7 @@ public interface IFollowersClient /// /// See the API documentation for more information. /// - /// + /// A of s that follow the authenticated user. [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] Task> GetAllForCurrent(); @@ -29,7 +29,7 @@ public interface IFollowersClient /// /// See the API documentation for more information. /// - /// + /// A of s that follow the passed user. Task> GetAll(string login); /// @@ -38,7 +38,7 @@ public interface IFollowersClient /// /// See the API documentation for more information. /// - /// + /// A of s that the authenticated user follows. [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] Task> GetFollowingForCurrent(); @@ -49,7 +49,7 @@ public interface IFollowersClient /// /// See the API documentation for more information. /// - /// + /// A of s that the passed user follows. Task> GetFollowing(string login); /// @@ -59,7 +59,7 @@ public interface IFollowersClient /// /// See the API documentation for more information. /// - /// + /// A bool representing the success of the operation. Task IsFollowingForCurrent(string following); /// @@ -70,7 +70,7 @@ public interface IFollowersClient /// /// See the API documentation for more information. /// - /// + /// A bool representing the success of the operation. Task IsFollowing(string login, string following); /// @@ -80,7 +80,7 @@ public interface IFollowersClient /// /// See the API documentation for more information. /// - /// + /// A bool representing the success of the operation. Task Follow(string login); /// @@ -91,7 +91,8 @@ public interface IFollowersClient /// See the API documentation for more information. /// /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Unfollow")] + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Unfollow", + Justification = "Unfollow is consistent with the GitHub website")] Task Unfollow(string login); } } From 0965696813c795a57bb7a144c408261af0eed666 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Sat, 1 Feb 2014 12:42:22 +1000 Subject: [PATCH 11/11] Fix up the mono projects --- Octokit/Octokit-Mono.csproj | 2 -- Octokit/Octokit-MonoAndroid.csproj | 2 -- Octokit/Octokit-Monotouch.csproj | 2 -- 3 files changed, 6 deletions(-) diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index e04ec6ec54..cc349c2569 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -253,8 +253,6 @@ - - diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index 0f8c4cf63b..f196e297bf 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -263,8 +263,6 @@ - - diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index 40fb75ce36..1908e4b1a4 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -258,8 +258,6 @@ - -