From 90b6bdba3a1bfe1f2aefa3ddc7ac539efaca9477 Mon Sep 17 00:00:00 2001 From: rms81 Date: Sun, 1 Feb 2015 17:47:00 +0000 Subject: [PATCH 1/6] Add unit test for GetAll --- Octokit.Tests/Clients/RepositoriesClientTests.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index b0ed782e..2185c0b7 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -260,6 +260,21 @@ namespace Octokit.Tests.Clients } } + public class TheGetAllPublicMethod + { + [Fact] + public void RequestsTheCorrectUrlAndReturnsRepositories() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + + client.GetAllPublic(); + + connection.Received() + .GetAll(Arg.Is(u => u.ToString() == "/repositories")); + } + } + public class TheGetAllForCurrentMethod { [Fact] From 3bc0848906152ef6133bc6d142de41b523774723 Mon Sep 17 00:00:00 2001 From: rms81 Date: Sun, 1 Feb 2015 18:03:39 +0000 Subject: [PATCH 2/6] Add AllPublicRepositories to ApiUrls Helper --- Octokit/Helpers/ApiUrls.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 51c56661..4da9cab8 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -20,6 +20,17 @@ namespace Octokit static readonly Uri _oauthAuthorize = new Uri("login/oauth/authorize", UriKind.Relative); static readonly Uri _oauthAccesToken = new Uri("login/oauth/access_token", UriKind.Relative); + + /// + /// Returns the that returns all public repositories in + /// response to a GET request. + /// + /// + public static Uri AllPublicRepositories() + { + return "/repositories".FormatUri(); + } + /// /// Returns the that returns all of the repositories for the currently logged in user in /// response to a GET request. A POST to this URL creates a new repository. From ee8ed34e9ef2fccb11c8c6338a0952ff3dd19b96 Mon Sep 17 00:00:00 2001 From: rms81 Date: Sun, 1 Feb 2015 19:05:54 +0000 Subject: [PATCH 3/6] Add Integration Test for GetAllPublic --- .../Clients/RepositoriesClientTests.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index deb3a225..c9fc684f 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -534,6 +534,19 @@ public class RepositoriesClientTests } } + public class TheGetAllPublicMethod + { + [IntegrationTest] + public async Task ReturnsAllPublicRepositories() + { + var github = Helper.GetAuthenticatedClient(); + + var repositories = await github.Repository.GetAllPublic(); + + Assert.True(repositories.Count > 80); + } + } + public class TheGetAllForOrgMethod { [IntegrationTest] From aa867d5e4f6f113dd93d97d61d8c865894f7e72a Mon Sep 17 00:00:00 2001 From: rms81 Date: Sun, 1 Feb 2015 19:06:41 +0000 Subject: [PATCH 4/6] Add GetAllPublic in RepositoriesClient --- Octokit/Clients/IRepositoriesClient.cs | 14 ++++++++++++++ Octokit/Clients/RepositoriesClient.cs | 15 +++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index 627b8cbb..2080e6a0 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -94,6 +94,20 @@ namespace Octokit /// A [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] Task Get(string owner, string name); + + /// + /// Gets all public repositories. + /// + /// + /// See the API documentation for more information. + /// The default page size on GitHub.com is 30. + /// + /// Thrown if the client is not authenticated. + /// Thrown when a general API error occurs. + /// A of . + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", + Justification = "Makes a network request")] + Task> GetAllPublic(); /// /// Gets all repositories owned by the current user. diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 5116c37b..cc118d48 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -174,6 +174,21 @@ namespace Octokit return ApiConnection.Get(endpoint); } + /// + /// Gets all public repositories. + /// + /// + /// See the API documentation for more information. + /// The default page size on GitHub.com is 30. + /// + /// Thrown if the client is not authenticated. + /// Thrown when a general API error occurs. + /// A of . + public Task> GetAllPublic() + { + return ApiConnection.GetAll(ApiUrls.AllPublicRepositories()); + } + /// /// Gets all repositories owned by the current user. /// From 20dae37e72a1eef6692e101caa926db947ece901 Mon Sep 17 00:00:00 2001 From: rms81 Date: Sun, 1 Feb 2015 20:37:16 +0000 Subject: [PATCH 5/6] Add GetAllPublic to Octokit.Reactive --- .../Clients/IObservableRepositoriesClient.cs | 11 +++++++++++ .../Clients/ObservableRepositoriesClient.cs | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs index 24369e90..238cea4a 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs @@ -38,6 +38,17 @@ namespace Octokit.Reactive /// A [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] IObservable Get(string owner, string name); + + /// + /// Retrieves every public . + /// + /// + /// The default page size on GitHub.com is 30. + /// + /// A of . + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", + Justification = "Makes a network request")] + IObservable GetAllPublic(); /// /// Retrieves every that belongs to the current user. diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs index 5fa2f7a5..b4a010e7 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs @@ -90,6 +90,18 @@ namespace Octokit.Reactive return _client.Get(owner, name).ToObservable(); } + /// + /// Retrieves every public . + /// + /// + /// The default page size on GitHub.com is 30. + /// + /// A of . + public IObservable GetAllPublic() + { + return _connection.GetAndFlattenAllPages(ApiUrls.AllPublicRepositories()); + } + /// /// Retrieves every that belongs to the current user. /// From 5d7fbe758953d9786bb534195e4e78f4c0f93868 Mon Sep 17 00:00:00 2001 From: rms81 Date: Wed, 25 Feb 2015 09:06:40 +0000 Subject: [PATCH 6/6] Skip Added --- Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index c9fc684f..79e52eab 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -534,9 +534,10 @@ public class RepositoriesClientTests } } + public class TheGetAllPublicMethod { - [IntegrationTest] + [IntegrationTest(Skip = "Takes too long to run.")] public async Task ReturnsAllPublicRepositories() { var github = Helper.GetAuthenticatedClient();