From 084c513e066c76a531002dd42dbd76ba19c0f8c1 Mon Sep 17 00:00:00 2001 From: Devesh Khandelwal Date: Wed, 23 Mar 2016 13:20:43 +0530 Subject: [PATCH 001/123] Add ApiOptions overloads to Teams client + tests. --- Octokit.Tests/Clients/TeamsClientTests.cs | 20 ++++--- Octokit/Clients/ITeamsClient.cs | 40 ++++++++++++++ Octokit/Clients/TeamsClient.cs | 67 +++++++++++++++++++++-- 3 files changed, 116 insertions(+), 11 deletions(-) diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs index dfa09458..6452c346 100644 --- a/Octokit.Tests/Clients/TeamsClientTests.cs +++ b/Octokit.Tests/Clients/TeamsClientTests.cs @@ -46,7 +46,9 @@ namespace Octokit.Tests.Clients client.GetAll("orgName"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/orgName/teams")); + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "orgs/orgName/teams"), + Args.ApiOptions); } [Fact] @@ -55,6 +57,7 @@ namespace Octokit.Tests.Clients var teams = new TeamsClient(Substitute.For()); await Assert.ThrowsAsync(() => teams.GetAll(null)); + await Assert.ThrowsAsync(() => teams.GetAll("orgName", null)); } } @@ -68,7 +71,9 @@ namespace Octokit.Tests.Clients client.GetAllMembers(1); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "teams/1/members")); + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "teams/1/members"), + Args.ApiOptions); } } @@ -189,7 +194,9 @@ namespace Octokit.Tests.Clients client.GetAllForCurrent(); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "user/teams")); + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "user/teams"), + Args.ApiOptions); } } @@ -244,13 +251,12 @@ namespace Octokit.Tests.Clients { var connection = Substitute.For(); var client = new TeamsClient(connection); - client.GetAllRepositories(1); - - connection.Received().GetAll(Arg.Is(u => u.ToString() == "teams/1/repos")); client.GetAllRepositories(1); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "teams/1/repos")); + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "teams/1/repos"), + Args.ApiOptions); } } diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs index 45342768..ec832db3 100644 --- a/Octokit/Clients/ITeamsClient.cs +++ b/Octokit/Clients/ITeamsClient.cs @@ -30,10 +30,20 @@ namespace Octokit /// /// Returns all s for the current org. /// + /// Organization for which to list all teams. /// Thrown when a general API error occurs. /// A list of the orgs's teams s. Task> GetAll(string org); + /// + /// Returns all s for the current org. + /// + /// Organization for which to list all teams. + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// A list of the orgs's teams s. + Task> GetAll(string org, ApiOptions options); + /// /// Returns all s for the current user. /// @@ -42,6 +52,15 @@ namespace Octokit [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] Task> GetAllForCurrent(); + /// + /// Returns all s for the current user. + /// + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// A list of the user's s. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + Task> GetAllForCurrent(ApiOptions options); + /// /// Returns all members of the given team. /// @@ -52,6 +71,17 @@ namespace Octokit /// A list of the team's member s. Task> GetAllMembers(int id); + /// + /// Returns all members of the given team. + /// + /// The team identifier + /// Options to change API behaviour. + /// + /// https://developer.github.com/v3/orgs/teams/#list-team-members + /// + /// A list of the team's member s. + Task> GetAllMembers(int id, ApiOptions options); + /// /// Returns newly created for the current org. /// @@ -118,10 +148,20 @@ namespace Octokit /// /// Returns all team's repositories. /// + /// Team Id to list repos. /// Thrown when a general API error occurs. /// The team's repositories Task> GetAllRepositories(int id); + /// + /// Returns all team's repositories. + /// + /// Team Id to list repos. + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// The team's repositories + Task> GetAllRepositories(int id, ApiOptions options); + /// /// Add a repository to the team /// diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index e001d4cc..0b12ab8e 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -42,14 +42,28 @@ namespace Octokit /// /// Returns all s for the current org. /// + /// Organization to list teams of. /// Thrown when a general API error occurs. /// A list of the orgs's teams s. public Task> GetAll(string org) + { + return GetAll(org, ApiOptions.None); + } + + /// + /// Returns all s for the current org. + /// + /// Organization to list teams of. + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// A list of the orgs's teams s. + public Task> GetAll(string org, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); + Ensure.ArgumentNotNull(options, "options"); var endpoint = ApiUrls.OrganizationTeams(org); - return ApiConnection.GetAll(endpoint); + return ApiConnection.GetAll(endpoint, options); } /// @@ -59,8 +73,22 @@ namespace Octokit /// A list of the user's s. public Task> GetAllForCurrent() { + return GetAllForCurrent(ApiOptions.None); + } + + /// + /// Returns all s for the current user. + /// + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// A list of the user's s. + public Task> GetAllForCurrent(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + var endpoint = ApiUrls.UserTeams(); - return ApiConnection.GetAll(endpoint); + + return ApiConnection.GetAll(endpoint, options); } /// @@ -73,9 +101,25 @@ namespace Octokit /// A list of the team's member s. public Task> GetAllMembers(int id) { + return GetAllMembers(id, ApiOptions.None); + } + + /// + /// Returns all members of the given team. + /// + /// + /// https://developer.github.com/v3/orgs/teams/#list-team-members + /// + /// The team identifier + /// Options to change API behaviour. + /// A list of the team's member s. + public Task> GetAllMembers(int id, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + var endpoint = ApiUrls.TeamMembers(id); - return ApiConnection.GetAll(endpoint); + return ApiConnection.GetAll(endpoint, options); } /// @@ -236,13 +280,28 @@ namespace Octokit /// /// Returns all team's repositories. /// + /// Team Id. /// Thrown when a general API error occurs. /// The team's repositories public Task> GetAllRepositories(int id) { + return GetAllRepositories(id, ApiOptions.None); + } + + /// + /// Returns all team's repositories. + /// + /// Team Id. + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// The team's repositories + public Task> GetAllRepositories(int id, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + var endpoint = ApiUrls.TeamRepositories(id); - return ApiConnection.GetAll(endpoint); + return ApiConnection.GetAll(endpoint, options); } /// From 486e315c02b52d9ab517a0dfcbb2b2ff690d3ca5 Mon Sep 17 00:00:00 2001 From: Devesh Khandelwal Date: Wed, 23 Mar 2016 14:57:50 +0530 Subject: [PATCH 002/123] Add ApiOptions overload to Reactive Teams client. --- .../Clients/IObservableTeamsClient.cs | 43 +++++++++++- .../Clients/ObservableTeamsClient.cs | 66 +++++++++++++++++-- .../Reactive/ObservableTeamsClientTests.cs | 2 +- 3 files changed, 105 insertions(+), 6 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableTeamsClient.cs b/Octokit.Reactive/Clients/IObservableTeamsClient.cs index e6671028..dc17b6f4 100644 --- a/Octokit.Reactive/Clients/IObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/IObservableTeamsClient.cs @@ -27,10 +27,20 @@ namespace Octokit.Reactive /// /// Returns all s for the current org. /// + /// Organization to list all teams of. /// Thrown when a general API error occurs. /// A list of the orgs's teams s. IObservable GetAll(string org); + /// + /// Returns all s for the current org. + /// + /// Organization to list all teams of. + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// A list of the orgs's teams s. + IObservable GetAll(string org, ApiOptions options); + /// /// Returns all s for the current user. /// @@ -39,17 +49,38 @@ namespace Octokit.Reactive [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] IObservable GetAllForCurrent(); + /// + /// Returns all s for the current user. + /// + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// A list of the user's s. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + IObservable GetAllForCurrent(ApiOptions options); + /// /// Returns all members of the given team. /// - /// The team identifier /// /// https://developer.github.com/v3/orgs/teams/#list-team-members /// + /// The team identifier /// Thrown when a general API error occurs. /// A list of the team's member s. IObservable GetAllMembers(int id); + /// + /// Returns all members of the given team. + /// + /// + /// https://developer.github.com/v3/orgs/teams/#list-team-members + /// + /// The team identifier + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// A list of the team's member s. + IObservable GetAllMembers(int id, ApiOptions options); + /// /// Returns newly created for the current org. /// @@ -116,10 +147,20 @@ namespace Octokit.Reactive /// /// Returns all team's repositories. /// + /// Team Id. /// Thrown when a general API error occurs. /// The team's repositories IObservable GetAllRepositories(int id); + /// + /// Returns all team's repositories. + /// + /// Team Id. + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// The team's repositories + IObservable GetAllRepositories(int id, ApiOptions options); + /// /// Remove a repository from the team /// diff --git a/Octokit.Reactive/Clients/ObservableTeamsClient.cs b/Octokit.Reactive/Clients/ObservableTeamsClient.cs index c4d44985..cf21e0c9 100644 --- a/Octokit.Reactive/Clients/ObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/ObservableTeamsClient.cs @@ -46,9 +46,23 @@ namespace Octokit.Reactive /// Thrown when a general API error occurs. /// A list of the orgs's teams s. public IObservable GetAll(string org) + { + return GetAll(org, ApiOptions.None); + } + + /// + /// Returns all s for the current org. + /// + /// Organization to list all teams of. + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// A list of the orgs's teams s. + public IObservable GetAll(string org, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(org, "org"); - return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationTeams(org)); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationTeams(org), options); } /// @@ -58,7 +72,20 @@ namespace Octokit.Reactive /// A list of the user's s. public IObservable GetAllForCurrent() { - return _connection.GetAndFlattenAllPages(ApiUrls.UserTeams()); + return GetAllForCurrent(ApiOptions.None); + } + + /// + /// Returns all s for the current user. + /// + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// A list of the user's s. + public IObservable GetAllForCurrent(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.UserTeams(), options); } /// @@ -72,7 +99,24 @@ namespace Octokit.Reactive /// A list of the team's member s. public IObservable GetAllMembers(int id) { - return _connection.GetAndFlattenAllPages(ApiUrls.TeamMembers(id)); + return GetAllMembers(id, ApiOptions.None); + } + + /// + /// Returns all members of the given team. + /// + /// + /// https://developer.github.com/v3/orgs/teams/#list-team-members + /// + /// The team identifier + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// A list of the team's member s. + public IObservable GetAllMembers(int id, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.TeamMembers(id), options); } /// @@ -166,7 +210,21 @@ namespace Octokit.Reactive /// The team's repositories public IObservable GetAllRepositories(int id) { - return _connection.GetAndFlattenAllPages(ApiUrls.TeamRepositories(id)); + return GetAllRepositories(id, ApiOptions.None); + } + + /// + /// Returns all team's repositories. + /// + /// Team Id. + /// Options to change API behaviour. + /// Thrown when a general API error occurs. + /// The team's repositories + public IObservable GetAllRepositories(int id, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.TeamRepositories(id), options); } /// diff --git a/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs index bf8dc203..68b7dc9d 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs @@ -26,7 +26,7 @@ public class ObservableTeamsClientTests var client = new ObservableTeamsClient(github); - var member = await client.GetAllMembers(team.Id); + var member = await client.GetAllMembers(team.Id, ApiOptions.None); Assert.Equal(Helper.UserName, member.Login); } From 452c9c4c293837b697e66ba17b062bb0411fad4d Mon Sep 17 00:00:00 2001 From: Abdelkhalek Oussama Elhamer Date: Wed, 23 Mar 2016 17:47:39 +0100 Subject: [PATCH 003/123] Add ApiOption overloads to methods on ICommitStatusClient --- .../Clients/CommitStatusClientTests.cs | 19 +++++++++++++++ Octokit/Clients/CommitStatusClient.cs | 24 ++++++++++++++++++- Octokit/Clients/ICommitStatusClient.cs | 14 +++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/Octokit.Tests/Clients/CommitStatusClientTests.cs b/Octokit.Tests/Clients/CommitStatusClientTests.cs index c7658c83..cafa6250 100644 --- a/Octokit.Tests/Clients/CommitStatusClientTests.cs +++ b/Octokit.Tests/Clients/CommitStatusClientTests.cs @@ -22,6 +22,25 @@ namespace Octokit.Tests.Clients connection.Received() .GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/commits/sha/statuses")); } + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new CommitStatusClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAll("fake", "repo",options, "sha"); + + connection.Received() + .GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/commits/sha/statuses")); + } + [Fact] public async Task EnsuresNonNullArguments() diff --git a/Octokit/Clients/CommitStatusClient.cs b/Octokit/Clients/CommitStatusClient.cs index 6a42091e..ab77f1f9 100644 --- a/Octokit/Clients/CommitStatusClient.cs +++ b/Octokit/Clients/CommitStatusClient.cs @@ -36,7 +36,29 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); - return ApiConnection.GetAll(ApiUrls.CommitStatuses(owner, name, reference)); + return GetAll(owner,name,ApiOptions.None,reference); + } + + /// + /// Retrieves commit statuses for the specified reference. A reference can be a commit SHA, a branch name, or + /// a tag name. + /// + /// + /// https://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// The reference (SHA, branch name, or tag name) to list commits for + /// + public Task> GetAll(string owner, string name, ApiOptions options, string reference) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); + + return ApiConnection.GetAll(ApiUrls.CommitStatuses(owner, name, reference),options); } /// diff --git a/Octokit/Clients/ICommitStatusClient.cs b/Octokit/Clients/ICommitStatusClient.cs index e9743ea7..990bb652 100644 --- a/Octokit/Clients/ICommitStatusClient.cs +++ b/Octokit/Clients/ICommitStatusClient.cs @@ -24,6 +24,20 @@ namespace Octokit /// Task> GetAll(string owner, string name, string reference); + /// + /// Retrieves commit statuses for the specified reference. A reference can be a commit SHA, a branch name, or + /// a tag name. + /// + /// + /// https://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// The reference (SHA, branch name, or tag name) to list commits for + /// + Task> GetAll(string owner, string name, ApiOptions options, string reference); + /// /// Retrieves a combined view of statuses for the specified reference. A reference can be a commit SHA, a branch name, or /// a tag name. From a988ad166a7684cfdb0d8426984a6f366ac3b19d Mon Sep 17 00:00:00 2001 From: Abdelkhalek Oussama Elhamer Date: Wed, 23 Mar 2016 18:59:18 +0100 Subject: [PATCH 004/123] Add GetAll with options overload to IObservableCommitStatusClient + Implementation --- .../Clients/IObservableCommitStatusClient.cs | 12 ++++++++++ .../Clients/ObservableCommitStatusClient.cs | 24 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/Octokit.Reactive/Clients/IObservableCommitStatusClient.cs b/Octokit.Reactive/Clients/IObservableCommitStatusClient.cs index d2168f80..b1a970fb 100644 --- a/Octokit.Reactive/Clients/IObservableCommitStatusClient.cs +++ b/Octokit.Reactive/Clients/IObservableCommitStatusClient.cs @@ -15,6 +15,18 @@ namespace Octokit.Reactive /// IObservable GetAll(string owner, string name, string reference); + /// + /// Retrieves commit statuses for the specified reference. A reference can be a commit SHA, a branch name, or + /// a tag name. + /// + /// Only users with pull access can see this. + /// The owner of the repository + /// The name of the repository + /// The reference (SHA, branch name, or tag name) to list commits for + /// Options for changing the API response + /// + IObservable GetAll(string owner, string name, string reference, ApiOptions options); + /// /// Retrieves a combined view of statuses for the specified reference. A reference can be a commit SHA, a branch name, or /// a tag name. diff --git a/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs b/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs index b6390bc1..bf4b092f 100644 --- a/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs +++ b/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs @@ -28,9 +28,33 @@ namespace Octokit.Reactive /// public IObservable GetAll(string owner, string name, string reference) { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); + return _connection.GetAndFlattenAllPages(ApiUrls.CommitStatuses(owner, name, reference)); } + /// + /// Retrieves commit statuses for the specified reference. A reference can be a commit SHA, a branch name, or + /// a tag name. + /// + /// Only users with pull access can see this. + /// The owner of the repository + /// The name of the repository + /// The reference (SHA, branch name, or tag name) to list commits for + /// Options for changing the API response + /// + public IObservable GetAll(string owner, string name, string reference, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.CommitStatuses(owner, name, reference),options); + } + /// /// Retrieves a combined view of statuses for the specified reference. A reference can be a commit SHA, a branch name, or /// a tag name. From 5f306cfdcc0cae3ee3c2a6e695899c3a287725a1 Mon Sep 17 00:00:00 2001 From: Abdelkhalek Oussama Elhamer Date: Wed, 23 Mar 2016 19:04:16 +0100 Subject: [PATCH 005/123] Change the GetAll methode signature in the ICommitStatusClient interface --- Octokit.Tests/Clients/CommitStatusClientTests.cs | 2 +- Octokit/Clients/CommitStatusClient.cs | 12 ++++++------ Octokit/Clients/ICommitStatusClient.cs | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Octokit.Tests/Clients/CommitStatusClientTests.cs b/Octokit.Tests/Clients/CommitStatusClientTests.cs index cafa6250..46a16e50 100644 --- a/Octokit.Tests/Clients/CommitStatusClientTests.cs +++ b/Octokit.Tests/Clients/CommitStatusClientTests.cs @@ -35,7 +35,7 @@ namespace Octokit.Tests.Clients StartPage = 1 }; - client.GetAll("fake", "repo",options, "sha"); + client.GetAll("fake", "repo", "sha", options); connection.Received() .GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/commits/sha/statuses")); diff --git a/Octokit/Clients/CommitStatusClient.cs b/Octokit/Clients/CommitStatusClient.cs index ab77f1f9..b890bdff 100644 --- a/Octokit/Clients/CommitStatusClient.cs +++ b/Octokit/Clients/CommitStatusClient.cs @@ -36,7 +36,7 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); - return GetAll(owner,name,ApiOptions.None,reference); + return GetAll(owner,name,reference,ApiOptions.None); } /// @@ -47,16 +47,16 @@ namespace Octokit /// https://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref /// /// The owner of the repository - /// The name of the repository - /// Options for changing the API response + /// The name of the repository /// The reference (SHA, branch name, or tag name) to list commits for + /// Options for changing the API response /// - public Task> GetAll(string owner, string name, ApiOptions options, string reference) + public Task> GetAll(string owner, string name, string reference, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - Ensure.ArgumentNotNull(options, "options"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); + Ensure.ArgumentNotNull(options, "options"); return ApiConnection.GetAll(ApiUrls.CommitStatuses(owner, name, reference),options); } diff --git a/Octokit/Clients/ICommitStatusClient.cs b/Octokit/Clients/ICommitStatusClient.cs index 990bb652..eb3c7209 100644 --- a/Octokit/Clients/ICommitStatusClient.cs +++ b/Octokit/Clients/ICommitStatusClient.cs @@ -32,11 +32,11 @@ namespace Octokit /// https://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref /// /// The owner of the repository - /// The name of the repository - /// Options for changing the API response + /// The name of the repository /// The reference (SHA, branch name, or tag name) to list commits for + /// Options for changing the API response /// - Task> GetAll(string owner, string name, ApiOptions options, string reference); + Task> GetAll(string owner, string name, string reference, ApiOptions options); /// /// Retrieves a combined view of statuses for the specified reference. A reference can be a commit SHA, a branch name, or From 3a550a91829953c55e0ffbc7ab79761d3ba0ef71 Mon Sep 17 00:00:00 2001 From: Abdelkhalek Oussama Elhamer Date: Wed, 23 Mar 2016 20:22:00 +0100 Subject: [PATCH 006/123] Fix RequestsCorrectUrlWithApiOptions failling test --- Octokit.Tests/Clients/CommitStatusClientTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.Tests/Clients/CommitStatusClientTests.cs b/Octokit.Tests/Clients/CommitStatusClientTests.cs index 46a16e50..145c96da 100644 --- a/Octokit.Tests/Clients/CommitStatusClientTests.cs +++ b/Octokit.Tests/Clients/CommitStatusClientTests.cs @@ -38,7 +38,7 @@ namespace Octokit.Tests.Clients client.GetAll("fake", "repo", "sha", options); connection.Received() - .GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/commits/sha/statuses")); + .GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/commits/sha/statuses"),options); } From b88223109b718a879767b599f965085c5e37a8b2 Mon Sep 17 00:00:00 2001 From: Abdelkhalek Oussama Elhamer Date: Thu, 24 Mar 2016 00:55:33 +0100 Subject: [PATCH 007/123] Fix the RequestsCorrectUrl unit test --- Octokit.Tests/Clients/CommitStatusClientTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.Tests/Clients/CommitStatusClientTests.cs b/Octokit.Tests/Clients/CommitStatusClientTests.cs index 145c96da..631eacc1 100644 --- a/Octokit.Tests/Clients/CommitStatusClientTests.cs +++ b/Octokit.Tests/Clients/CommitStatusClientTests.cs @@ -20,7 +20,7 @@ namespace Octokit.Tests.Clients client.GetAll("fake", "repo", "sha"); connection.Received() - .GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/commits/sha/statuses")); + .GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/commits/sha/statuses"), Arg.Any()); } [Fact] public void RequestsCorrectUrlWithApiOptions() From 171b3c520a35af7d3fd80c48718623dafb7c474c Mon Sep 17 00:00:00 2001 From: Prayank Mathur Date: Fri, 25 Mar 2016 11:26:37 +0530 Subject: [PATCH 008/123] Implement Lock/Unlock Issue --- .../Clients/IObservableIssuesClient.cs | 23 ++++++- .../Clients/ObservableIssuesClient.cs | 33 ++++++++++ .../Clients/IssuesClientTests.cs | 20 +++++++ .../Reactive/ObservableIssuesClientTests.cs | 17 ++++++ Octokit.Tests/Clients/IssuesClientTests.cs | 52 ++++++++++++++++ .../Reactive/ObservableIssuesClientTests.cs | 60 +++++++++++++++++-- Octokit/Clients/IIssuesClient.cs | 24 +++++++- Octokit/Clients/IssuesClient.cs | 32 ++++++++++ Octokit/Helpers/ApiUrls.cs | 12 ++++ 9 files changed, 265 insertions(+), 8 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableIssuesClient.cs b/Octokit.Reactive/Clients/IObservableIssuesClient.cs index 008d9955..cae13e02 100644 --- a/Octokit.Reactive/Clients/IObservableIssuesClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssuesClient.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics.CodeAnalysis; +using System.Reactive; namespace Octokit.Reactive { @@ -156,5 +157,25 @@ namespace Octokit.Reactive /// /// IObservable Update(string owner, string name, int number, IssueUpdate issueUpdate); + + /// + /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. + /// + /// https://developer.github.com/v3/issues/#lock-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// + IObservable LockIssue(string owner, string name, int number); + + /// + /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. + /// + /// https://developer.github.com/v3/issues/#unlock-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// + IObservable UnlockIssue(string owner, string name, int number); } -} +} \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservableIssuesClient.cs b/Octokit.Reactive/Clients/ObservableIssuesClient.cs index 45716963..47d2b9f0 100644 --- a/Octokit.Reactive/Clients/ObservableIssuesClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssuesClient.cs @@ -1,6 +1,7 @@ using System; using System.Reactive.Threading.Tasks; using Octokit.Reactive.Internal; +using System.Reactive; namespace Octokit.Reactive { @@ -222,5 +223,37 @@ namespace Octokit.Reactive return _client.Update(owner, name, number, issueUpdate).ToObservable(); } + + /// + /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. + /// + /// https://developer.github.com/v3/issues/#lock-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// + public IObservable LockIssue(string owner, string name, int number) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return _client.LockIssue(owner, name, number).ToObservable(); + } + + /// + /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. + /// + /// https://developer.github.com/v3/issues/#unlock-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// + public IObservable UnlockIssue(string owner, string name, int number) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return _client.UnlockIssue(owner, name, number).ToObservable(); + } } } diff --git a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs index 73284093..fec271d0 100644 --- a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs @@ -62,6 +62,26 @@ public class IssuesClientTests : IDisposable } [IntegrationTest] + public async Task CanLockAndUnlockIssue() + { + var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; + var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); + var retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + + Assert.Equal(false, issue.Locked); + + await _issuesClient.LockIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + Assert.NotNull(retrieved); + Assert.Equal(true, issue.Locked); + + await _issuesClient.UnlockIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + Assert.NotNull(retrieved); + Assert.Equal(false, issue.Locked); + } + + [IntegrationTest] public async Task CanListOpenIssuesWithDefaultSort() { var newIssue1 = new NewIssue("A test issue1") { Body = "A new unassigned issue" }; diff --git a/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs index 5eb94af7..1b40a7ac 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs @@ -72,6 +72,23 @@ public class ObservableIssuesClientTests : IDisposable Assert.Equal("Modified integration test issue", updateResult.Title); } + [IntegrationTest] + public async Task CanLockAndUnlockIssues() + { + var newIssue = new NewIssue("Integration Test Issue"); + + var createResult = await _client.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); + Assert.Equal(false, createResult.Locked); + + await _client.LockIssue(_context.RepositoryOwner, _context.RepositoryName, createResult.Number); + var lockResult = await _client.Get(_context.RepositoryOwner, _context.RepositoryName, createResult.Number); + Assert.Equal(true, lockResult.Locked); + + await _client.UnlockIssue(_context.RepositoryOwner, _context.RepositoryName, createResult.Number); + var unlockIssueResult = await _client.Get(_context.RepositoryOwner, _context.RepositoryName, createResult.Number); + Assert.Equal(false, unlockIssueResult.Locked); + } + public void Dispose() { _context.Dispose(); diff --git a/Octokit.Tests/Clients/IssuesClientTests.cs b/Octokit.Tests/Clients/IssuesClientTests.cs index 2f3b759b..f4086d68 100644 --- a/Octokit.Tests/Clients/IssuesClientTests.cs +++ b/Octokit.Tests/Clients/IssuesClientTests.cs @@ -185,6 +185,58 @@ namespace Octokit.Tests.Clients } } + public class TheLockIssueMethod + { + [Fact] + public void PostsToCorrectUrl() + { + var connection = Substitute.For(); + var client = new IssuesClient(connection); + + client.LockIssue("fake", "repo", 42); + + connection.Received().Put(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/lock")); + } + + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var connection = Substitute.For(); + var client = new IssuesClient(connection); + + await Assert.ThrowsAsync(() => client.LockIssue(null, "name", 1)); + await Assert.ThrowsAsync(() => client.LockIssue("", "name", 1)); + await Assert.ThrowsAsync(() => client.LockIssue("owner", null, 1)); + await Assert.ThrowsAsync(() => client.LockIssue("owner", "", 1)); + } + } + + public class TheUnlockIssueMethod + { + [Fact] + public void PostsToCorrectUrl() + { + var connection = Substitute.For(); + var client = new IssuesClient(connection); + + client.UnlockIssue("fake", "repo", 42); + + connection.Received().Delete(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/lock")); + } + + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var connection = Substitute.For(); + var client = new IssuesClient(connection); + + await Assert.ThrowsAsync(() => client.UnlockIssue(null, "name", 1)); + await Assert.ThrowsAsync(() => client.UnlockIssue("", "name", 1)); + await Assert.ThrowsAsync(() => client.UnlockIssue("owner", null, 1)); + await Assert.ThrowsAsync(() => client.UnlockIssue("owner", "", 1)); + } + } + public class TheCtor { [Fact] diff --git a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs index aa23f958..61afa771 100644 --- a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs @@ -329,11 +329,61 @@ public class ObservableIssuesClientTests var gitHubClient = Substitute.For(); var client = new ObservableIssuesClient(gitHubClient); - Assert.Throws(() => client.Create(null, "name", new NewIssue("title"))); - Assert.Throws(() => client.Create("", "name", new NewIssue("x"))); - Assert.Throws(() => client.Create("owner", null, new NewIssue("x"))); - Assert.Throws(() => client.Create("owner", "", new NewIssue("x"))); - Assert.Throws(() => client.Create("owner", "name", null)); + Assert.Throws(() => client.Update(null, "name", 42, new IssueUpdate())); + Assert.Throws(() => client.Update("", "name", 42, new IssueUpdate())); + Assert.Throws(() => client.Update("owner", null, 42, new IssueUpdate())); + Assert.Throws(() => client.Update("owner", "", 42, new IssueUpdate())); + Assert.Throws(() => client.Update("owner", "name", 42, null)); + } + } + + public class TheLockIssueMethod + { + [Fact] + public void LockIssue() + { + var gitHubClient = Substitute.For(); + var client = new ObservableIssuesClient(gitHubClient); + + client.LockIssue("fake", "repo", 42); + gitHubClient.Issue.Received().LockIssue("fake", "repo", 42); + } + + [Fact] + public void EnsuresArgumentsNotNull() + { + var gitHubClient = Substitute.For(); + var client = new ObservableIssuesClient(gitHubClient); + + Assert.Throws(() => client.LockIssue(null, "name", 42)); + Assert.Throws(() => client.LockIssue("", "name", 42)); + Assert.Throws(() => client.LockIssue("owner", null, 42)); + Assert.Throws(() => client.LockIssue("owner", "", 42)); + } + } + + public class TheUnlockIssueMethod + { + [Fact] + public void UnlockIssue() + { + var gitHubClient = Substitute.For(); + var client = new ObservableIssuesClient(gitHubClient); + + client.UnlockIssue("fake", "repo", 42); + gitHubClient.Issue.Received().UnlockIssue("fake", "repo", 42); + } + + [Fact] + public void EnsuresArgumentsNotNull() + { + var gitHubClient = Substitute.For(); + var client = new ObservableIssuesClient(gitHubClient); + + Assert.Throws(() => client.UnlockIssue(null, "name", 42)); + Assert.Throws(() => client.UnlockIssue("", "name", 42)); + Assert.Throws(() => client.UnlockIssue("owner", null, 42)); + Assert.Throws(() => client.UnlockIssue("owner", "", 42)); } } diff --git a/Octokit/Clients/IIssuesClient.cs b/Octokit/Clients/IIssuesClient.cs index bc0e362c..f6f61dea 100644 --- a/Octokit/Clients/IIssuesClient.cs +++ b/Octokit/Clients/IIssuesClient.cs @@ -152,10 +152,10 @@ namespace Octokit Task Create(string owner, string name, NewIssue newIssue); /// - /// Creates an issue for the specified repository. Any user with pull access to a repository can create an + /// Updates an issue for the specified repository. Any user with pull access to a repository can update an /// issue. /// - /// http://developer.github.com/v3/issues/#create-an-issue + /// http://developer.github.com/v3/issues/#edit-an-issue /// The owner of the repository /// The name of the repository /// The issue number @@ -163,5 +163,25 @@ namespace Octokit /// /// Task Update(string owner, string name, int number, IssueUpdate issueUpdate); + + /// + /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. + /// + /// https://developer.github.com/v3/issues/#lock-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// + Task LockIssue(string owner, string name, int number); + + /// + /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. + /// + /// https://developer.github.com/v3/issues/#unlock-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// + Task UnlockIssue(string owner, string name, int number); } } diff --git a/Octokit/Clients/IssuesClient.cs b/Octokit/Clients/IssuesClient.cs index 8b924245..be4a9641 100644 --- a/Octokit/Clients/IssuesClient.cs +++ b/Octokit/Clients/IssuesClient.cs @@ -225,5 +225,37 @@ namespace Octokit return ApiConnection.Patch(ApiUrls.Issue(owner, name, number), issueUpdate); } + + /// + /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. + /// + /// https://developer.github.com/v3/issues/#lock-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// + public Task LockIssue(string owner, string name, int number) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return ApiConnection.Put(ApiUrls.IssueLock(owner, name, number)); + } + + /// + /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. + /// + /// https://developer.github.com/v3/issues/#unlock-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// + public Task UnlockIssue(string owner, string name, int number) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return ApiConnection.Delete(ApiUrls.IssueLock(owner, name, number)); + } } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index bb34ce46..73e99aa3 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -294,6 +294,18 @@ namespace Octokit return "repos/{0}/{1}/issues/{2}".FormatUri(owner, name, number); } + /// + /// Returns the for the specified issue to be locked/unlocked. + /// + /// The owner of the repository + /// The name of the repository + /// The issue number + /// + public static Uri IssueLock(string owner, string name, int number) + { + return "repos/{0}/{1}/issues/{2}/lock".FormatUri(owner, name, number); + } + /// /// Returns the for the comments for all issues in a specific repo. /// From 2c167bfb706bfc93b771dc8be41ff7b43f683095 Mon Sep 17 00:00:00 2001 From: Prayank Mathur Date: Fri, 25 Mar 2016 12:01:18 +0530 Subject: [PATCH 009/123] Fixes --- Octokit.Tests/Reactive/ObservableIssuesClientTests.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs index 61afa771..c59bb2e9 100644 --- a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs @@ -329,11 +329,11 @@ public class ObservableIssuesClientTests var gitHubClient = Substitute.For(); var client = new ObservableIssuesClient(gitHubClient); - Assert.Throws(() => client.Update(null, "name", 42, new IssueUpdate())); - Assert.Throws(() => client.Update("", "name", 42, new IssueUpdate())); - Assert.Throws(() => client.Update("owner", null, 42, new IssueUpdate())); - Assert.Throws(() => client.Update("owner", "", 42, new IssueUpdate())); - Assert.Throws(() => client.Update("owner", "name", 42, null)); + Assert.Throws(() => client.Create(null, "name", new NewIssue("title"))); + Assert.Throws(() => client.Create("", "name", new NewIssue("x"))); + Assert.Throws(() => client.Create("owner", null, new NewIssue("x"))); + Assert.Throws(() => client.Create("owner", "", new NewIssue("x"))); + Assert.Throws(() => client.Create("owner", "name", null)); } } From e328911fc6cc85f2ba28eba33fe7502caa82f5fb Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Fri, 25 Mar 2016 15:24:07 +0700 Subject: [PATCH 010/123] Method GetAll(string owner, string name, ApiOptions options) was implemented. --- Octokit/Clients/DeploymentsClient.cs | 19 ++++++++++++++++++- Octokit/Clients/IDeploymentsClient.cs | 13 +++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Octokit/Clients/DeploymentsClient.cs b/Octokit/Clients/DeploymentsClient.cs index 4ccc2948..4f63e510 100644 --- a/Octokit/Clients/DeploymentsClient.cs +++ b/Octokit/Clients/DeploymentsClient.cs @@ -33,11 +33,28 @@ namespace Octokit /// The name of the repository /// All the s for the specified repository. public Task> GetAll(string owner, string name) + { + return GetAll(owner, name, ApiOptions.None); + } + + /// + /// Gets all the deployments for the specified repository. Any user with pull access + /// to a repository can view deployments. + /// + /// + /// http://developer.github.com/v3/repos/deployments/#list-deployments + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the specified repository. + public Task> GetAll(string owner, string name, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, "login"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); - return ApiConnection.GetAll(ApiUrls.Deployments(owner, name)); + return ApiConnection.GetAll(ApiUrls.Deployments(owner, name), options); } /// diff --git a/Octokit/Clients/IDeploymentsClient.cs b/Octokit/Clients/IDeploymentsClient.cs index 97a8b245..3cbcd80f 100644 --- a/Octokit/Clients/IDeploymentsClient.cs +++ b/Octokit/Clients/IDeploymentsClient.cs @@ -24,6 +24,19 @@ namespace Octokit /// All the s for the specified repository. Task> GetAll(string owner, string name); + /// + /// Gets all the deployments for the specified repository. Any user with pull access + /// to a repository can view deployments. + /// + /// + /// http://developer.github.com/v3/repos/deployments/#list-deployments + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the specified repository. + Task> GetAll(string owner, string name, ApiOptions options); + /// /// Creates a new deployment for the specified repository. /// Users with push access can create a deployment for a given ref. From ad15e05471ca144572e50685b34277d5ab3d40cc Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Fri, 25 Mar 2016 15:51:37 +0700 Subject: [PATCH 011/123] New GetAll overload added for ObservableDeploymentsClient --- .../Clients/IObservableDeploymentsClient.cs | 13 ++++++++++++ .../Clients/ObservableDeploymentsClient.cs | 21 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/Octokit.Reactive/Clients/IObservableDeploymentsClient.cs b/Octokit.Reactive/Clients/IObservableDeploymentsClient.cs index 3a77e846..23fbee4a 100644 --- a/Octokit.Reactive/Clients/IObservableDeploymentsClient.cs +++ b/Octokit.Reactive/Clients/IObservableDeploymentsClient.cs @@ -16,6 +16,19 @@ namespace Octokit.Reactive /// All the s for the specified repository. IObservable GetAll(string owner, string name); + /// + /// Gets all the deployments for the specified repository. Any user with pull access + /// to a repository can view deployments. + /// + /// + /// http://developer.github.com/v3/repos/deployments/#list-deployments + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the specified repository. + IObservable GetAll(string owner, string name, ApiOptions options); + /// /// Creates a new deployment for the specified repository. /// Users with push access can create a deployment for a given ref. diff --git a/Octokit.Reactive/Clients/ObservableDeploymentsClient.cs b/Octokit.Reactive/Clients/ObservableDeploymentsClient.cs index 3d2ab9f1..1851b719 100644 --- a/Octokit.Reactive/Clients/ObservableDeploymentsClient.cs +++ b/Octokit.Reactive/Clients/ObservableDeploymentsClient.cs @@ -38,6 +38,27 @@ namespace Octokit.Reactive.Clients ApiUrls.Deployments(owner, name)); } + /// + /// Gets all the deployments for the specified repository. Any user with pull access + /// to a repository can view deployments. + /// + /// + /// http://developer.github.com/v3/repos/deployments/#list-deployments + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the specified repository. + public IObservable GetAll(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages( + ApiUrls.Deployments(owner, name), options); + } + /// /// Creates a new deployment for the specified repository. /// Users with push access can create a deployment for a given ref. From 7d5b56618bced60b1fdb4b371def7b20bbf0991d Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Fri, 25 Mar 2016 15:51:56 +0700 Subject: [PATCH 012/123] DeploymentsClientTests were updated --- .../Clients/DeploymentsClientTests.cs | 48 +++++++++++++------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/Octokit.Tests/Clients/DeploymentsClientTests.cs b/Octokit.Tests/Clients/DeploymentsClientTests.cs index 3eb59569..c0bd008d 100644 --- a/Octokit.Tests/Clients/DeploymentsClientTests.cs +++ b/Octokit.Tests/Clients/DeploymentsClientTests.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; using NSubstitute; using Octokit; +using Octokit.Tests; using Xunit; public class DeploymentsClientTests @@ -15,6 +16,7 @@ public class DeploymentsClientTests await Assert.ThrowsAsync(() => client.GetAll(null, "name")); await Assert.ThrowsAsync(() => client.GetAll("owner", null)); + await Assert.ThrowsAsync(() => client.GetAll("owner", "name", null)); } [Fact] @@ -45,24 +47,42 @@ public class DeploymentsClientTests { var connection = Substitute.For(); var client = new DeploymentsClient(connection); - var expectedUrl = "repos/owner/name/deployments"; + var expectedUrl = ApiUrls.Deployments("owner", "name"); client.GetAll("owner", "name"); - connection.Received(1).GetAll(Arg.Is(u => u.ToString() == expectedUrl)); + connection.Received(1).GetAll(Arg.Is(u => u == expectedUrl), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new DeploymentsClient(connection); + var expectedUrl = ApiUrls.Deployments("owner", "name"); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAll("owner", "name"); + connection.Received(1).GetAll(Arg.Is(u => u == expectedUrl), options); } } public class TheCreateMethod { - readonly NewDeployment newDeployment = new NewDeployment("aRef"); + private readonly NewDeployment _newDeployment = new NewDeployment("aRef"); [Fact] public async Task EnsuresNonNullArguments() { var client = new DeploymentsClient(Substitute.For()); - await Assert.ThrowsAsync(() => client.Create(null, "name", newDeployment)); - await Assert.ThrowsAsync(() => client.Create("owner", null, newDeployment)); + await Assert.ThrowsAsync(() => client.Create(null, "name", _newDeployment)); + await Assert.ThrowsAsync(() => client.Create("owner", null, _newDeployment)); await Assert.ThrowsAsync(() => client.Create("owner", "name", null)); } @@ -71,8 +91,8 @@ public class DeploymentsClientTests { var client = new DeploymentsClient(Substitute.For()); - await Assert.ThrowsAsync(() => client.Create("", "name", newDeployment)); - await Assert.ThrowsAsync(() => client.Create("owner", "", newDeployment)); + await Assert.ThrowsAsync(() => client.Create("", "name", _newDeployment)); + await Assert.ThrowsAsync(() => client.Create("owner", "", _newDeployment)); } [Theory] @@ -85,8 +105,8 @@ public class DeploymentsClientTests { var client = new DeploymentsClient(Substitute.For()); - await Assert.ThrowsAsync(() => client.Create(whitespace, "name", newDeployment)); - await Assert.ThrowsAsync(() => client.Create("owner", whitespace, newDeployment)); + await Assert.ThrowsAsync(() => client.Create(whitespace, "name", _newDeployment)); + await Assert.ThrowsAsync(() => client.Create("owner", whitespace, _newDeployment)); } [Fact] @@ -94,11 +114,11 @@ public class DeploymentsClientTests { var connection = Substitute.For(); var client = new DeploymentsClient(connection); - var expectedUrl = "repos/owner/name/deployments"; + var expectedUrl = ApiUrls.Deployments("owner", "name"); - client.Create("owner", "name", newDeployment); + client.Create("owner", "name", _newDeployment); - connection.Received(1).Post(Arg.Is(u => u.ToString() == expectedUrl), + connection.Received(1).Post(Arg.Is(u => u == expectedUrl), Arg.Any()); } @@ -108,10 +128,10 @@ public class DeploymentsClientTests var connection = Substitute.For(); var client = new DeploymentsClient(connection); - client.Create("owner", "name", newDeployment); + client.Create("owner", "name", _newDeployment); connection.Received(1).Post(Arg.Any(), - newDeployment); + _newDeployment); } } From 1ebdfbfb0acae585dd093f246bf05f003497278d Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Fri, 25 Mar 2016 15:52:12 +0700 Subject: [PATCH 013/123] ObservableDeploymentsClientTests were updated --- .../ObservableDeploymentsClientTests.cs | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs b/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs index 9005cc7e..4f63e92d 100644 --- a/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs @@ -13,8 +13,8 @@ namespace Octokit.Tests.Reactive { public class TheGetAllMethod { - readonly IGitHubClient _githubClient; - readonly ObservableDeploymentsClient _client; + private readonly IGitHubClient _githubClient; + private readonly ObservableDeploymentsClient _client; public TheGetAllMethod() { @@ -27,6 +27,7 @@ namespace Octokit.Tests.Reactive { Assert.Throws(() => _client.GetAll(null, "repo")); Assert.Throws(() => _client.GetAll("owner", null)); + Assert.Throws(() => _client.GetAll("owner", "repo", null)); } [Fact] @@ -46,7 +47,7 @@ namespace Octokit.Tests.Reactive } [Fact] - public void CallsDeploymentsUrl() + public void RequestsCorrectUrl() { var expectedUri = ApiUrls.Deployments("owner", "repo"); @@ -54,14 +55,33 @@ namespace Octokit.Tests.Reactive _githubClient.Connection .Received(1) .Get>(Arg.Is(expectedUri), - Arg.Any>(), Arg.Any()); + Arg.Is>(dictionary => dictionary.Count == 0), Arg.Any()); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var expectedUri = ApiUrls.Deployments("owner", "repo"); + + var options = new ApiOptions + { + StartPage = 1, + PageCount = 1, + PageSize = 1 + }; + + _client.GetAll("owner", "repo", options); + _githubClient.Connection + .Received(1) + .Get>(Arg.Is(expectedUri), + Arg.Is>(dictionary => dictionary.Count == 3), Arg.Any()); } } public class TheCreateMethod { - IGitHubClient _githubClient; - ObservableDeploymentsClient _client; + private readonly IGitHubClient _githubClient; + private ObservableDeploymentsClient _client; public TheCreateMethod() { From a1e9a283e90c2f506ff9a7380839f90169734f9c Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Fri, 25 Mar 2016 16:15:27 +0700 Subject: [PATCH 014/123] Small fixes in DeploymentsClientTests --- .../Clients/DeploymentsClientTests.cs | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Octokit.Tests/Clients/DeploymentsClientTests.cs b/Octokit.Tests/Clients/DeploymentsClientTests.cs index c0bd008d..e7f20ecc 100644 --- a/Octokit.Tests/Clients/DeploymentsClientTests.cs +++ b/Octokit.Tests/Clients/DeploymentsClientTests.cs @@ -9,14 +9,17 @@ public class DeploymentsClientTests { public class TheGetAllMethod { + private const string name = "name"; + private const string owner = "name"; + [Fact] public async Task EnsuresNonNullArguments() { var client = new DeploymentsClient(Substitute.For()); - await Assert.ThrowsAsync(() => client.GetAll(null, "name")); - await Assert.ThrowsAsync(() => client.GetAll("owner", null)); - await Assert.ThrowsAsync(() => client.GetAll("owner", "name", null)); + await Assert.ThrowsAsync(() => client.GetAll(null, name)); + await Assert.ThrowsAsync(() => client.GetAll(owner, null)); + await Assert.ThrowsAsync(() => client.GetAll(owner, name, null)); } [Fact] @@ -24,8 +27,8 @@ public class DeploymentsClientTests { var client = new DeploymentsClient(Substitute.For()); - await Assert.ThrowsAsync(() => client.GetAll("", "name")); - await Assert.ThrowsAsync(() => client.GetAll("owner", "")); + await Assert.ThrowsAsync(() => client.GetAll("", name)); + await Assert.ThrowsAsync(() => client.GetAll(owner, "")); } [Theory] @@ -38,8 +41,8 @@ public class DeploymentsClientTests { var client = new DeploymentsClient(Substitute.For()); - await Assert.ThrowsAsync(() => client.GetAll(whitespace, "name")); - await Assert.ThrowsAsync(() => client.GetAll("owner", whitespace)); + await Assert.ThrowsAsync(() => client.GetAll(whitespace, name)); + await Assert.ThrowsAsync(() => client.GetAll(owner, whitespace)); } [Fact] @@ -47,9 +50,9 @@ public class DeploymentsClientTests { var connection = Substitute.For(); var client = new DeploymentsClient(connection); - var expectedUrl = ApiUrls.Deployments("owner", "name"); + var expectedUrl = ApiUrls.Deployments(owner, name); - client.GetAll("owner", "name"); + client.GetAll(owner, name); connection.Received(1).GetAll(Arg.Is(u => u == expectedUrl), Args.ApiOptions); } @@ -58,7 +61,7 @@ public class DeploymentsClientTests { var connection = Substitute.For(); var client = new DeploymentsClient(connection); - var expectedUrl = ApiUrls.Deployments("owner", "name"); + var expectedUrl = ApiUrls.Deployments(owner, name); var options = new ApiOptions { @@ -67,7 +70,7 @@ public class DeploymentsClientTests StartPage = 1 }; - client.GetAll("owner", "name"); + client.GetAll(owner, name); connection.Received(1).GetAll(Arg.Is(u => u == expectedUrl), options); } } From 38dfa82100ae0c71a4684f403242a52cdfa5de78 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Fri, 25 Mar 2016 16:30:10 +0700 Subject: [PATCH 015/123] Fix for prev commit. --- Octokit.Tests/Clients/DeploymentsClientTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.Tests/Clients/DeploymentsClientTests.cs b/Octokit.Tests/Clients/DeploymentsClientTests.cs index e7f20ecc..af4ad63b 100644 --- a/Octokit.Tests/Clients/DeploymentsClientTests.cs +++ b/Octokit.Tests/Clients/DeploymentsClientTests.cs @@ -10,7 +10,7 @@ public class DeploymentsClientTests public class TheGetAllMethod { private const string name = "name"; - private const string owner = "name"; + private const string owner = "owner"; [Fact] public async Task EnsuresNonNullArguments() From 6aa617a3edf844916f01e8adc0670cc614b8a343 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Fri, 25 Mar 2016 16:31:09 +0700 Subject: [PATCH 016/123] Some additional fixes for ObservableDeploymentsClient. --- Octokit.Reactive/Clients/ObservableDeploymentsClient.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Octokit.Reactive/Clients/ObservableDeploymentsClient.cs b/Octokit.Reactive/Clients/ObservableDeploymentsClient.cs index 1851b719..3d382af5 100644 --- a/Octokit.Reactive/Clients/ObservableDeploymentsClient.cs +++ b/Octokit.Reactive/Clients/ObservableDeploymentsClient.cs @@ -31,11 +31,7 @@ namespace Octokit.Reactive.Clients /// All the s for the specified repository. public IObservable GetAll(string owner, string name) { - Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - - return _connection.GetAndFlattenAllPages( - ApiUrls.Deployments(owner, name)); + return GetAll(owner, name, ApiOptions.None); } /// From 18150cf152df5f0430a3b7ffe79fca7eb2679637 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Fri, 25 Mar 2016 16:35:59 +0700 Subject: [PATCH 017/123] Some small refactorings in ObservableDeploymentsClientTests. --- .../ObservableDeploymentsClientTests.cs | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs b/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs index 4f63e92d..ddbe4cd7 100644 --- a/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs @@ -15,6 +15,8 @@ namespace Octokit.Tests.Reactive { private readonly IGitHubClient _githubClient; private readonly ObservableDeploymentsClient _client; + private const string owner = "owner"; + private const string name = "name"; public TheGetAllMethod() { @@ -25,33 +27,33 @@ namespace Octokit.Tests.Reactive [Fact] public void EnsuresNonNullArguments() { - Assert.Throws(() => _client.GetAll(null, "repo")); - Assert.Throws(() => _client.GetAll("owner", null)); - Assert.Throws(() => _client.GetAll("owner", "repo", null)); + Assert.Throws(() => _client.GetAll(null, name)); + Assert.Throws(() => _client.GetAll(owner, null)); + Assert.Throws(() => _client.GetAll(owner, name, null)); } [Fact] public void EnsuresNonEmptyArguments() { - Assert.Throws(() => _client.GetAll("", "repo")); - Assert.Throws(() => _client.GetAll("owner", "")); + Assert.Throws(() => _client.GetAll("", name)); + Assert.Throws(() => _client.GetAll(owner, "")); } [Fact] public async Task EnsuresNonWhitespaceArguments() { await AssertEx.ThrowsWhenGivenWhitespaceArgument( - async whitespace => await _client.GetAll(whitespace, "repo")); + async whitespace => await _client.GetAll(whitespace, name)); await AssertEx.ThrowsWhenGivenWhitespaceArgument( - async whitespace => await _client.GetAll("owner", whitespace)); + async whitespace => await _client.GetAll(owner, whitespace)); } [Fact] public void RequestsCorrectUrl() { - var expectedUri = ApiUrls.Deployments("owner", "repo"); + var expectedUri = ApiUrls.Deployments(owner, name); - _client.GetAll("owner", "repo"); + _client.GetAll(owner, name); _githubClient.Connection .Received(1) .Get>(Arg.Is(expectedUri), @@ -61,7 +63,7 @@ namespace Octokit.Tests.Reactive [Fact] public void RequestsCorrectUrlWithApiOptions() { - var expectedUri = ApiUrls.Deployments("owner", "repo"); + var expectedUri = ApiUrls.Deployments(owner, name); var options = new ApiOptions { @@ -70,7 +72,7 @@ namespace Octokit.Tests.Reactive PageSize = 1 }; - _client.GetAll("owner", "repo", options); + _client.GetAll(owner, name, options); _githubClient.Connection .Received(1) .Get>(Arg.Is(expectedUri), From 9943af7ef169da310e9c261128c0a47a663bce38 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Fri, 25 Mar 2016 17:11:50 +0700 Subject: [PATCH 018/123] Integration tests for ApiOptions were added. --- .../Clients/DeploymentsClientTests.cs | 119 +++++++++++++++--- 1 file changed, 99 insertions(+), 20 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs b/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs index af308d6f..b2ab7abe 100644 --- a/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Octokit; using Octokit.Tests.Integration; @@ -9,7 +11,7 @@ public class DeploymentsClientTests : IDisposable { private readonly IDeploymentsClient _deploymentsClient; private readonly RepositoryContext _context; - private readonly Commit _commit; + private readonly ICollection _commits; public DeploymentsClientTests() { @@ -17,33 +19,38 @@ public class DeploymentsClientTests : IDisposable _deploymentsClient = github.Repository.Deployment; _context = github.CreateRepositoryContext("public-repo").Result; + _commits = new List(); - var blob = new NewBlob + for (int i = 0; i < 6; i++) { - Content = "Hello World!", - Encoding = EncodingType.Utf8 - }; + var blob = new NewBlob + { + Content = string.Format("Hello World {0}!", i), + Encoding = EncodingType.Utf8 + }; - var blobResult = github.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob).Result; + var blobResult = github.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob).Result; - var newTree = new NewTree(); - newTree.Tree.Add(new NewTreeItem - { - Type = TreeType.Blob, - Mode = FileMode.File, - Path = "README.md", - Sha = blobResult.Sha - }); + var newTree = new NewTree(); + newTree.Tree.Add(new NewTreeItem + { + Type = TreeType.Blob, + Mode = FileMode.File, + Path = "README.md", + Sha = blobResult.Sha + }); - var treeResult = github.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree).Result; - var newCommit = new NewCommit("test-commit", treeResult.Sha); - _commit = github.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit).Result; + var treeResult = github.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree).Result; + var newCommit = new NewCommit("test-commit", treeResult.Sha); + var commit = github.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit).Result; + _commits.Add(commit); + } } [IntegrationTest] public async Task CanCreateDeployment() { - var newDeployment = new NewDeployment(_commit.Sha) { AutoMerge = false }; + var newDeployment = new NewDeployment(_commits.First().Sha) { AutoMerge = false }; var deployment = await _deploymentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newDeployment); @@ -51,9 +58,9 @@ public class DeploymentsClientTests : IDisposable } [IntegrationTest] - public async Task CanGetDeployments() + public async Task ReturnsDeployments() { - var newDeployment = new NewDeployment(_commit.Sha) { AutoMerge = false }; + var newDeployment = new NewDeployment(_commits.First().Sha) { AutoMerge = false }; await _deploymentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newDeployment); var deployments = await _deploymentsClient.GetAll(_context.RepositoryOwner, _context.RepositoryName); @@ -61,6 +68,78 @@ public class DeploymentsClientTests : IDisposable Assert.NotEmpty(deployments); } + [IntegrationTest] + public async Task ReturnsCorrectCountOfDeploymentsWithoutStart() + { + foreach (var commit in _commits) + { + var newDeployment = new NewDeployment(commit.Sha) { AutoMerge = false }; + await _deploymentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newDeployment); + } + + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var releases = await _deploymentsClient.GetAll(_context.RepositoryOwner, _context.RepositoryName, options); + + Assert.Equal(5, releases.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfDeploymentsWithStart() + { + foreach (var commit in _commits) + { + var newDeployment = new NewDeployment(commit.Sha) { AutoMerge = false }; + await _deploymentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newDeployment); + } + + var options = new ApiOptions + { + PageSize = 3, + PageCount = 1, + StartPage = 2 + }; + + var releases = await _deploymentsClient.GetAll(_context.RepositoryOwner, _context.RepositoryName, options); + + Assert.Equal(3, releases.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + foreach (var commit in _commits) + { + var newDeployment = new NewDeployment(commit.Sha) { AutoMerge = false }; + await _deploymentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newDeployment); + } + + var startOptions = new ApiOptions + { + PageSize = 3, + PageCount = 1 + }; + + var firstPage = await _deploymentsClient.GetAll(_context.RepositoryOwner, _context.RepositoryName, startOptions); + + var skipStartOptions = new ApiOptions + { + PageSize = 3, + PageCount = 1, + StartPage = 2 + }; + + var secondPage = await _deploymentsClient.GetAll(_context.RepositoryOwner, _context.RepositoryName, skipStartOptions); + + Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); + Assert.NotEqual(firstPage[1].Id, secondPage[1].Id); + Assert.NotEqual(firstPage[2].Id, secondPage[2].Id); + } + public void Dispose() { _context.Dispose(); From 9ec431f95e3113fc7d4d73729822e64b34ff27be Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Fri, 25 Mar 2016 23:19:01 +0700 Subject: [PATCH 019/123] Fix red test. --- Octokit.Tests/Clients/DeploymentsClientTests.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Octokit.Tests/Clients/DeploymentsClientTests.cs b/Octokit.Tests/Clients/DeploymentsClientTests.cs index af4ad63b..7597989b 100644 --- a/Octokit.Tests/Clients/DeploymentsClientTests.cs +++ b/Octokit.Tests/Clients/DeploymentsClientTests.cs @@ -53,7 +53,8 @@ public class DeploymentsClientTests var expectedUrl = ApiUrls.Deployments(owner, name); client.GetAll(owner, name); - connection.Received(1).GetAll(Arg.Is(u => u == expectedUrl), Args.ApiOptions); + connection.Received(1) + .GetAll(Arg.Is(u => u == expectedUrl), Args.ApiOptions); } [Fact] @@ -70,8 +71,9 @@ public class DeploymentsClientTests StartPage = 1 }; - client.GetAll(owner, name); - connection.Received(1).GetAll(Arg.Is(u => u == expectedUrl), options); + client.GetAll(owner, name, options); + connection.Received(1) + .GetAll(Arg.Is(u => u == expectedUrl), options); } } From b54922b855de980a89b42545a8a72ed61ef4b60c Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Fri, 25 Mar 2016 23:51:08 +0700 Subject: [PATCH 020/123] In order to test ApiOptions we should check count of recived parameters. Fixed. --- .../ObservableDeploymentsClientTests.cs | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs b/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs index ddbe4cd7..e3d815b9 100644 --- a/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs @@ -65,6 +65,7 @@ namespace Octokit.Tests.Reactive { var expectedUri = ApiUrls.Deployments(owner, name); + // all properties are setted => only 2 options (StartPage, PageSize) in Dictionary var options = new ApiOptions { StartPage = 1, @@ -76,7 +77,31 @@ namespace Octokit.Tests.Reactive _githubClient.Connection .Received(1) .Get>(Arg.Is(expectedUri), - Arg.Is>(dictionary => dictionary.Count == 3), Arg.Any()); + Arg.Is>(dictionary => dictionary.Count == 2), null); + + // StartPage is setted => only 1 option (StartPage) in Dictionary + options = new ApiOptions + { + StartPage = 1 + }; + + _client.GetAll(owner, name, options); + _githubClient.Connection + .Received(1) + .Get>(Arg.Is(expectedUri), + Arg.Is>(dictionary => dictionary.Count == 1), null); + + // PageCount is setted => none of options in Dictionary + options = new ApiOptions + { + PageCount = 1 + }; + + _client.GetAll(owner, name, options); + _githubClient.Connection + .Received(1) + .Get>(Arg.Is(expectedUri), + Arg.Is>(dictionary => dictionary.Count == 0), null); } } From 06ab549f759c62fc09860d7e3dbfa6b9ca3da245 Mon Sep 17 00:00:00 2001 From: Abdelkhalek Oussama Elhamer Date: Sat, 26 Mar 2016 03:23:42 +0100 Subject: [PATCH 021/123] Refactoring the code by calling the GetAll with the ApiOption.None in one of the overloads --- Octokit.Reactive/Clients/ObservableCommitStatusClient.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs b/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs index bf4b092f..cc43773e 100644 --- a/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs +++ b/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs @@ -31,8 +31,8 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); - - return _connection.GetAndFlattenAllPages(ApiUrls.CommitStatuses(owner, name, reference)); + + return GetAll(owner, name ,reference, ApiOptions.None); } /// From 2e8317d536d203e43d64570d900c16eda84028b2 Mon Sep 17 00:00:00 2001 From: Abdelkhalek Oussama Elhamer Date: Sat, 26 Mar 2016 03:26:59 +0100 Subject: [PATCH 022/123] Change the GetAll method by calling the other overload usign ApiOption.None --- Octokit.Reactive/Clients/ObservableReleasesClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.Reactive/Clients/ObservableReleasesClient.cs b/Octokit.Reactive/Clients/ObservableReleasesClient.cs index 100bd131..880580c1 100644 --- a/Octokit.Reactive/Clients/ObservableReleasesClient.cs +++ b/Octokit.Reactive/Clients/ObservableReleasesClient.cs @@ -33,7 +33,7 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return _connection.GetAndFlattenAllPages(ApiUrls.Releases(owner, name)); + return GetAll(owner, name, ApiOptions.None); } /// From a9014616ce04a470bc5201f2de88b5b6b3de2ce5 Mon Sep 17 00:00:00 2001 From: Abdelkhalek Oussama Elhamer Date: Sat, 26 Mar 2016 05:03:04 +0100 Subject: [PATCH 023/123] Fix a failling test after refactoring the GetAll releases method --- Octokit.Tests/Reactive/ObservableReleasesClientTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs b/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs index fd8f94bb..77e09103 100644 --- a/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs @@ -29,7 +29,7 @@ namespace Octokit.Tests.Reactive client.GetAll("fake", "repo"); gitHubClient.Connection.Received(1).Get>( - new Uri("repos/fake/repo/releases", UriKind.Relative), null, null); + new Uri("repos/fake/repo/releases", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] From 761bee4a35630d690111d86839b799bd41e39833 Mon Sep 17 00:00:00 2001 From: Abdelkhalek Oussama Elhamer Date: Sat, 26 Mar 2016 05:28:08 +0100 Subject: [PATCH 024/123] Add the IntegrationTests for the ObservableCommitStatusClient --- .../Octokit.Tests.Integration.csproj | 1 + .../ObservableCommitStatusClientTests.cs | 88 +++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 Octokit.Tests.Integration/Reactive/ObservableCommitStatusClientTests.cs diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 4181ab35..960f011e 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -141,6 +141,7 @@ + diff --git a/Octokit.Tests.Integration/Reactive/ObservableCommitStatusClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableCommitStatusClientTests.cs new file mode 100644 index 00000000..c2fd4706 --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableCommitStatusClientTests.cs @@ -0,0 +1,88 @@ +using System.Reactive.Linq; +using System.Threading.Tasks; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Integration.Reactive +{ + public class ObservableCommitStatusClientTests + { + public class TheGetAllMethod + { + readonly ObservableCommitStatusClient _commitStatusClient; + const string owner = "octokit"; + const string name = "octokit.net"; + const string reference = "master"; + + public TheGetAllMethod() + { + var github = Helper.GetAuthenticatedClient(); + _commitStatusClient = new ObservableCommitStatusClient(github); + } + + [IntegrationTest] + public async Task ReturnCommitStatus() + { + var commitStatus = await _commitStatusClient.GetAll(owner, name, reference).ToList(); + + Assert.NotEmpty(commitStatus); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfCommitStatusWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var commitStatus = await _commitStatusClient.GetAll(owner, name ,reference , options).ToList(); + + Assert.Equal(5, commitStatus.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfCommitStatusWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 1 + }; + + var commitStatus = await _commitStatusClient.GetAll(owner, name, reference, options).ToList(); + + Assert.Equal(5, commitStatus.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstPage = await _commitStatusClient.GetAll(owner, name, reference, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondPage = await _commitStatusClient.GetAll(owner, name, reference,skipStartOptions).ToList(); + + Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); + Assert.NotEqual(firstPage[1].Id, secondPage[1].Id); + Assert.NotEqual(firstPage[2].Id, secondPage[2].Id); + Assert.NotEqual(firstPage[3].Id, secondPage[3].Id); + Assert.NotEqual(firstPage[4].Id, secondPage[4].Id); + } + } + } +} From b225b25483caf16b43944ab4d0ed8d93f76acd46 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Sat, 26 Mar 2016 13:02:45 +0700 Subject: [PATCH 025/123] Some useful fixes in DeploymentsClientTests. --- Octokit.Tests/Clients/DeploymentsClientTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests/Clients/DeploymentsClientTests.cs b/Octokit.Tests/Clients/DeploymentsClientTests.cs index 7597989b..ef69431c 100644 --- a/Octokit.Tests/Clients/DeploymentsClientTests.cs +++ b/Octokit.Tests/Clients/DeploymentsClientTests.cs @@ -119,11 +119,11 @@ public class DeploymentsClientTests { var connection = Substitute.For(); var client = new DeploymentsClient(connection); - var expectedUrl = ApiUrls.Deployments("owner", "name"); + var expectedUrl = "repos/owner/name/deployments"; client.Create("owner", "name", _newDeployment); - connection.Received(1).Post(Arg.Is(u => u == expectedUrl), + connection.Received(1).Post(Arg.Is(u => u.ToString() == expectedUrl), Arg.Any()); } From b34ba547a7ab9828cee2190a568a07cfe7ba3bd6 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Mon, 28 Mar 2016 12:33:26 +0700 Subject: [PATCH 026/123] Small refactoring of DeploymentsClientTests. --- .../Clients/DeploymentsClientTests.cs | 53 +++++++++++++++---- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs b/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs index b2ab7abe..8cc015ff 100644 --- a/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/DeploymentsClientTests.cs @@ -1,17 +1,16 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using Octokit; using Octokit.Tests.Integration; -using Xunit; using Octokit.Tests.Integration.Helpers; +using Xunit; public class DeploymentsClientTests : IDisposable { private readonly IDeploymentsClient _deploymentsClient; private readonly RepositoryContext _context; - private readonly ICollection _commits; + private readonly Commit _commit; public DeploymentsClientTests() { @@ -19,9 +18,36 @@ public class DeploymentsClientTests : IDisposable _deploymentsClient = github.Repository.Deployment; _context = github.CreateRepositoryContext("public-repo").Result; - _commits = new List(); - for (int i = 0; i < 6; i++) + var blob = new NewBlob + { + Content = "Hello World!", + Encoding = EncodingType.Utf8 + }; + + var blobResult = github.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob).Result; + + var newTree = new NewTree(); + newTree.Tree.Add(new NewTreeItem + { + Type = TreeType.Blob, + Mode = FileMode.File, + Path = "README.md", + Sha = blobResult.Sha + }); + + var treeResult = github.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree).Result; + var newCommit = new NewCommit("test-commit", treeResult.Sha); + _commit = github.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit).Result; + } + + private IEnumerable CreateCommits(int commitCount) + { + var github = Helper.GetAuthenticatedClient(); + + var list = new List(); + + for (int i = 0; i < commitCount; i++) { var blob = new NewBlob { @@ -43,14 +69,16 @@ public class DeploymentsClientTests : IDisposable var treeResult = github.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree).Result; var newCommit = new NewCommit("test-commit", treeResult.Sha); var commit = github.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit).Result; - _commits.Add(commit); + list.Add(commit); } + + return list; } [IntegrationTest] public async Task CanCreateDeployment() { - var newDeployment = new NewDeployment(_commits.First().Sha) { AutoMerge = false }; + var newDeployment = new NewDeployment(_commit.Sha) { AutoMerge = false }; var deployment = await _deploymentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newDeployment); @@ -60,7 +88,7 @@ public class DeploymentsClientTests : IDisposable [IntegrationTest] public async Task ReturnsDeployments() { - var newDeployment = new NewDeployment(_commits.First().Sha) { AutoMerge = false }; + var newDeployment = new NewDeployment(_commit.Sha) { AutoMerge = false }; await _deploymentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newDeployment); var deployments = await _deploymentsClient.GetAll(_context.RepositoryOwner, _context.RepositoryName); @@ -71,7 +99,8 @@ public class DeploymentsClientTests : IDisposable [IntegrationTest] public async Task ReturnsCorrectCountOfDeploymentsWithoutStart() { - foreach (var commit in _commits) + var commits = CreateCommits(6); + foreach (var commit in commits) { var newDeployment = new NewDeployment(commit.Sha) { AutoMerge = false }; await _deploymentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newDeployment); @@ -91,7 +120,8 @@ public class DeploymentsClientTests : IDisposable [IntegrationTest] public async Task ReturnsCorrectCountOfDeploymentsWithStart() { - foreach (var commit in _commits) + var commits = CreateCommits(6); + foreach (var commit in commits) { var newDeployment = new NewDeployment(commit.Sha) { AutoMerge = false }; await _deploymentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newDeployment); @@ -112,7 +142,8 @@ public class DeploymentsClientTests : IDisposable [IntegrationTest] public async Task ReturnsDistinctResultsBasedOnStartPage() { - foreach (var commit in _commits) + var commits = CreateCommits(6); + foreach (var commit in commits) { var newDeployment = new NewDeployment(commit.Sha) { AutoMerge = false }; await _deploymentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newDeployment); From 78f9aae43157bd39ff9bc6b21e4f260544da818c Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:35:43 +0700 Subject: [PATCH 027/123] IAuthorizationsClient and AuthorizationsClient fixes --- Octokit/Clients/AuthorizationsClient.cs | 2 +- Octokit/Clients/IAuthorizationsClient.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit/Clients/AuthorizationsClient.cs b/Octokit/Clients/AuthorizationsClient.cs index 92a4cf4b..0030d108 100644 --- a/Octokit/Clients/AuthorizationsClient.cs +++ b/Octokit/Clients/AuthorizationsClient.cs @@ -353,7 +353,7 @@ namespace Octokit } /// - /// Resets a valid OAuth token for an OAuth application without end user involvment. + /// Resets a valid OAuth token for an OAuth application without end user involvement. /// /// /// This method requires authentication. diff --git a/Octokit/Clients/IAuthorizationsClient.cs b/Octokit/Clients/IAuthorizationsClient.cs index c78a048d..994a9494 100644 --- a/Octokit/Clients/IAuthorizationsClient.cs +++ b/Octokit/Clients/IAuthorizationsClient.cs @@ -215,7 +215,7 @@ namespace Octokit Task CheckApplicationAuthentication(string clientId, string accessToken); /// - /// Resets a valid OAuth token for an OAuth application without end user involvment. + /// Resets a valid OAuth token for an OAuth application without end user involvement. /// /// /// This method requires authentication. From 655dde808187241c6a41cebe4225229330a3a8a2 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:36:04 +0700 Subject: [PATCH 028/123] ApiUrls fixes. --- Octokit/Helpers/ApiUrls.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 54d6edaa..9abff514 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -17,7 +17,7 @@ namespace Octokit static readonly Uri _currentUserAllIssues = new Uri("issues", UriKind.Relative); static readonly Uri _currentUserOwnedAndMemberIssues = new Uri("user/issues", UriKind.Relative); static readonly Uri _oauthAuthorize = new Uri("login/oauth/authorize", UriKind.Relative); - static readonly Uri _oauthAccesToken = new Uri("login/oauth/access_token", UriKind.Relative); + static readonly Uri _oauthAccessToken = new Uri("login/oauth/access_token", UriKind.Relative); /// /// Returns the that returns all public repositories in @@ -1135,7 +1135,7 @@ namespace Octokit } /// - /// Returns the for a specifc blob. + /// Returns the for a specific blob. /// /// The owner of the blob /// The name of the organization @@ -1146,7 +1146,7 @@ namespace Octokit } /// - /// Returns the for a specifc blob. + /// Returns the for a specific blob. /// /// The owner of the blob /// The name of the organization @@ -1560,7 +1560,7 @@ namespace Octokit /// public static Uri OauthAccessToken() { - return _oauthAccesToken; + return _oauthAccessToken; } /// From 0a71cb4abe56ba0576be23de5d59ef6dbab516df Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:36:34 +0700 Subject: [PATCH 029/123] Connection.cs fixes --- Octokit/Http/Connection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Http/Connection.cs b/Octokit/Http/Connection.cs index 81a1f86b..084f550d 100644 --- a/Octokit/Http/Connection.cs +++ b/Octokit/Http/Connection.cs @@ -142,7 +142,7 @@ namespace Octokit /// representing the information returned as part of an Api call public ApiInfo GetLastApiInfo() { - // We've choosen to not wrap the _lastApiInfo in a lock. Originally the code was returning a reference - so there was a danger of + // We've chosen to not wrap the _lastApiInfo in a lock. Originally the code was returning a reference - so there was a danger of // on thread writing to the object while another was reading. Now we are cloning the ApiInfo on request - thus removing the need (or overhead) // of putting locks in place. // See https://github.com/octokit/octokit.net/pull/855#discussion_r36774884 From 5c98093f7d1a7c4a746526389acf3c989f2daa7e Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:37:00 +0700 Subject: [PATCH 030/123] IMiscellaneousClient and MiscellaneousClient fixes --- Octokit/Clients/IMiscellaneousClient.cs | 2 +- Octokit/Clients/MiscellaneousClient.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit/Clients/IMiscellaneousClient.cs b/Octokit/Clients/IMiscellaneousClient.cs index 6df182db..3f20fabf 100644 --- a/Octokit/Clients/IMiscellaneousClient.cs +++ b/Octokit/Clients/IMiscellaneousClient.cs @@ -62,7 +62,7 @@ namespace Octokit Task> GetAllLicenses(); /// - /// Retrieves a license based on the licence key such as "mit" + /// Retrieves a license based on the license key such as "mit" /// /// /// A that includes the license key, text, and attributes of the license. diff --git a/Octokit/Clients/MiscellaneousClient.cs b/Octokit/Clients/MiscellaneousClient.cs index 7079fada..c9f03d54 100644 --- a/Octokit/Clients/MiscellaneousClient.cs +++ b/Octokit/Clients/MiscellaneousClient.cs @@ -117,7 +117,7 @@ namespace Octokit } /// - /// Retrieves a license based on the licence key such as "mit" + /// Retrieves a license based on the license key such as "mit" /// /// /// A that includes the license key, text, and attributes of the license. From 9dcfb2e4264f09639354acd277459ebc67d404fd Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:37:22 +0700 Subject: [PATCH 031/123] IRepositoriesClient and RepositoriesClient fixes. --- Octokit/Clients/IRepositoriesClient.cs | 4 ++-- Octokit/Clients/RepositoriesClient.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index 098e03d0..0989d99f 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -73,7 +73,7 @@ namespace Octokit /// /// See the API documentation for more information. /// - /// Login of the organization in which to create the repostiory + /// Login of the organization in which to create the repository /// A instance describing the new repository to create /// Thrown when a general API error occurs. /// A instance for the created repository @@ -351,7 +351,7 @@ namespace Octokit /// /// The owner of the repository /// The name of the repository - /// All of the repositorys tags. + /// All of the repositories tags. Task> GetAllTags(string owner, string name); /// diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 9f14ac78..1619ae37 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -69,7 +69,7 @@ namespace Octokit /// /// See the API documentation for more information. /// - /// Login of the organization in which to create the repostiory + /// Login of the organization in which to create the repository /// A instance describing the new repository to create /// Thrown when a general API error occurs. /// A instance for the created repository @@ -551,7 +551,7 @@ namespace Octokit /// /// The owner of the repository /// The name of the repository - /// All of the repositorys tags. + /// All of the repositories tags. public Task> GetAllTags(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); From 9ec62f5ee1325dbdc670919d047377a04f2b94aa Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:37:54 +0700 Subject: [PATCH 032/123] IObservableAuthorizationsClient and ObservableAuthorizationsClient fixes --- Octokit.Reactive/Clients/IObservableAuthorizationsClient.cs | 2 +- Octokit.Reactive/Clients/ObservableAuthorizationsClient.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableAuthorizationsClient.cs b/Octokit.Reactive/Clients/IObservableAuthorizationsClient.cs index 0e5083fd..1b7505ca 100644 --- a/Octokit.Reactive/Clients/IObservableAuthorizationsClient.cs +++ b/Octokit.Reactive/Clients/IObservableAuthorizationsClient.cs @@ -190,7 +190,7 @@ namespace Octokit.Reactive IObservable CheckApplicationAuthentication(string clientId, string accessToken); /// - /// Resets a valid OAuth token for an OAuth application without end user involvment. + /// Resets a valid OAuth token for an OAuth application without end user involvement. /// /// /// This method requires authentication. diff --git a/Octokit.Reactive/Clients/ObservableAuthorizationsClient.cs b/Octokit.Reactive/Clients/ObservableAuthorizationsClient.cs index d5cd1989..8ae04e50 100644 --- a/Octokit.Reactive/Clients/ObservableAuthorizationsClient.cs +++ b/Octokit.Reactive/Clients/ObservableAuthorizationsClient.cs @@ -264,7 +264,7 @@ namespace Octokit.Reactive } /// - /// Resets a valid OAuth token for an OAuth application without end user involvment. + /// Resets a valid OAuth token for an OAuth application without end user involvement. /// /// /// This method requires authentication. From 29ada0c15e4f400bafab77ee6219b1e0b23a58ef Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:38:14 +0700 Subject: [PATCH 033/123] IApiInfoProvider fixes --- Octokit/Http/IApiInfoProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Http/IApiInfoProvider.cs b/Octokit/Http/IApiInfoProvider.cs index c0b5dfb9..8221682a 100644 --- a/Octokit/Http/IApiInfoProvider.cs +++ b/Octokit/Http/IApiInfoProvider.cs @@ -1,7 +1,7 @@ namespace Octokit { /// - /// Provides a property for the Last recorded API infomation + /// Provides a property for the Last recorded API information /// public interface IApiInfoProvider { From fc644a0b1d897a9cf8d25941c80d8fc673e6ae7b Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:38:39 +0700 Subject: [PATCH 034/123] ConnectionTests fixes --- Octokit.Tests/Http/ConnectionTests.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Octokit.Tests/Http/ConnectionTests.cs b/Octokit.Tests/Http/ConnectionTests.cs index db72cbef..01850ccc 100644 --- a/Octokit.Tests/Http/ConnectionTests.cs +++ b/Octokit.Tests/Http/ConnectionTests.cs @@ -7,9 +7,7 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; using NSubstitute; -using NSubstitute.Core.Arguments; using Octokit.Internal; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Http @@ -44,7 +42,7 @@ namespace Octokit.Tests.Http } [Fact] - public async Task CanMakeMutipleRequestsWithSameConnection() + public async Task CanMakeMultipleRequestsWithSameConnection() { var httpClient = Substitute.For(); IResponse response = new Response(); From bc0390ef4a9c3dae39a8678c20d0897cd25a9966 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:39:08 +0700 Subject: [PATCH 035/123] IObservableMiscellaneousClient and ObservableMiscellaneousClient fixes --- Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs | 2 +- Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs b/Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs index 8f1f3bdb..25d63bc4 100644 --- a/Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs +++ b/Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs @@ -53,7 +53,7 @@ namespace Octokit.Reactive IObservable GetAllLicenses(); /// - /// Retrieves a license based on the licence key such as "mit" + /// Retrieves a license based on the license key such as "mit" /// /// /// A that includes the license key, text, and attributes of the license. diff --git a/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs b/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs index ea9c4096..50ba37e0 100644 --- a/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs +++ b/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs @@ -78,7 +78,7 @@ namespace Octokit.Reactive } /// - /// Retrieves a license based on the licence key such as "mit" + /// Retrieves a license based on the license key such as "mit" /// /// /// A that includes the license key, text, and attributes of the license. From 570d70ab314bc957c8361fe06f94befe47d2e305 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:39:31 +0700 Subject: [PATCH 036/123] IObservableRepositoriesClient and ObservableRepositoriesClient fixes. --- Octokit.Reactive/Clients/IObservableRepositoriesClient.cs | 4 ++-- Octokit.Reactive/Clients/ObservableRepositoriesClient.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs index 123860bc..8f47b4fe 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs @@ -16,7 +16,7 @@ namespace Octokit.Reactive /// /// Creates a new repository in the specified organization. /// - /// The login of the organization in which to create the repostiory + /// The login of the organization in which to create the repository /// A instance describing the new repository to create /// An instance for the created repository IObservable Create(string organizationLogin, NewRepository newRepository); @@ -256,7 +256,7 @@ namespace Octokit.Reactive /// /// The owner of the repository /// The name of the repository - /// All of the repositorys tags. + /// All of the repositories tags. IObservable GetAllTags(string owner, string name); /// diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs index 005270bb..d7d7d4cd 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs @@ -61,7 +61,7 @@ namespace Octokit.Reactive /// /// Creates a new repository in the specified organization. /// - /// The login of the organization in which to create the repostiory + /// The login of the organization in which to create the repository /// A instance describing the new repository to create /// An instance for the created repository public IObservable Create(string organizationLogin, NewRepository newRepository) @@ -374,7 +374,7 @@ namespace Octokit.Reactive /// /// The owner of the repository /// The name of the repository - /// All of the repositorys tags. + /// All of the repositories tags. public IObservable GetAllTags(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); From 1f119767dce59baf0ac28979872cf388658cf364 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:40:40 +0700 Subject: [PATCH 037/123] IAssigneesClient fixes --- Octokit/Clients/IAssigneesClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Clients/IAssigneesClient.cs b/Octokit/Clients/IAssigneesClient.cs index f3bc5b79..77d04912 100644 --- a/Octokit/Clients/IAssigneesClient.cs +++ b/Octokit/Clients/IAssigneesClient.cs @@ -24,7 +24,7 @@ namespace Octokit /// /// The owner of the repository /// The name of the repository - /// The options to chagne API's response. + /// The options to change API's response. /// Task> GetAllForRepository(string owner, string name, ApiOptions options); From 7dc3c413525b645bf10d30ded6fcaf9cab94d667 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:40:55 +0700 Subject: [PATCH 038/123] IRepositoryContentsClient and RepositoryContentsClient fixes --- Octokit/Clients/IRepositoryContentsClient.cs | 2 +- Octokit/Clients/RepositoryContentsClient.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit/Clients/IRepositoryContentsClient.cs b/Octokit/Clients/IRepositoryContentsClient.cs index b072dc17..daf12728 100644 --- a/Octokit/Clients/IRepositoryContentsClient.cs +++ b/Octokit/Clients/IRepositoryContentsClient.cs @@ -80,7 +80,7 @@ namespace Octokit Task GetReadme(string owner, string name); /// - /// Gets the perferred README's HTML for the specified repository. + /// Gets the preferred README's HTML for the specified repository. /// /// /// See the API documentation for more information. diff --git a/Octokit/Clients/RepositoryContentsClient.cs b/Octokit/Clients/RepositoryContentsClient.cs index 7f3081c2..3b835d35 100644 --- a/Octokit/Clients/RepositoryContentsClient.cs +++ b/Octokit/Clients/RepositoryContentsClient.cs @@ -131,7 +131,7 @@ namespace Octokit } /// - /// Gets the perferred README's HTML for the specified repository. + /// Gets the preferred README's HTML for the specified repository. /// /// /// See the API documentation for more information. From 4300c5e17c76b57b9e4ea8d14a435c32f35c14bc Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:41:45 +0700 Subject: [PATCH 039/123] RepositoryIssueRequest fixes --- Octokit/Models/Request/RepositoryIssueRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Models/Request/RepositoryIssueRequest.cs b/Octokit/Models/Request/RepositoryIssueRequest.cs index 6e82cefc..30915cc6 100644 --- a/Octokit/Models/Request/RepositoryIssueRequest.cs +++ b/Octokit/Models/Request/RepositoryIssueRequest.cs @@ -3,7 +3,7 @@ namespace Octokit { /// - /// Used to requent and filter a list of repository issues. + /// Used to request and filter a list of repository issues. /// [DebuggerDisplay("{DebuggerDisplay,nq}")] public class RepositoryIssueRequest : IssueRequest From 8e7bfe63c45837e2725b81a8fb10593d20d78c77 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:41:57 +0700 Subject: [PATCH 040/123] RepositoryRequest fixes --- Octokit/Models/Request/RepositoryRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Models/Request/RepositoryRequest.cs b/Octokit/Models/Request/RepositoryRequest.cs index ddb0beb4..813de9f5 100644 --- a/Octokit/Models/Request/RepositoryRequest.cs +++ b/Octokit/Models/Request/RepositoryRequest.cs @@ -90,7 +90,7 @@ namespace Octokit Owner, /// - /// Returns public repositoires. + /// Returns public repositories. /// Public, From 09582fc5ebaf7a8dbee785e63a7f8c33e73f80b0 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:42:06 +0700 Subject: [PATCH 041/123] SearchQualifierOperator fixes --- Octokit/Models/Request/SearchQualifierOperator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Models/Request/SearchQualifierOperator.cs b/Octokit/Models/Request/SearchQualifierOperator.cs index 5ed9481f..de42deb6 100644 --- a/Octokit/Models/Request/SearchQualifierOperator.cs +++ b/Octokit/Models/Request/SearchQualifierOperator.cs @@ -1,7 +1,7 @@ namespace Octokit { /// - /// Used to qualify a serch term. + /// Used to qualify a search term. /// public enum SearchQualifierOperator { From 2fa41b7f3f4594bee545729a811464cf083ac28d Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:42:20 +0700 Subject: [PATCH 042/123] SearchRepositoriesRequest fixes --- .../Request/SearchRepositoriesRequest.cs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Octokit/Models/Request/SearchRepositoriesRequest.cs b/Octokit/Models/Request/SearchRepositoriesRequest.cs index 9cce0203..8a08c357 100644 --- a/Octokit/Models/Request/SearchRepositoriesRequest.cs +++ b/Octokit/Models/Request/SearchRepositoriesRequest.cs @@ -321,10 +321,10 @@ namespace Octokit } /// - /// helper method to create a LessThan Date Comparision + /// helper method to create a LessThan Date Comparison /// e.g. < 2011 /// - /// date to be used for comparision (times are ignored) + /// date to be used for comparison (times are ignored) /// public static DateRange LessThan(DateTime date) { @@ -332,10 +332,10 @@ namespace Octokit } /// - /// helper method to create a LessThanOrEqualTo Date Comparision + /// helper method to create a LessThanOrEqualTo Date Comparison /// e.g. <= 2011 /// - /// date to be used for comparision (times are ignored) + /// date to be used for comparison (times are ignored) /// public static DateRange LessThanOrEquals(DateTime date) { @@ -343,10 +343,10 @@ namespace Octokit } /// - /// helper method to create a GreaterThan Date Comparision + /// helper method to create a GreaterThan Date Comparison /// e.g. > 2011 /// - /// date to be used for comparision (times are ignored) + /// date to be used for comparison (times are ignored) /// public static DateRange GreaterThan(DateTime date) { @@ -354,10 +354,10 @@ namespace Octokit } /// - /// helper method to create a GreaterThanOrEqualTo Date Comparision + /// helper method to create a GreaterThanOrEqualTo Date Comparison /// e.g. >= 2011 /// - /// date to be used for comparision (times are ignored) + /// date to be used for comparison (times are ignored) /// public static DateRange GreaterThanOrEquals(DateTime date) { @@ -479,9 +479,9 @@ namespace Octokit [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Edn")] Edn, Eiffel, - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Elixer")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Elixer")] - Elixer, + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Elixir")] + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Elixir")] + Elixir, Elm, [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Emacs")] [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Emacs")] @@ -709,9 +709,9 @@ namespace Octokit [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "TypeScript")] [Parameter(Value = "TypeScript")] TypeScript, - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Paralel")] - [Parameter(Value = "Unified Paralel C")] - UnifiedParalelC, + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Parallel")] + [Parameter(Value = "Unified Parallel C")] + UnifiedParallelC, Unknown, [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Vala")] Vala, From 211cfb00360330cd5e012961496cbc1ebfb00199 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:42:33 +0700 Subject: [PATCH 043/123] BranchProtection fixes --- Octokit/Models/Response/BranchProtection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Models/Response/BranchProtection.cs b/Octokit/Models/Response/BranchProtection.cs index 31a2f3f1..0cd63840 100644 --- a/Octokit/Models/Response/BranchProtection.cs +++ b/Octokit/Models/Response/BranchProtection.cs @@ -82,7 +82,7 @@ namespace Octokit Off, /// - /// Required status checks will be enforeced for non-admins. + /// Required status checks will be enforced for non-admins. /// NonAdmins, From 903829ad06cb297f6fdffde2fb3ca0ffd55884eb Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:43:06 +0700 Subject: [PATCH 044/123] License fixes --- Octokit/Models/Response/License.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Models/Response/License.cs b/Octokit/Models/Response/License.cs index 673f3ab2..d5d2b53b 100644 --- a/Octokit/Models/Response/License.cs +++ b/Octokit/Models/Response/License.cs @@ -79,7 +79,7 @@ namespace Octokit public IReadOnlyList Required { get; protected set; } /// - /// Set of codes for what is permitted under the terms of the license. For example, "commerical-use" + /// Set of codes for what is permitted under the terms of the license. For example, "commercial-use" /// public IReadOnlyList Permitted { get; protected set; } From a9439285430e80846e8e8f03c81dc121f42ef160 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:43:16 +0700 Subject: [PATCH 045/123] Readme fixes --- Octokit/Models/Response/Readme.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Models/Response/Readme.cs b/Octokit/Models/Response/Readme.cs index b5ce2100..9a6784bd 100644 --- a/Octokit/Models/Response/Readme.cs +++ b/Octokit/Models/Response/Readme.cs @@ -45,7 +45,7 @@ namespace Octokit public Uri Url { get; private set; } [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", - Justification = "Makse a network request")] + Justification = "Makes a network request")] public Task GetHtmlContent() { return htmlContent.Value; From b9b88a4e64e12f2dc88f605cd8015ca9d25b0bc3 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:43:27 +0700 Subject: [PATCH 046/123] TagObject fixes --- Octokit/Models/Response/TagObject.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Models/Response/TagObject.cs b/Octokit/Models/Response/TagObject.cs index 5260023a..a157d17b 100644 --- a/Octokit/Models/Response/TagObject.cs +++ b/Octokit/Models/Response/TagObject.cs @@ -15,7 +15,7 @@ namespace Octokit } [SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods", - Justification = "Name defined by web api and required for deserialisation")] + Justification = "Name defined by web api and required for deserialization")] public TaggedType Type { get; protected set; } } From b078c91645d1956a2809813430635c180e0a1eac Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:43:37 +0700 Subject: [PATCH 047/123] ReferencesClientTests fixes --- Octokit.Tests.Integration/Clients/ReferencesClientTests.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs b/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs index 7e0a4827..0f15e76c 100644 --- a/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/ReferencesClientTests.cs @@ -2,7 +2,6 @@ using System.Linq; using System.Threading.Tasks; using Octokit; -using Octokit.Tests.Helpers; using Octokit.Tests.Integration; using Xunit; using Octokit.Tests.Integration.Helpers; @@ -37,7 +36,7 @@ public class ReferencesClientTests : IDisposable } [IntegrationTest] - public async Task WhenReferenceDoesNotExistAnExeptionIsThrown() + public async Task WhenReferenceDoesNotExistAnExceptionIsThrown() { await Assert.ThrowsAsync( () => _fixture.Get("octokit", "octokit.net", "heads/foofooblahblah")); From 6c7e70b60f31a01734f2da6037bf6f6ba422e596 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:43:47 +0700 Subject: [PATCH 048/123] ReleasesClientTests fixes --- Octokit.Tests.Integration/Clients/ReleasesClientTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs b/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs index 34892219..a60b1d26 100644 --- a/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs @@ -319,9 +319,9 @@ public class ReleasesClientTests using (var zipstream = new MemoryStream((byte[])response.Body)) using (var archive = new ZipArchive(zipstream)) { - var enttry = archive.Entries[0]; - var data = new byte[enttry.Length]; - await enttry.Open().ReadAsync(data, 0, data.Length); + var entry = archive.Entries[0]; + var data = new byte[entry.Length]; + await entry.Open().ReadAsync(data, 0, data.Length); textContent = Encoding.ASCII.GetString(data); } From 02b5f37bbfb57a71ce209da59bd56eb59dd76c49 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:43:59 +0700 Subject: [PATCH 049/123] RepositoryForksClientTests fixes --- .../Clients/RepositoryForksClientTests.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs index 84c849f8..bf2770a0 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs @@ -1,5 +1,4 @@ -using System; -using System.Linq; +using System.Linq; using System.Threading.Tasks; using Xunit; @@ -41,7 +40,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task ForkCreatedForUserLoggedIn() { - // The fork is created asynchronially by github and therefore it cannot + // The fork is created asynchronically by github and therefore it cannot // be certain that the repo exists when the test ends. It is therefore deleted // before the test starts instead of after. Helper.DeleteRepo(Helper.Credentials.Login, "octokit.net"); @@ -58,7 +57,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task ForkCreatedForOrganization() { - // The fork is created asynchronially by github and therefore it cannot + // The fork is created asynchronically by github and therefore it cannot // be certain that the repo exists when the test ends. It is therefore deleted // before the test starts. Helper.DeleteRepo(Helper.Organization, "octokit.net"); From 31c2fb153b81932c76041b62f17ff2e7dfad6ab9 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:44:18 +0700 Subject: [PATCH 050/123] AuthorizationsClientTests fixes --- Octokit.Tests/Clients/AuthorizationsClientTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.Tests/Clients/AuthorizationsClientTests.cs b/Octokit.Tests/Clients/AuthorizationsClientTests.cs index 0724d76b..882d5cd9 100644 --- a/Octokit.Tests/Clients/AuthorizationsClientTests.cs +++ b/Octokit.Tests/Clients/AuthorizationsClientTests.cs @@ -335,7 +335,7 @@ namespace Octokit.Tests.Clients public class TheRevokeApplicationAuthenticationMethod { [Fact] - public async Task RevokesApplicatonAuthenticationAtCorrectUrl() + public async Task RevokesApplicationAuthenticationAtCorrectUrl() { var client = Substitute.For(); var authEndpoint = new AuthorizationsClient(client); From 942d645c2e3180ad1edb612ac6be3aad4854fdfa Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:44:30 +0700 Subject: [PATCH 051/123] MiscellaneousClientTests fixes --- Octokit.Tests/Clients/MiscellaneousClientTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.Tests/Clients/MiscellaneousClientTests.cs b/Octokit.Tests/Clients/MiscellaneousClientTests.cs index 7b9a0f2b..6de66a5a 100644 --- a/Octokit.Tests/Clients/MiscellaneousClientTests.cs +++ b/Octokit.Tests/Clients/MiscellaneousClientTests.cs @@ -82,7 +82,7 @@ namespace Octokit.Tests.Clients public class TheGetResourceRateLimitsMethod { [Fact] - public async Task RequestsTheRecourceRateLimitEndpoint() + public async Task RequestsTheResourceRateLimitEndpoint() { IApiResponse response = new ApiResponse ( From 16c80d0893d43a8d30464bc0ccd0938f07572456 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:44:38 +0700 Subject: [PATCH 052/123] RepositoriesClientTests fixes --- Octokit.Tests/Clients/RepositoriesClientTests.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index f0f77b7d..329ca607 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Net; using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -119,7 +118,7 @@ namespace Octokit.Tests.Clients } [Fact] - public async Task UsesTheOrganizatinosReposUrl() + public async Task UsesTheOrganizationsReposUrl() { var connection = Substitute.For(); var client = new RepositoriesClient(connection); From ad44d4d099e0295ad8ad33d2b30883a51ae313b3 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:44:56 +0700 Subject: [PATCH 053/123] SearchClientTests fixes --- Octokit.Tests/Clients/SearchClientTests.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Octokit.Tests/Clients/SearchClientTests.cs b/Octokit.Tests/Clients/SearchClientTests.cs index 16d27cf5..b26c4191 100644 --- a/Octokit.Tests/Clients/SearchClientTests.cs +++ b/Octokit.Tests/Clients/SearchClientTests.cs @@ -377,7 +377,7 @@ namespace Octokit.Tests.Clients { var connection = Substitute.For(); var client = new SearchClient(connection); - //get repos whos stargazers are greater than 500 + //get repos who's stargazers are greater than 500 var request = new SearchRepositoriesRequest("github"); request.Stars = Range.GreaterThan(500); client.SearchRepo(request); @@ -391,7 +391,7 @@ namespace Octokit.Tests.Clients { var connection = Substitute.For(); var client = new SearchClient(connection); - //get repos whos stargazers are less than 500 + //get repos who's stargazers are less than 500 var request = new SearchRepositoriesRequest("github"); request.Stars = Range.LessThan(500); client.SearchRepo(request); @@ -405,7 +405,7 @@ namespace Octokit.Tests.Clients { var connection = Substitute.For(); var client = new SearchClient(connection); - //get repos whos stargazers are less than 500 or equal to + //get repos who's stargazers are less than 500 or equal to var request = new SearchRepositoriesRequest("github"); request.Stars = Range.LessThanOrEquals(500); client.SearchRepo(request); @@ -445,7 +445,7 @@ namespace Octokit.Tests.Clients { var connection = Substitute.For(); var client = new SearchClient(connection); - //get repos whos language is Ruby + //get repos who's language is Ruby var request = new SearchRepositoriesRequest("github"); request.Language = Language.Ruby; client.SearchRepo(request); From 4e2691de8a0b024d33c890710fda0533399a9417 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:46:08 +0700 Subject: [PATCH 054/123] TeamsClientTests fixes --- Octokit.Tests/Clients/TeamsClientTests.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs index dfa09458..c7722ac4 100644 --- a/Octokit.Tests/Clients/TeamsClientTests.cs +++ b/Octokit.Tests/Clients/TeamsClientTests.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -25,7 +24,7 @@ namespace Octokit.Tests.Clients public class TheGetMethod { [Fact] - public void RequestsTheCorrectlUrl() + public void RequestsTheCorrectUrl() { var connection = Substitute.For(); var client = new TeamsClient(connection); From b93f0ece0b94651554ad69ef60729f61d99090a3 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Tue, 29 Mar 2016 17:46:19 +0700 Subject: [PATCH 055/123] ObservableRepositoryDeployKeysClientTests fixes --- Octokit.Tests.Integration/Octokit.Tests.Integration.csproj | 2 +- ...tTests.cs => ObservableRepositoryDeployKeysClientTests.cs} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename Octokit.Tests.Integration/Reactive/{ObservableRespositoryDeployKeysClientTests.cs => ObservableRepositoryDeployKeysClientTests.cs} (96%) diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 4181ab35..e889bf82 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -148,7 +148,7 @@ - + diff --git a/Octokit.Tests.Integration/Reactive/ObservableRespositoryDeployKeysClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryDeployKeysClientTests.cs similarity index 96% rename from Octokit.Tests.Integration/Reactive/ObservableRespositoryDeployKeysClientTests.cs rename to Octokit.Tests.Integration/Reactive/ObservableRepositoryDeployKeysClientTests.cs index 19fe4a83..3df43c17 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableRespositoryDeployKeysClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryDeployKeysClientTests.cs @@ -6,7 +6,7 @@ using Octokit.Reactive; using Octokit.Tests.Integration; using Xunit; -public class ObservableRespositoryDeployKeysClientTests : IDisposable +public class ObservableRepositoryDeployKeysClientTests : IDisposable { const string _key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDB8IE5+RppLpeW+6lqo0fpfvMunKg6W4bhYCfVJIOYbpKoHP95nTUMZPBT++9NLeB4/YsuNTCrrpnpjc4f2IVpGvloRiVXjAzoJk9QIL6uzn1zRFdvaxSJ3Urhe9LcLHcIgccgZgSdWGzaZI3xtMvGC4diwWNsPjvVc/RyDM/MPqAim0X5XVOQwEFsSsUSraezJ+VgYMYzLYBcKWW0B86HVVhL4ZtmcY/RN2544bljnzw2M3aQvXNPTvkuiUoqLOI+5/qzZ8PfkruO55YtweEd0lkY6oZvrBPMD6dLODEqMHb4tD6htx60wSipNqjPwpOMpzp0Bk3G909unVXi6Fw5"; const string _keyTitle = "octokit@github"; @@ -14,7 +14,7 @@ public class ObservableRespositoryDeployKeysClientTests : IDisposable Repository _repository; string _owner; - public ObservableRespositoryDeployKeysClientTests() + public ObservableRepositoryDeployKeysClientTests() { var github = Helper.GetAuthenticatedClient(); From 8ff574ab1ce04c59d698f15a2ffba8d80df50265 Mon Sep 17 00:00:00 2001 From: Prayank Mathur Date: Tue, 29 Mar 2016 16:19:47 +0530 Subject: [PATCH 056/123] Changes in Accept headers as well as names of the functions --- .../Clients/IObservableIssuesClient.cs | 4 +-- .../Clients/ObservableIssuesClient.cs | 8 +++--- .../Clients/IssuesClientTests.cs | 25 +++++++++---------- .../Reactive/ObservableIssuesClientTests.cs | 10 ++++---- Octokit/Clients/IIssuesClient.cs | 4 +-- Octokit/Clients/IssuesClient.cs | 8 +++--- Octokit/Helpers/AcceptHeaders.cs | 2 ++ 7 files changed, 31 insertions(+), 30 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableIssuesClient.cs b/Octokit.Reactive/Clients/IObservableIssuesClient.cs index cae13e02..86bbe89d 100644 --- a/Octokit.Reactive/Clients/IObservableIssuesClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssuesClient.cs @@ -166,7 +166,7 @@ namespace Octokit.Reactive /// The name of the repository /// The issue number /// - IObservable LockIssue(string owner, string name, int number); + IObservable Lock(string owner, string name, int number); /// /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. @@ -176,6 +176,6 @@ namespace Octokit.Reactive /// The name of the repository /// The issue number /// - IObservable UnlockIssue(string owner, string name, int number); + IObservable Unlock(string owner, string name, int number); } } \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservableIssuesClient.cs b/Octokit.Reactive/Clients/ObservableIssuesClient.cs index 47d2b9f0..f00095d3 100644 --- a/Octokit.Reactive/Clients/ObservableIssuesClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssuesClient.cs @@ -232,12 +232,12 @@ namespace Octokit.Reactive /// The name of the repository /// The issue number /// - public IObservable LockIssue(string owner, string name, int number) + public IObservable Lock(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return _client.LockIssue(owner, name, number).ToObservable(); + return _client.Lock(owner, name, number).ToObservable(); } /// @@ -248,12 +248,12 @@ namespace Octokit.Reactive /// The name of the repository /// The issue number /// - public IObservable UnlockIssue(string owner, string name, int number) + public IObservable Unlock(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return _client.UnlockIssue(owner, name, number).ToObservable(); + return _client.Unlock(owner, name, number).ToObservable(); } } } diff --git a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs index fec271d0..809da6bf 100644 --- a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs @@ -64,21 +64,20 @@ public class IssuesClientTests : IDisposable [IntegrationTest] public async Task CanLockAndUnlockIssue() { - var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; - var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); - var retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; + var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); + var retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + Assert.False(issue.Locked); - Assert.Equal(false, issue.Locked); + await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + Assert.NotNull(retrieved); + Assert.True(issue.Locked); - await _issuesClient.LockIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - Assert.NotNull(retrieved); - Assert.Equal(true, issue.Locked); - - await _issuesClient.UnlockIssue(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - Assert.NotNull(retrieved); - Assert.Equal(false, issue.Locked); + await _issuesClient.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + Assert.NotNull(retrieved); + Assert.False(issue.Locked); } [IntegrationTest] diff --git a/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs index 1b40a7ac..9c6acf98 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs @@ -78,15 +78,15 @@ public class ObservableIssuesClientTests : IDisposable var newIssue = new NewIssue("Integration Test Issue"); var createResult = await _client.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); - Assert.Equal(false, createResult.Locked); + Assert.False(createResult.Locked); - await _client.LockIssue(_context.RepositoryOwner, _context.RepositoryName, createResult.Number); + await _client.Lock(_context.RepositoryOwner, _context.RepositoryName, createResult.Number); var lockResult = await _client.Get(_context.RepositoryOwner, _context.RepositoryName, createResult.Number); - Assert.Equal(true, lockResult.Locked); + Assert.True(lockResult.Locked); - await _client.UnlockIssue(_context.RepositoryOwner, _context.RepositoryName, createResult.Number); + await _client.Unlock(_context.RepositoryOwner, _context.RepositoryName, createResult.Number); var unlockIssueResult = await _client.Get(_context.RepositoryOwner, _context.RepositoryName, createResult.Number); - Assert.Equal(false, unlockIssueResult.Locked); + Assert.False(unlockIssueResult.Locked); } public void Dispose() diff --git a/Octokit/Clients/IIssuesClient.cs b/Octokit/Clients/IIssuesClient.cs index f6f61dea..ed42329e 100644 --- a/Octokit/Clients/IIssuesClient.cs +++ b/Octokit/Clients/IIssuesClient.cs @@ -172,7 +172,7 @@ namespace Octokit /// The name of the repository /// The issue number /// - Task LockIssue(string owner, string name, int number); + Task Lock(string owner, string name, int number); /// /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. @@ -182,6 +182,6 @@ namespace Octokit /// The name of the repository /// The issue number /// - Task UnlockIssue(string owner, string name, int number); + Task Unlock(string owner, string name, int number); } } diff --git a/Octokit/Clients/IssuesClient.cs b/Octokit/Clients/IssuesClient.cs index be4a9641..cb4af642 100644 --- a/Octokit/Clients/IssuesClient.cs +++ b/Octokit/Clients/IssuesClient.cs @@ -234,12 +234,12 @@ namespace Octokit /// The name of the repository /// The issue number /// - public Task LockIssue(string owner, string name, int number) + public Task Lock(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return ApiConnection.Put(ApiUrls.IssueLock(owner, name, number)); + return ApiConnection.Put(ApiUrls.IssueLock(owner, name, number), AcceptHeaders.IssueLockingUnlockingApiPreview); } /// @@ -250,12 +250,12 @@ namespace Octokit /// The name of the repository /// The issue number /// - public Task UnlockIssue(string owner, string name, int number) + public Task Unlock(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return ApiConnection.Delete(ApiUrls.IssueLock(owner, name, number)); + return ApiConnection.Delete(ApiUrls.IssueLock(owner, name, number), AcceptHeaders.IssueLockingUnlockingApiPreview); } } } diff --git a/Octokit/Helpers/AcceptHeaders.cs b/Octokit/Helpers/AcceptHeaders.cs index d94e7e15..80310a36 100644 --- a/Octokit/Helpers/AcceptHeaders.cs +++ b/Octokit/Helpers/AcceptHeaders.cs @@ -13,5 +13,7 @@ public const string ProtectedBranchesApiPreview = "application/vnd.github.loki-preview+json"; public const string StarCreationTimestamps = "application/vnd.github.v3.star+json"; + + public const string IssueLockingUnlockingApiPreview = "application/vnd.github.the-key-preview+json"; } } From 55f4e72c2d423f8767e672a382ff9b35f60260ed Mon Sep 17 00:00:00 2001 From: Prayank Mathur Date: Tue, 29 Mar 2016 16:59:55 +0530 Subject: [PATCH 057/123] Changed function names in unit tests --- Octokit.Tests/Clients/IssuesClientTests.cs | 20 ++++++++-------- .../Reactive/ObservableIssuesClientTests.cs | 24 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Octokit.Tests/Clients/IssuesClientTests.cs b/Octokit.Tests/Clients/IssuesClientTests.cs index f4086d68..2922dba8 100644 --- a/Octokit.Tests/Clients/IssuesClientTests.cs +++ b/Octokit.Tests/Clients/IssuesClientTests.cs @@ -193,7 +193,7 @@ namespace Octokit.Tests.Clients var connection = Substitute.For(); var client = new IssuesClient(connection); - client.LockIssue("fake", "repo", 42); + client.Lock("fake", "repo", 42); connection.Received().Put(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/lock")); } @@ -204,10 +204,10 @@ namespace Octokit.Tests.Clients var connection = Substitute.For(); var client = new IssuesClient(connection); - await Assert.ThrowsAsync(() => client.LockIssue(null, "name", 1)); - await Assert.ThrowsAsync(() => client.LockIssue("", "name", 1)); - await Assert.ThrowsAsync(() => client.LockIssue("owner", null, 1)); - await Assert.ThrowsAsync(() => client.LockIssue("owner", "", 1)); + await Assert.ThrowsAsync(() => client.Lock(null, "name", 1)); + await Assert.ThrowsAsync(() => client.Lock("", "name", 1)); + await Assert.ThrowsAsync(() => client.Lock("owner", null, 1)); + await Assert.ThrowsAsync(() => client.Lock("owner", "", 1)); } } @@ -219,7 +219,7 @@ namespace Octokit.Tests.Clients var connection = Substitute.For(); var client = new IssuesClient(connection); - client.UnlockIssue("fake", "repo", 42); + client.Unlock("fake", "repo", 42); connection.Received().Delete(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/lock")); } @@ -230,10 +230,10 @@ namespace Octokit.Tests.Clients var connection = Substitute.For(); var client = new IssuesClient(connection); - await Assert.ThrowsAsync(() => client.UnlockIssue(null, "name", 1)); - await Assert.ThrowsAsync(() => client.UnlockIssue("", "name", 1)); - await Assert.ThrowsAsync(() => client.UnlockIssue("owner", null, 1)); - await Assert.ThrowsAsync(() => client.UnlockIssue("owner", "", 1)); + await Assert.ThrowsAsync(() => client.Unlock(null, "name", 1)); + await Assert.ThrowsAsync(() => client.Unlock("", "name", 1)); + await Assert.ThrowsAsync(() => client.Unlock("owner", null, 1)); + await Assert.ThrowsAsync(() => client.Unlock("owner", "", 1)); } } diff --git a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs index 61afa771..9c16f846 100644 --- a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs @@ -345,8 +345,8 @@ public class ObservableIssuesClientTests var gitHubClient = Substitute.For(); var client = new ObservableIssuesClient(gitHubClient); - client.LockIssue("fake", "repo", 42); - gitHubClient.Issue.Received().LockIssue("fake", "repo", 42); + client.Lock("fake", "repo", 42); + gitHubClient.Issue.Received().Lock("fake", "repo", 42); } [Fact] @@ -355,10 +355,10 @@ public class ObservableIssuesClientTests var gitHubClient = Substitute.For(); var client = new ObservableIssuesClient(gitHubClient); - Assert.Throws(() => client.LockIssue(null, "name", 42)); - Assert.Throws(() => client.LockIssue("", "name", 42)); - Assert.Throws(() => client.LockIssue("owner", null, 42)); - Assert.Throws(() => client.LockIssue("owner", "", 42)); + Assert.Throws(() => client.Lock(null, "name", 42)); + Assert.Throws(() => client.Lock("", "name", 42)); + Assert.Throws(() => client.Lock("owner", null, 42)); + Assert.Throws(() => client.Lock("owner", "", 42)); } } @@ -370,8 +370,8 @@ public class ObservableIssuesClientTests var gitHubClient = Substitute.For(); var client = new ObservableIssuesClient(gitHubClient); - client.UnlockIssue("fake", "repo", 42); - gitHubClient.Issue.Received().UnlockIssue("fake", "repo", 42); + client.Unlock("fake", "repo", 42); + gitHubClient.Issue.Received().Unlock("fake", "repo", 42); } [Fact] @@ -380,10 +380,10 @@ public class ObservableIssuesClientTests var gitHubClient = Substitute.For(); var client = new ObservableIssuesClient(gitHubClient); - Assert.Throws(() => client.UnlockIssue(null, "name", 42)); - Assert.Throws(() => client.UnlockIssue("", "name", 42)); - Assert.Throws(() => client.UnlockIssue("owner", null, 42)); - Assert.Throws(() => client.UnlockIssue("owner", "", 42)); + Assert.Throws(() => client.Unlock(null, "name", 42)); + Assert.Throws(() => client.Unlock("", "name", 42)); + Assert.Throws(() => client.Unlock("owner", null, 42)); + Assert.Throws(() => client.Unlock("owner", "", 42)); } } From 5173adeffbe5e54d52aa1af5452093a1b7ee23c7 Mon Sep 17 00:00:00 2001 From: Prayank Mathur Date: Tue, 29 Mar 2016 17:13:44 +0530 Subject: [PATCH 058/123] Some more changes in tests --- Octokit.Tests/Clients/IssuesClientTests.cs | 8 ++++---- Octokit.Tests/Reactive/ObservableIssuesClientTests.cs | 8 ++++---- Octokit/Helpers/AcceptHeaders.cs | 1 - 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Octokit.Tests/Clients/IssuesClientTests.cs b/Octokit.Tests/Clients/IssuesClientTests.cs index 2922dba8..ade94e09 100644 --- a/Octokit.Tests/Clients/IssuesClientTests.cs +++ b/Octokit.Tests/Clients/IssuesClientTests.cs @@ -185,7 +185,7 @@ namespace Octokit.Tests.Clients } } - public class TheLockIssueMethod + public class TheLockMethod { [Fact] public void PostsToCorrectUrl() @@ -195,7 +195,7 @@ namespace Octokit.Tests.Clients client.Lock("fake", "repo", 42); - connection.Received().Put(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/lock")); + connection.Received().Put(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/lock"), Arg.Is(u => u.ToString() == "application/vnd.github.the-key-preview+json")); } [Fact] @@ -211,7 +211,7 @@ namespace Octokit.Tests.Clients } } - public class TheUnlockIssueMethod + public class TheUnlockMethod { [Fact] public void PostsToCorrectUrl() @@ -221,7 +221,7 @@ namespace Octokit.Tests.Clients client.Unlock("fake", "repo", 42); - connection.Received().Delete(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/lock")); + connection.Received().Delete(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/lock"), Arg.Is(u => u.ToString() == "application/vnd.github.the-key-preview+json")); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs index 9c16f846..c511b901 100644 --- a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs @@ -337,10 +337,10 @@ public class ObservableIssuesClientTests } } - public class TheLockIssueMethod + public class TheLockMethod { [Fact] - public void LockIssue() + public void LocksIssue() { var gitHubClient = Substitute.For(); var client = new ObservableIssuesClient(gitHubClient); @@ -362,10 +362,10 @@ public class ObservableIssuesClientTests } } - public class TheUnlockIssueMethod + public class TheUnlockMethod { [Fact] - public void UnlockIssue() + public void UnlocksIssue() { var gitHubClient = Substitute.For(); var client = new ObservableIssuesClient(gitHubClient); diff --git a/Octokit/Helpers/AcceptHeaders.cs b/Octokit/Helpers/AcceptHeaders.cs index 4108ddcf..bf3423b3 100644 --- a/Octokit/Helpers/AcceptHeaders.cs +++ b/Octokit/Helpers/AcceptHeaders.cs @@ -17,6 +17,5 @@ public const string IssueLockingUnlockingApiPreview = "application/vnd.github.the-key-preview+json"; public const string CommitReferenceSha1Preview = "application/vnd.github.chitauri-preview+sha"; - } } From d1376c8f02b8ac61d165ea4f73adc4c3a7128f6d Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Wed, 30 Mar 2016 12:04:50 +0700 Subject: [PATCH 059/123] All remarks were fixed --- .../Clients/ObservableDeploymentsClient.cs | 3 ++ .../Clients/DeploymentsClientTests.cs | 28 +++++----- .../ObservableDeploymentsClientTests.cs | 51 ++++++++++--------- Octokit/Clients/DeploymentsClient.cs | 5 +- 4 files changed, 47 insertions(+), 40 deletions(-) diff --git a/Octokit.Reactive/Clients/ObservableDeploymentsClient.cs b/Octokit.Reactive/Clients/ObservableDeploymentsClient.cs index 3d382af5..9a32ace1 100644 --- a/Octokit.Reactive/Clients/ObservableDeploymentsClient.cs +++ b/Octokit.Reactive/Clients/ObservableDeploymentsClient.cs @@ -31,6 +31,9 @@ namespace Octokit.Reactive.Clients /// All the s for the specified repository. public IObservable GetAll(string owner, string name) { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + return GetAll(owner, name, ApiOptions.None); } diff --git a/Octokit.Tests/Clients/DeploymentsClientTests.cs b/Octokit.Tests/Clients/DeploymentsClientTests.cs index ef69431c..804835cc 100644 --- a/Octokit.Tests/Clients/DeploymentsClientTests.cs +++ b/Octokit.Tests/Clients/DeploymentsClientTests.cs @@ -50,11 +50,11 @@ public class DeploymentsClientTests { var connection = Substitute.For(); var client = new DeploymentsClient(connection); - var expectedUrl = ApiUrls.Deployments(owner, name); + var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name); client.GetAll(owner, name); connection.Received(1) - .GetAll(Arg.Is(u => u == expectedUrl), Args.ApiOptions); + .GetAll(Arg.Is(u => u.ToString() == expectedUrl), Args.ApiOptions); } [Fact] @@ -62,7 +62,7 @@ public class DeploymentsClientTests { var connection = Substitute.For(); var client = new DeploymentsClient(connection); - var expectedUrl = ApiUrls.Deployments(owner, name); + var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name); var options = new ApiOptions { @@ -73,21 +73,21 @@ public class DeploymentsClientTests client.GetAll(owner, name, options); connection.Received(1) - .GetAll(Arg.Is(u => u == expectedUrl), options); + .GetAll(Arg.Is(u => u.ToString() == expectedUrl), options); } } public class TheCreateMethod { - private readonly NewDeployment _newDeployment = new NewDeployment("aRef"); + private readonly NewDeployment newDeployment = new NewDeployment("aRef"); [Fact] public async Task EnsuresNonNullArguments() { var client = new DeploymentsClient(Substitute.For()); - await Assert.ThrowsAsync(() => client.Create(null, "name", _newDeployment)); - await Assert.ThrowsAsync(() => client.Create("owner", null, _newDeployment)); + await Assert.ThrowsAsync(() => client.Create(null, "name", newDeployment)); + await Assert.ThrowsAsync(() => client.Create("owner", null, newDeployment)); await Assert.ThrowsAsync(() => client.Create("owner", "name", null)); } @@ -96,8 +96,8 @@ public class DeploymentsClientTests { var client = new DeploymentsClient(Substitute.For()); - await Assert.ThrowsAsync(() => client.Create("", "name", _newDeployment)); - await Assert.ThrowsAsync(() => client.Create("owner", "", _newDeployment)); + await Assert.ThrowsAsync(() => client.Create("", "name", newDeployment)); + await Assert.ThrowsAsync(() => client.Create("owner", "", newDeployment)); } [Theory] @@ -110,8 +110,8 @@ public class DeploymentsClientTests { var client = new DeploymentsClient(Substitute.For()); - await Assert.ThrowsAsync(() => client.Create(whitespace, "name", _newDeployment)); - await Assert.ThrowsAsync(() => client.Create("owner", whitespace, _newDeployment)); + await Assert.ThrowsAsync(() => client.Create(whitespace, "name", newDeployment)); + await Assert.ThrowsAsync(() => client.Create("owner", whitespace, newDeployment)); } [Fact] @@ -121,7 +121,7 @@ public class DeploymentsClientTests var client = new DeploymentsClient(connection); var expectedUrl = "repos/owner/name/deployments"; - client.Create("owner", "name", _newDeployment); + client.Create("owner", "name", newDeployment); connection.Received(1).Post(Arg.Is(u => u.ToString() == expectedUrl), Arg.Any()); @@ -133,10 +133,10 @@ public class DeploymentsClientTests var connection = Substitute.For(); var client = new DeploymentsClient(connection); - client.Create("owner", "name", _newDeployment); + client.Create("owner", "name", newDeployment); connection.Received(1).Post(Arg.Any(), - _newDeployment); + newDeployment); } } diff --git a/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs b/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs index e3d815b9..477d1d78 100644 --- a/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs @@ -51,21 +51,21 @@ namespace Octokit.Tests.Reactive [Fact] public void RequestsCorrectUrl() { - var expectedUri = ApiUrls.Deployments(owner, name); + var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name); _client.GetAll(owner, name); - _githubClient.Connection - .Received(1) - .Get>(Arg.Is(expectedUri), - Arg.Is>(dictionary => dictionary.Count == 0), Arg.Any()); + _githubClient.Connection.Received(1) + .Get>(Arg.Is(u => u.ToString() == expectedUrl), + Arg.Is>(dictionary => dictionary.Count == 0), + Arg.Any()); } [Fact] public void RequestsCorrectUrlWithApiOptions() { - var expectedUri = ApiUrls.Deployments(owner, name); - - // all properties are setted => only 2 options (StartPage, PageSize) in Dictionary + var expectedUrl = string.Format("repos/{0}/{1}/deployments", owner, name); + + // all properties are setted => only 2 options (StartPage, PageSize) in dictionary var options = new ApiOptions { StartPage = 1, @@ -74,34 +74,34 @@ namespace Octokit.Tests.Reactive }; _client.GetAll(owner, name, options); - _githubClient.Connection - .Received(1) - .Get>(Arg.Is(expectedUri), - Arg.Is>(dictionary => dictionary.Count == 2), null); + _githubClient.Connection.Received(1) + .Get>(Arg.Is(u => u.ToString() == expectedUrl), + Arg.Is>(dictionary => dictionary.Count == 2), + null); - // StartPage is setted => only 1 option (StartPage) in Dictionary + // StartPage is setted => only 1 option (StartPage) in dictionary options = new ApiOptions { StartPage = 1 }; _client.GetAll(owner, name, options); - _githubClient.Connection - .Received(1) - .Get>(Arg.Is(expectedUri), - Arg.Is>(dictionary => dictionary.Count == 1), null); + _githubClient.Connection.Received(1) + .Get>(Arg.Is(u => u.ToString() == expectedUrl), + Arg.Is>(dictionary => dictionary.Count == 1), + null); - // PageCount is setted => none of options in Dictionary + // PageCount is setted => none of options in dictionary options = new ApiOptions { PageCount = 1 }; _client.GetAll(owner, name, options); - _githubClient.Connection - .Received(1) - .Get>(Arg.Is(expectedUri), - Arg.Is>(dictionary => dictionary.Count == 0), null); + _githubClient.Connection.Received(1) + .Get>(Arg.Is(u => u.ToString() == expectedUrl), + Arg.Is>(dictionary => dictionary.Count == 0), + null); } } @@ -164,9 +164,10 @@ namespace Octokit.Tests.Reactive var newDeployment = new NewDeployment("ref"); _client.Create("owner", "repo", newDeployment); + _githubClient.Repository.Deployment.Received(1).Create(Arg.Is("owner"), - Arg.Is("repo"), - Arg.Is(newDeployment)); + Arg.Is("repo"), + Arg.Is(newDeployment)); } } @@ -179,4 +180,4 @@ namespace Octokit.Tests.Reactive } } } -} \ No newline at end of file +} diff --git a/Octokit/Clients/DeploymentsClient.cs b/Octokit/Clients/DeploymentsClient.cs index 4f63e510..db42b424 100644 --- a/Octokit/Clients/DeploymentsClient.cs +++ b/Octokit/Clients/DeploymentsClient.cs @@ -34,6 +34,9 @@ namespace Octokit /// All the s for the specified repository. public Task> GetAll(string owner, string name) { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + return GetAll(owner, name, ApiOptions.None); } @@ -50,7 +53,7 @@ namespace Octokit /// All the s for the specified repository. public Task> GetAll(string owner, string name, ApiOptions options) { - Ensure.ArgumentNotNullOrEmptyString(owner, "login"); + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(options, "options"); From 8e49f04a5d3312f193dd0de70701324e0dd8c0d0 Mon Sep 17 00:00:00 2001 From: Prayank Mathur Date: Wed, 30 Mar 2016 14:30:37 +0530 Subject: [PATCH 060/123] Added implementation for delete that takes custom media type header and changed definition for Unlock accordingly --- .../Clients/IssuesClientTests.cs | 7 +++---- Octokit/Clients/IIssuesClient.cs | 2 +- Octokit/Clients/IssuesClient.cs | 6 +++--- Octokit/Http/ApiConnection.cs | 15 +++++++++++++++ Octokit/Http/Connection.cs | 16 ++++++++++++++++ Octokit/Http/IApiConnection.cs | 9 +++++++++ Octokit/Http/IConnection.cs | 9 +++++++++ 7 files changed, 56 insertions(+), 8 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs index 118cc73c..c9619a4b 100644 --- a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs @@ -65,18 +65,17 @@ public class IssuesClientTests : IDisposable { var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); - var retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); Assert.False(issue.Locked); await _issuesClient.Lock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); + var retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); Assert.NotNull(retrieved); - Assert.True(issue.Locked); + Assert.True(retrieved.Locked); await _issuesClient.Unlock(_context.RepositoryOwner, _context.RepositoryName, issue.Number); retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); Assert.NotNull(retrieved); - Assert.False(issue.Locked); + Assert.False(retrieved.Locked); } [IntegrationTest] diff --git a/Octokit/Clients/IIssuesClient.cs b/Octokit/Clients/IIssuesClient.cs index ed42329e..bea894bf 100644 --- a/Octokit/Clients/IIssuesClient.cs +++ b/Octokit/Clients/IIssuesClient.cs @@ -172,7 +172,7 @@ namespace Octokit /// The name of the repository /// The issue number /// - Task Lock(string owner, string name, int number); + Task Lock(string owner, string name, int number); /// /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. diff --git a/Octokit/Clients/IssuesClient.cs b/Octokit/Clients/IssuesClient.cs index cb4af642..4757c014 100644 --- a/Octokit/Clients/IssuesClient.cs +++ b/Octokit/Clients/IssuesClient.cs @@ -234,12 +234,12 @@ namespace Octokit /// The name of the repository /// The issue number /// - public Task Lock(string owner, string name, int number) + public Task Lock(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return ApiConnection.Put(ApiUrls.IssueLock(owner, name, number), AcceptHeaders.IssueLockingUnlockingApiPreview); + return ApiConnection.Put(ApiUrls.IssueLock(owner, name, number), new object(), null, AcceptHeaders.IssueLockingUnlockingApiPreview); } /// @@ -255,7 +255,7 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return ApiConnection.Delete(ApiUrls.IssueLock(owner, name, number), AcceptHeaders.IssueLockingUnlockingApiPreview); + return ApiConnection.Delete(ApiUrls.IssueLock(owner, name, number), new object(), AcceptHeaders.IssueLockingUnlockingApiPreview); } } } diff --git a/Octokit/Http/ApiConnection.cs b/Octokit/Http/ApiConnection.cs index 0cf57496..a08a8aeb 100644 --- a/Octokit/Http/ApiConnection.cs +++ b/Octokit/Http/ApiConnection.cs @@ -467,6 +467,21 @@ namespace Octokit return Connection.Delete(uri, data); } + /// + /// Performs an asynchronous HTTP DELETE request that expects an empty response. + /// + /// URI endpoint to send request to + /// The object to serialize as the body of the request + /// Specifies accept response media type + /// The returned + public Task Delete(Uri uri, object data, string accepts) + { + Ensure.ArgumentNotNull(uri, "uri"); + Ensure.ArgumentNotNull(data, "data"); + Ensure.ArgumentNotNull(accepts, "accepts"); + + return Connection.Delete(uri, data, accepts); + } /// /// Executes a GET to the API object at the specified URI. This operation is appropriate for /// API calls which wants to return the redirect URL. diff --git a/Octokit/Http/Connection.cs b/Octokit/Http/Connection.cs index 81a1f86b..dc5bccf2 100644 --- a/Octokit/Http/Connection.cs +++ b/Octokit/Http/Connection.cs @@ -484,6 +484,22 @@ namespace Octokit return response.HttpResponse.StatusCode; } + /// + /// Performs an asynchronous HTTP DELETE request that expects an empty response. + /// + /// URI endpoint to send request to + /// The object to serialize as the body of the request + /// Specifies accept response media type + /// The returned + public async Task Delete(Uri uri,object data, string accepts) + { + Ensure.ArgumentNotNull(uri, "uri"); + Ensure.ArgumentNotNull(accepts, "accepts"); + + var response = await SendData(uri, HttpMethod.Delete, data, accepts, null, CancellationToken.None); + return response.HttpResponse.StatusCode; + } + /// /// Base address for the connection. /// diff --git a/Octokit/Http/IApiConnection.cs b/Octokit/Http/IApiConnection.cs index 81966a10..f3fe9f20 100644 --- a/Octokit/Http/IApiConnection.cs +++ b/Octokit/Http/IApiConnection.cs @@ -293,6 +293,15 @@ namespace Octokit /// A for the request's execution. Task Delete(Uri uri, object data); + /// + /// Performs an asynchronous HTTP DELETE request that expects an empty response. + /// + /// URI endpoint to send request to + /// The object to serialize as the body of the request + /// Specifies accept response media type + /// The returned + Task Delete(Uri uri, object data, string accepts); + /// /// Executes a GET to the API object at the specified URI. This operation is appropriate for /// API calls which wants to return the redirect URL. diff --git a/Octokit/Http/IConnection.cs b/Octokit/Http/IConnection.cs index 137f488e..74b0ab0a 100644 --- a/Octokit/Http/IConnection.cs +++ b/Octokit/Http/IConnection.cs @@ -234,6 +234,15 @@ namespace Octokit /// The returned Task Delete(Uri uri, object data); + /// + /// Performs an asynchronous HTTP DELETE request that expects an empty response. + /// + /// URI endpoint to send request to + /// The object to serialize as the body of the request + /// Specifies accept response media type + /// The returned + Task Delete(Uri uri, object data, string accepts); + /// /// Base address for the connection. /// From 73240390ca42f9148f52815673a604db6425fb22 Mon Sep 17 00:00:00 2001 From: Prayank Mathur Date: Wed, 30 Mar 2016 14:42:47 +0530 Subject: [PATCH 061/123] Minor fixes --- Octokit.Reactive/Clients/IObservableIssuesClient.cs | 2 +- Octokit.Reactive/Clients/ObservableIssuesClient.cs | 2 +- Octokit.Tests/Clients/IssuesClientTests.cs | 4 ++-- SolutionInfo.cs | 6 ++---- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableIssuesClient.cs b/Octokit.Reactive/Clients/IObservableIssuesClient.cs index 86bbe89d..d9ca53a3 100644 --- a/Octokit.Reactive/Clients/IObservableIssuesClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssuesClient.cs @@ -166,7 +166,7 @@ namespace Octokit.Reactive /// The name of the repository /// The issue number /// - IObservable Lock(string owner, string name, int number); + IObservable Lock(string owner, string name, int number); /// /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. diff --git a/Octokit.Reactive/Clients/ObservableIssuesClient.cs b/Octokit.Reactive/Clients/ObservableIssuesClient.cs index f00095d3..007b743d 100644 --- a/Octokit.Reactive/Clients/ObservableIssuesClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssuesClient.cs @@ -232,7 +232,7 @@ namespace Octokit.Reactive /// The name of the repository /// The issue number /// - public IObservable Lock(string owner, string name, int number) + public IObservable Lock(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); diff --git a/Octokit.Tests/Clients/IssuesClientTests.cs b/Octokit.Tests/Clients/IssuesClientTests.cs index ade94e09..bcb14395 100644 --- a/Octokit.Tests/Clients/IssuesClientTests.cs +++ b/Octokit.Tests/Clients/IssuesClientTests.cs @@ -195,7 +195,7 @@ namespace Octokit.Tests.Clients client.Lock("fake", "repo", 42); - connection.Received().Put(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/lock"), Arg.Is(u => u.ToString() == "application/vnd.github.the-key-preview+json")); + connection.Received().Put(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/lock"), Arg.Any(), Arg.Any(), Arg.Is(u => u.ToString() == "application/vnd.github.the-key-preview+json")); } [Fact] @@ -221,7 +221,7 @@ namespace Octokit.Tests.Clients client.Unlock("fake", "repo", 42); - connection.Received().Delete(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/lock"), Arg.Is(u => u.ToString() == "application/vnd.github.the-key-preview+json")); + connection.Received().Delete(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/lock"), Arg.Any(), Arg.Is(u => u.ToString() == "application/vnd.github.the-key-preview+json")); } [Fact] diff --git a/SolutionInfo.cs b/SolutionInfo.cs index 22509412..a52961be 100644 --- a/SolutionInfo.cs +++ b/SolutionInfo.cs @@ -6,10 +6,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyVersionAttribute("0.19.0")] [assembly: AssemblyFileVersionAttribute("0.19.0")] [assembly: ComVisibleAttribute(false)] -namespace System -{ - internal static class AssemblyVersionInformation - { +namespace System { + internal static class AssemblyVersionInformation { internal const string Version = "0.19.0"; } } From 27d6e3bfc9db27745f8ed476054d86491fdce9bf Mon Sep 17 00:00:00 2001 From: Devesh Khandelwal Date: Wed, 30 Mar 2016 20:56:33 +0530 Subject: [PATCH 062/123] Tests added. --- .../Clients/TeamsClientTests.cs | 2 +- .../Reactive/ObservableTeamsClientTests.cs | 6 +-- Octokit.Tests/Octokit.Tests.csproj | 1 + .../Reactive/ObservableTeamsClientTests.cs | 47 +++++++++++++++++++ 4 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 Octokit.Tests/Reactive/ObservableTeamsClientTests.cs diff --git a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs index 1e653c79..a80a6da0 100644 --- a/Octokit.Tests.Integration/Clients/TeamsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/TeamsClientTests.cs @@ -48,7 +48,7 @@ public class TeamsClientTests public class TheGetAllForCurrentMethod { [IntegrationTest] - public async Task GetsIsMemberWhenAuthenticated() + public async Task GetsAllForCurrentWhenAuthenticated() { var github = Helper.GetAuthenticatedClient(); var teams = await github.Organization.Team.GetAllForCurrent(); diff --git a/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs index 68b7dc9d..d6743e8c 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableTeamsClientTests.cs @@ -10,13 +10,13 @@ public class ObservableTeamsClientTests { public class TheGetMembersMethod { - readonly Team team; + readonly Team _team; public TheGetMembersMethod() { var github = Helper.GetAuthenticatedClient(); - team = github.Organization.Team.GetAll(Helper.Organization).Result.First(); + _team = github.Organization.Team.GetAll(Helper.Organization).Result.First(); } [OrganizationTest] @@ -26,7 +26,7 @@ public class ObservableTeamsClientTests var client = new ObservableTeamsClient(github); - var member = await client.GetAllMembers(team.Id, ApiOptions.None); + var member = await client.GetAllMembers(_team.Id, ApiOptions.None); Assert.Equal(Helper.UserName, member.Login); } diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 8fd268a0..4bb75c60 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -218,6 +218,7 @@ + diff --git a/Octokit.Tests/Reactive/ObservableTeamsClientTests.cs b/Octokit.Tests/Reactive/ObservableTeamsClientTests.cs new file mode 100644 index 00000000..eebd3491 --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableTeamsClientTests.cs @@ -0,0 +1,47 @@ +using System; +using System.Reactive.Threading.Tasks; +using System.Threading.Tasks; +using NSubstitute; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableTeamsClientTests + { + public class TheCreateMethod + { + [Fact] + public void PostsToCorrectUrl() + { + var team = new NewTeam("avengers"); + var github = Substitute.For(); + var client = new ObservableTeamsClient(github); + + client.Create("shield", team); + + github.Organization.Team.Received().Create("shield", team); + } + + [Fact] + public void EnsuresNotNullAndNonEmptyArguments() + { + var github = Substitute.For(); + var client = new ObservableTeamsClient(github); + + Assert.ThrowsAsync(() => client.Create("shield", null).ToTask()); + Assert.ThrowsAsync(() => client.Create(null, new NewTeam("avengers")).ToTask()); + Assert.ThrowsAsync(() => client.Create("", new NewTeam("avengers")).ToTask()); + } + } + + public class TheCtor + { + [Fact] + public void EnsuresNotNullGitHubClient() + { + Assert.Throws(() => new ObservableTeamsClient(null)); + } + } + } +} \ No newline at end of file From 3d9402bef5a887abe769e960fe579144fcdf1c5a Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Thu, 31 Mar 2016 12:53:20 +0700 Subject: [PATCH 063/123] 'Some misspellings were fixed' --- .../Clients/RepositoryForksClientTests.cs | 4 ++-- Octokit/Models/Request/SearchRepositoriesRequest.cs | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs index bf2770a0..3f7c5af7 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs @@ -40,7 +40,7 @@ namespace Octokit.Tests.Integration.Clients [IntegrationTest] public async Task ForkCreatedForUserLoggedIn() { - // The fork is created asynchronically by github and therefore it cannot + // The fork is created asynchronously by github and therefore it cannot // be certain that the repo exists when the test ends. It is therefore deleted // before the test starts instead of after. Helper.DeleteRepo(Helper.Credentials.Login, "octokit.net"); @@ -57,7 +57,7 @@ namespace Octokit.Tests.Integration.Clients [OrganizationTest] public async Task ForkCreatedForOrganization() { - // The fork is created asynchronically by github and therefore it cannot + // The fork is created asynchronously by github and therefore it cannot // be certain that the repo exists when the test ends. It is therefore deleted // before the test starts. Helper.DeleteRepo(Helper.Organization, "octokit.net"); diff --git a/Octokit/Models/Request/SearchRepositoriesRequest.cs b/Octokit/Models/Request/SearchRepositoriesRequest.cs index 8a08c357..3c2990e7 100644 --- a/Octokit/Models/Request/SearchRepositoriesRequest.cs +++ b/Octokit/Models/Request/SearchRepositoriesRequest.cs @@ -482,6 +482,10 @@ namespace Octokit [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Elixir")] [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Elixir")] Elixir, + [Obsolete("This item is incorrect and will be removed in a future update. Use Elixir instead.")] + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Elixer")] + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Elixer")] + Elixer, Elm, [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Emacs")] [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Emacs")] @@ -712,6 +716,10 @@ namespace Octokit [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Parallel")] [Parameter(Value = "Unified Parallel C")] UnifiedParallelC, + [Obsolete("This item is incorrect and will be removed in a future update. Use UnifiedParallelC instead.")] + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Paralel")] + [Parameter(Value = "Unified Paralel C")] + UnifiedParalelC, Unknown, [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Vala")] Vala, From 0d5c15fce93886bf1673368062202f683bf603e2 Mon Sep 17 00:00:00 2001 From: Abdelkhalek Oussama Elhamer Date: Thu, 31 Mar 2016 13:34:07 +0100 Subject: [PATCH 064/123] Use a proper reference to test the GetAll CommitStatus +Other small fixes --- .../ObservableCommitStatusClientTests.cs | 17 +++++++---------- .../Clients/CommitStatusClientTests.cs | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Octokit.Tests.Integration/Reactive/ObservableCommitStatusClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableCommitStatusClientTests.cs index c2fd4706..0ba02e5b 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableCommitStatusClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableCommitStatusClientTests.cs @@ -12,7 +12,7 @@ namespace Octokit.Tests.Integration.Reactive readonly ObservableCommitStatusClient _commitStatusClient; const string owner = "octokit"; const string name = "octokit.net"; - const string reference = "master"; + const string reference = "1335f37"; public TheGetAllMethod() { @@ -33,7 +33,7 @@ namespace Octokit.Tests.Integration.Reactive { var options = new ApiOptions { - PageSize = 5, + PageSize = 2, PageCount = 1 }; @@ -47,14 +47,14 @@ namespace Octokit.Tests.Integration.Reactive { var options = new ApiOptions { - PageSize = 5, + PageSize = 2, PageCount = 1, StartPage = 1 }; var commitStatus = await _commitStatusClient.GetAll(owner, name, reference, options).ToList(); - Assert.Equal(5, commitStatus.Count); + Assert.Equal(2, commitStatus.Count); } [IntegrationTest] @@ -62,7 +62,7 @@ namespace Octokit.Tests.Integration.Reactive { var startOptions = new ApiOptions { - PageSize = 5, + PageSize = 2, PageCount = 1 }; @@ -70,7 +70,7 @@ namespace Octokit.Tests.Integration.Reactive var skipStartOptions = new ApiOptions { - PageSize = 5, + PageSize = 2, PageCount = 1, StartPage = 2 }; @@ -78,10 +78,7 @@ namespace Octokit.Tests.Integration.Reactive var secondPage = await _commitStatusClient.GetAll(owner, name, reference,skipStartOptions).ToList(); Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); - Assert.NotEqual(firstPage[1].Id, secondPage[1].Id); - Assert.NotEqual(firstPage[2].Id, secondPage[2].Id); - Assert.NotEqual(firstPage[3].Id, secondPage[3].Id); - Assert.NotEqual(firstPage[4].Id, secondPage[4].Id); + Assert.NotEqual(firstPage[1].Id, secondPage[1].Id); } } } diff --git a/Octokit.Tests/Clients/CommitStatusClientTests.cs b/Octokit.Tests/Clients/CommitStatusClientTests.cs index 631eacc1..6dd5689f 100644 --- a/Octokit.Tests/Clients/CommitStatusClientTests.cs +++ b/Octokit.Tests/Clients/CommitStatusClientTests.cs @@ -38,7 +38,7 @@ namespace Octokit.Tests.Clients client.GetAll("fake", "repo", "sha", options); connection.Received() - .GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/commits/sha/statuses"),options); + .GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/commits/sha/statuses"), Args.ApiOptions); } From 8a559cca6fe3e827b6606dc83a58e8233c2108ea Mon Sep 17 00:00:00 2001 From: Abdelkhalek Oussama Elhamer Date: Thu, 31 Mar 2016 20:54:00 +0100 Subject: [PATCH 065/123] Fix the ReturnsCorrectCountOfCommitStatusWithoutStart Test --- .../Reactive/ObservableCommitStatusClientTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.Tests.Integration/Reactive/ObservableCommitStatusClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableCommitStatusClientTests.cs index 0ba02e5b..f903f896 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableCommitStatusClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableCommitStatusClientTests.cs @@ -39,7 +39,7 @@ namespace Octokit.Tests.Integration.Reactive var commitStatus = await _commitStatusClient.GetAll(owner, name ,reference , options).ToList(); - Assert.Equal(5, commitStatus.Count); + Assert.Equal(2, commitStatus.Count); } [IntegrationTest] From a1aa51a6bf05a7916c60a4a0086bc7c83e8e242d Mon Sep 17 00:00:00 2001 From: Devesh Khandelwal Date: Sat, 2 Apr 2016 01:01:00 +0530 Subject: [PATCH 066/123] Add Ensures in ObservableTeamsClient. --- .../Clients/ObservableTeamsClient.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Octokit.Reactive/Clients/ObservableTeamsClient.cs b/Octokit.Reactive/Clients/ObservableTeamsClient.cs index cf21e0c9..1711f78c 100644 --- a/Octokit.Reactive/Clients/ObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/ObservableTeamsClient.cs @@ -47,6 +47,8 @@ namespace Octokit.Reactive /// A list of the orgs's teams s. public IObservable GetAll(string org) { + Ensure.ArgumentNotNullOrEmptyString(org, "org"); + return GetAll(org, ApiOptions.None); } @@ -126,6 +128,9 @@ namespace Octokit.Reactive /// Newly created public IObservable Create(string org, NewTeam team) { + Ensure.ArgumentNotNullOrEmptyString(org, "org"); + Ensure.ArgumentNotNull(team, "team"); + return _client.Create(org, team).ToObservable(); } @@ -136,6 +141,8 @@ namespace Octokit.Reactive /// Updated public IObservable Update(int id, UpdateTeam team) { + Ensure.ArgumentNotNull(team, "team"); + return _client.Update(id, team).ToObservable(); } @@ -161,6 +168,8 @@ namespace Octokit.Reactive /// A result indicating the membership status public IObservable AddMembership(int id, string login) { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + return _client.AddMembership(id, login).ToObservable(); } @@ -175,6 +184,8 @@ namespace Octokit.Reactive /// if the user was removed from the team; otherwise. public IObservable RemoveMembership(int id, string login) { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + return _client.RemoveMembership(id, login).ToObservable(); } @@ -188,6 +199,8 @@ namespace Octokit.Reactive [Obsolete("Use GetMembership(id, login) to detect pending memberships")] public IObservable IsMember(int id, string login) { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + return _client.IsMember(id, login).ToObservable(); } @@ -200,6 +213,8 @@ namespace Octokit.Reactive /// A result indicating the membership status public IObservable GetMembership(int id, string login) { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + return _client.GetMembership(id, login).ToObservable(); } @@ -240,6 +255,9 @@ namespace Octokit.Reactive /// if the repository was added to the team; otherwise. public IObservable AddRepository(int id, string organization, string repoName) { + Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); + Ensure.ArgumentNotNullOrEmptyString(repoName, "repoName"); + return _client.AddRepository(id, organization, repoName).ToObservable(); } @@ -251,6 +269,9 @@ namespace Octokit.Reactive /// public IObservable RemoveRepository(int id, string organization, string repoName) { + Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); + Ensure.ArgumentNotNullOrEmptyString(repoName, "repoName"); + return _client.RemoveRepository(id, organization, repoName).ToObservable(); } @@ -266,6 +287,8 @@ namespace Octokit.Reactive /// if the repository is managed by the given team; otherwise. public IObservable IsRepositoryManagedByTeam(int id, string owner, string repo) { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repo, "repo"); return _client.IsRepositoryManagedByTeam(id, owner, repo).ToObservable(); } } From a489092f62fe31b0b6033f11296ed7316382477c Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sun, 3 Apr 2016 21:56:30 +1000 Subject: [PATCH 067/123] Add Importer property to Meta response model Implement unit test for GetMetadata() call Flesh out integration test to check all returned Meta fields -> Found and fixed a bug where the existing `GitHubServicesSHA` field was not deserialised properly --- .../Clients/MiscellaneousClientTests.cs | 5 +++ .../Clients/MiscellaneousClientTests.cs | 36 +++++++++++++++++++ Octokit/Models/Response/Meta.cs | 11 +++++- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs b/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs index b13fd3a9..a6ec1944 100644 --- a/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs +++ b/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs @@ -113,6 +113,11 @@ public class MiscellaneousClientTests var result = await github.Miscellaneous.GetMetadata(); Assert.True(result.VerifiablePasswordAuthentication); + Assert.NotEmpty(result.GitHubServicesSha); + Assert.True(result.Hooks.Count > 0); + Assert.True(result.Git.Count > 0); + Assert.True(result.Pages.Count > 0); + Assert.True(result.Importer.Count > 0); } } } \ No newline at end of file diff --git a/Octokit.Tests/Clients/MiscellaneousClientTests.cs b/Octokit.Tests/Clients/MiscellaneousClientTests.cs index 7b9a0f2b..088b33ad 100644 --- a/Octokit.Tests/Clients/MiscellaneousClientTests.cs +++ b/Octokit.Tests/Clients/MiscellaneousClientTests.cs @@ -136,6 +136,42 @@ namespace Octokit.Tests.Clients } } + public class TheGetMetadataMethod + { + [Fact] + public async Task RequestsTheMetadataEndpoint() + { + IApiResponse response = new ApiResponse + ( + new Response(), + new Meta( + false, + "12345ABCDE", + new[] { "1.1.1.1/24", "1.1.1.2/24" }, + new[] { "1.1.2.1/24", "1.1.2.2/24" }, + new[] { "1.1.3.1/24", "1.1.3.2/24" }, + new[] { "1.1.4.1", "1.1.4.2" } + ) + ); + var connection = Substitute.For(); + connection.Get(Args.Uri, null, null) + .Returns(Task.FromResult(response)); + var client = new MiscellaneousClient(connection); + + var result = await client.GetMetadata(); + + Assert.Equal(result.VerifiablePasswordAuthentication, false); + Assert.Equal(result.GitHubServicesSha, "12345ABCDE"); + Assert.Equal(result.Hooks, new[] { "1.1.1.1/24", "1.1.1.2/24" }); + Assert.Equal(result.Git, new[] { "1.1.2.1/24", "1.1.2.2/24" }); + Assert.Equal(result.Pages, new[] { "1.1.3.1/24", "1.1.3.2/24" }); + Assert.Equal(result.Importer, new[] { "1.1.4.1", "1.1.4.2" }); + + connection.Received() + .Get(Arg.Is(u => u.ToString() == "meta"), null, null); + } + } + public class TheCtor { [Fact] diff --git a/Octokit/Models/Response/Meta.cs b/Octokit/Models/Response/Meta.cs index 3d388827..a6211110 100644 --- a/Octokit/Models/Response/Meta.cs +++ b/Octokit/Models/Response/Meta.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Globalization; +using Octokit.Internal; namespace Octokit { @@ -30,13 +31,15 @@ namespace Octokit string gitHubServicesSha, IReadOnlyList hooks, IReadOnlyList git, - IReadOnlyList pages) + IReadOnlyList pages, + IReadOnlyList importer) { VerifiablePasswordAuthentication = verifiablePasswordAuthentication; GitHubServicesSha = gitHubServicesSha; Hooks = hooks; Git = git; Pages = pages; + Importer = importer; } /// @@ -49,6 +52,7 @@ namespace Octokit /// /// The currently-deployed SHA of github-services. /// + [Parameter(Key = "github_services_sha")] public string GitHubServicesSha { get; private set; } /// @@ -68,6 +72,11 @@ namespace Octokit /// public IReadOnlyList Pages { get; private set; } + /// + /// An Array of IP addresses specifying the addresses that source imports will originate from on GitHub.com. + /// + public IReadOnlyList Importer { get; private set; } + internal string DebuggerDisplay { get From 09ebe007b75f3dc40ae63709eb5dd8cb2c3b6548 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sun, 3 Apr 2016 22:20:02 +1000 Subject: [PATCH 068/123] Add unit test for ObservableMiscellaneousClient Fix observable's constructor (obsoleting old constructor) to make it consistent with the other API clients --- .../Clients/ObservableMiscellaneousClient.cs | 8 + Octokit.Reactive/ObservableGitHubClient.cs | 2 +- Octokit.Tests/Octokit.Tests.csproj | 1 + .../ObservableMiscellaneousClientTests.cs | 145 ++++++++++++++++++ 4 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 Octokit.Tests/Reactive/ObservableMiscellaneousClientTests.cs diff --git a/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs b/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs index ea9c4096..c92d2db9 100644 --- a/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs +++ b/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs @@ -9,6 +9,7 @@ namespace Octokit.Reactive { readonly IMiscellaneousClient _client; + [Obsolete("Please use another constructor")] public ObservableMiscellaneousClient(IMiscellaneousClient client) { Ensure.ArgumentNotNull(client, "client"); @@ -16,6 +17,13 @@ namespace Octokit.Reactive _client = client; } + public ObservableMiscellaneousClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, "client"); + + _client = client.Miscellaneous; + } + /// /// Gets all the emojis available to use on GitHub. /// diff --git a/Octokit.Reactive/ObservableGitHubClient.cs b/Octokit.Reactive/ObservableGitHubClient.cs index d938bf1b..16485593 100644 --- a/Octokit.Reactive/ObservableGitHubClient.cs +++ b/Octokit.Reactive/ObservableGitHubClient.cs @@ -34,7 +34,7 @@ namespace Octokit.Reactive Authorization = new ObservableAuthorizationsClient(gitHubClient); Activity = new ObservableActivitiesClient(gitHubClient); Issue = new ObservableIssuesClient(gitHubClient); - Miscellaneous = new ObservableMiscellaneousClient(gitHubClient.Miscellaneous); + Miscellaneous = new ObservableMiscellaneousClient(gitHubClient); Notification = new ObservableNotificationsClient(gitHubClient); Oauth = new ObservableOauthClient(gitHubClient); Organization = new ObservableOrganizationsClient(gitHubClient); diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 842cb3bc..e93524cf 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -209,6 +209,7 @@ + diff --git a/Octokit.Tests/Reactive/ObservableMiscellaneousClientTests.cs b/Octokit.Tests/Reactive/ObservableMiscellaneousClientTests.cs new file mode 100644 index 00000000..b5a47719 --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableMiscellaneousClientTests.cs @@ -0,0 +1,145 @@ +using System; +using NSubstitute; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableMiscellaneousClientTests + { + public class TheGetAllEmojisMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For(); + var client = new ObservableMiscellaneousClient(gitHubClient); + + client.GetAllEmojis(); + + gitHubClient.Miscellaneous.Received(1).GetAllEmojis(); + } + } + + public class TheRenderArbitraryMarkdownMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For(); + var client = new ObservableMiscellaneousClient(gitHubClient); + + client.RenderArbitraryMarkdown(new NewArbitraryMarkdown("# test")); + + gitHubClient.Miscellaneous.Received(1).RenderArbitraryMarkdown(Arg.Is(a => a.Text == "# test")); + } + } + + public class TheRenderRawMarkdownMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For(); + var client = new ObservableMiscellaneousClient(gitHubClient); + + client.RenderRawMarkdown("# test"); + + gitHubClient.Miscellaneous.Received(1).RenderRawMarkdown("# test"); + } + } + + public class TheGetAllGitIgnoreTemplatesMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For(); + var client = new ObservableMiscellaneousClient(gitHubClient); + + client.GetAllGitIgnoreTemplates(); + + gitHubClient.Miscellaneous.Received(1).GetAllGitIgnoreTemplates(); + } + } + + public class TheGetGitIgnoreTemplate + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For(); + var client = new ObservableMiscellaneousClient(gitHubClient); + + client.GetGitIgnoreTemplate("template"); + + gitHubClient.Miscellaneous.Received(1).GetGitIgnoreTemplate("template"); + } + } + + public class TheGetAllLicensesMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For(); + var client = new ObservableMiscellaneousClient(gitHubClient); + + client.GetAllLicenses(); + + gitHubClient.Miscellaneous.Received(1).GetAllLicenses(); + } + } + + public class TheGetLicenseMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For(); + var client = new ObservableMiscellaneousClient(gitHubClient); + + client.GetLicense("key"); + + gitHubClient.Miscellaneous.Received(1).GetLicense("key"); + } + } + + public class TheGetRateLimitsMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For(); + var client = new ObservableMiscellaneousClient(gitHubClient); + + client.GetRateLimits(); + + gitHubClient.Miscellaneous.Received(1).GetRateLimits(); + } + } + + public class TheGetMetadataMethod + { + [Fact] + public void CallsIntoClient() + { + var gitHubClient = Substitute.For(); + var client = new ObservableMiscellaneousClient(gitHubClient); + + client.GetMetadata(); + + gitHubClient.Miscellaneous.Received(1).GetMetadata(); + } + } + + public class TheCtor + { + [Fact] + public void EnsuresArgument() + { + Assert.Throws(() => new ObservableMiscellaneousClient((IGitHubClient)null)); + } + } + } +} From 6a68110bc9a44ce58c5c30f133a8296d12019893 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Sun, 3 Apr 2016 23:04:46 +1000 Subject: [PATCH 069/123] fix XmlDoc comments --- Octokit/Models/Response/Meta.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Octokit/Models/Response/Meta.cs b/Octokit/Models/Response/Meta.cs index a6211110..0dec38c9 100644 --- a/Octokit/Models/Response/Meta.cs +++ b/Octokit/Models/Response/Meta.cs @@ -26,6 +26,7 @@ namespace Octokit /// An array of IP addresses in CIDR format specifying the addresses that incoming service hooks will originate from on GitHub.com. /// An array of IP addresses in CIDR format specifying the Git servers for the GitHub server /// An array of IP addresses in CIDR format specifying the A records for GitHub Pages. + /// An Array of IP addresses specifying the addresses that source imports will originate from on GitHub.com. public Meta( bool verifiablePasswordAuthentication, string gitHubServicesSha, From 8ec4bf388c674c1ce5f09f8c8ad88a470ce7f4d9 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Sun, 3 Apr 2016 15:48:38 -0400 Subject: [PATCH 070/123] remove the PCL unpackaging when running on Travis --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index cc3ced7c..5acd1c06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,6 @@ os: - osx - linux install: - - curl -sS http://storage.bos.xamarin.com/bot-provisioning/PortableReferenceAssemblies-2014-04-14.zip > /tmp/pcl-assemblies.zip - - unzip /tmp/pcl-assemblies.zip -d /tmp/pcl-assemblies && mv /tmp/pcl-assemblies/PortableReferenceAssemblies-2014-04-14 /tmp/pcl-assemblies/.NETPortable - - export XBUILD_FRAMEWORK_FOLDERS_PATH=/tmp/pcl-assemblies/ - nuget restore Octokit-Mono.sln script: - mono tools/nuget/NuGet.exe restore Octokit-Mono.sln From a51e17e790753f099be7ba6776943d52bc42e045 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Sun, 3 Apr 2016 15:48:38 -0400 Subject: [PATCH 071/123] remove the PCL unpackaging when running on Travis --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index cc3ced7c..5acd1c06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,6 @@ os: - osx - linux install: - - curl -sS http://storage.bos.xamarin.com/bot-provisioning/PortableReferenceAssemblies-2014-04-14.zip > /tmp/pcl-assemblies.zip - - unzip /tmp/pcl-assemblies.zip -d /tmp/pcl-assemblies && mv /tmp/pcl-assemblies/PortableReferenceAssemblies-2014-04-14 /tmp/pcl-assemblies/.NETPortable - - export XBUILD_FRAMEWORK_FOLDERS_PATH=/tmp/pcl-assemblies/ - nuget restore Octokit-Mono.sln script: - mono tools/nuget/NuGet.exe restore Octokit-Mono.sln From 5a979e696c448883b422ac52ce08b613335ad6b8 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Tue, 5 Apr 2016 07:20:32 +1000 Subject: [PATCH 072/123] Reword obsolete message --- Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs b/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs index c92d2db9..9fae21b2 100644 --- a/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs +++ b/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs @@ -9,7 +9,7 @@ namespace Octokit.Reactive { readonly IMiscellaneousClient _client; - [Obsolete("Please use another constructor")] + [Obsolete("Please use the IGitHubClient overload constructor")] public ObservableMiscellaneousClient(IMiscellaneousClient client) { Ensure.ArgumentNotNull(client, "client"); From 544ea6b3e888cb86cea8bb2a6eb8cae57674bfdc Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 6 Apr 2016 20:08:40 -0400 Subject: [PATCH 073/123] drop unnecessary awaits and specify ConfigureAwait otherwise --- Octokit/Clients/AuthorizationsClient.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Octokit/Clients/AuthorizationsClient.cs b/Octokit/Clients/AuthorizationsClient.cs index c94a7604..12f1d590 100644 --- a/Octokit/Clients/AuthorizationsClient.cs +++ b/Octokit/Clients/AuthorizationsClient.cs @@ -323,7 +323,7 @@ namespace Octokit return await ApiConnection.Put( endpoint, requestData, - twoFactorAuthenticationCode); + twoFactorAuthenticationCode).ConfigureAwait(false); } catch (AuthorizationException e) { @@ -341,15 +341,13 @@ namespace Octokit /// Client ID of the OAuth application for the token /// The OAuth token to check /// The valid . - public async Task CheckApplicationAuthentication(string clientId, string accessToken) + public Task CheckApplicationAuthentication(string clientId, string accessToken) { Ensure.ArgumentNotNullOrEmptyString(clientId, "clientId"); Ensure.ArgumentNotNullOrEmptyString(accessToken, "accessToken"); var endpoint = ApiUrls.ApplicationAuthorization(clientId, accessToken); - return await ApiConnection.Get( - endpoint, - null); + return ApiConnection.Get(endpoint, null); } /// @@ -362,15 +360,14 @@ namespace Octokit /// ClientID of the OAuth application for the token /// The OAuth token to reset /// The valid with a new OAuth token - public async Task ResetApplicationAuthentication(string clientId, string accessToken) + public Task ResetApplicationAuthentication(string clientId, string accessToken) { Ensure.ArgumentNotNullOrEmptyString(clientId, "clientId"); Ensure.ArgumentNotNullOrEmptyString(accessToken, "accessToken"); var requestData = new { }; - return await ApiConnection.Post( - ApiUrls.ApplicationAuthorization(clientId, accessToken), requestData); + return ApiConnection.Post(ApiUrls.ApplicationAuthorization(clientId, accessToken), requestData); } /// From cc834b13855e25a1b0e216f90ab052d27341762c Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 6 Apr 2016 20:09:19 -0400 Subject: [PATCH 074/123] drop unnecessary awaits and specify ConfigureAwait otherwise for Enterprise clients --- .../Enterprise/EnterpriseAdminStatsClient.cs | 55 ++++++++----------- .../Enterprise/EnterpriseLdapClient.cs | 4 +- .../Enterprise/EnterpriseLicenseClient.cs | 5 +- .../EnterpriseOrganizationClient.cs | 4 +- .../EnterpriseSearchIndexingClient.cs | 35 +++++------- 5 files changed, 42 insertions(+), 61 deletions(-) diff --git a/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs b/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs index 11e5f9fb..cdbbd7de 100644 --- a/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseAdminStatsClient.cs @@ -21,12 +21,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The statistics. - public async Task GetStatisticsIssues() + public Task GetStatisticsIssues() { var endpoint = ApiUrls.EnterpriseAdminStatsIssues(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } /// @@ -36,12 +35,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The statistics. - public async Task GetStatisticsHooks() + public Task GetStatisticsHooks() { var endpoint = ApiUrls.EnterpriseAdminStatsHooks(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } /// @@ -51,12 +49,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The statistics. - public async Task GetStatisticsMilestones() + public Task GetStatisticsMilestones() { var endpoint = ApiUrls.EnterpriseAdminStatsMilestones(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } /// @@ -66,12 +63,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The statistics. - public async Task GetStatisticsOrgs() + public Task GetStatisticsOrgs() { var endpoint = ApiUrls.EnterpriseAdminStatsOrgs(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } /// @@ -81,12 +77,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The statistics. - public async Task GetStatisticsComments() + public Task GetStatisticsComments() { var endpoint = ApiUrls.EnterpriseAdminStatsComments(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } /// @@ -96,12 +91,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The statistics. - public async Task GetStatisticsPages() + public Task GetStatisticsPages() { var endpoint = ApiUrls.EnterpriseAdminStatsPages(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } /// @@ -111,12 +105,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The statistics. - public async Task GetStatisticsUsers() + public Task GetStatisticsUsers() { var endpoint = ApiUrls.EnterpriseAdminStatsUsers(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } /// @@ -126,12 +119,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The statistics. - public async Task GetStatisticsGists() + public Task GetStatisticsGists() { var endpoint = ApiUrls.EnterpriseAdminStatsGists(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } /// @@ -141,12 +133,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The statistics. - public async Task GetStatisticsPulls() + public Task GetStatisticsPulls() { var endpoint = ApiUrls.EnterpriseAdminStatsPulls(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } /// @@ -156,12 +147,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The statistics. - public async Task GetStatisticsRepos() + public Task GetStatisticsRepos() { var endpoint = ApiUrls.EnterpriseAdminStatsRepos(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } /// @@ -171,12 +161,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/admin_stats/#get-statistics /// /// The collection of statistics. - public async Task GetStatisticsAll() + public Task GetStatisticsAll() { var endpoint = ApiUrls.EnterpriseAdminStatsAll(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } } } diff --git a/Octokit/Clients/Enterprise/EnterpriseLdapClient.cs b/Octokit/Clients/Enterprise/EnterpriseLdapClient.cs index 1980dc6f..16c8987f 100644 --- a/Octokit/Clients/Enterprise/EnterpriseLdapClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseLdapClient.cs @@ -48,7 +48,7 @@ namespace Octokit var endpoint = ApiUrls.EnterpriseLdapUserSync(userName); - var response = await Connection.Post(endpoint); + var response = await Connection.Post(endpoint).ConfigureAwait(false); if (response.HttpResponse.StatusCode != HttpStatusCode.Created) { throw new ApiException("Invalid Status Code returned. Expected a 201", response.HttpResponse.StatusCode); @@ -90,7 +90,7 @@ namespace Octokit var endpoint = ApiUrls.EnterpriseLdapTeamSync(teamId); - var response = await Connection.Post(endpoint); + var response = await Connection.Post(endpoint).ConfigureAwait(false); if (response.HttpResponse.StatusCode != HttpStatusCode.Created) { throw new ApiException("Invalid Status Code returned. Expected a 201", response.HttpResponse.StatusCode); diff --git a/Octokit/Clients/Enterprise/EnterpriseLicenseClient.cs b/Octokit/Clients/Enterprise/EnterpriseLicenseClient.cs index 46638883..4efab54b 100644 --- a/Octokit/Clients/Enterprise/EnterpriseLicenseClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseLicenseClient.cs @@ -21,12 +21,11 @@ namespace Octokit /// https://developer.github.com/v3/enterprise/license/#get-license-information /// /// The statistics. - public async Task Get() + public Task Get() { var endpoint = ApiUrls.EnterpriseLicense(); - return await ApiConnection.Get(endpoint) - .ConfigureAwait(false); + return ApiConnection.Get(endpoint); } } } diff --git a/Octokit/Clients/Enterprise/EnterpriseOrganizationClient.cs b/Octokit/Clients/Enterprise/EnterpriseOrganizationClient.cs index 0848ff8e..22fee148 100644 --- a/Octokit/Clients/Enterprise/EnterpriseOrganizationClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseOrganizationClient.cs @@ -22,13 +22,13 @@ namespace Octokit /// /// A instance describing the organization to be created /// The created. - public async Task Create(NewOrganization newOrganization) + public Task Create(NewOrganization newOrganization) { Ensure.ArgumentNotNull(newOrganization, "newOrganization"); var endpoint = ApiUrls.EnterpriseOrganization(); - return await ApiConnection.Post(endpoint, newOrganization); + return ApiConnection.Post(endpoint, newOrganization); } } } diff --git a/Octokit/Clients/Enterprise/EnterpriseSearchIndexingClient.cs b/Octokit/Clients/Enterprise/EnterpriseSearchIndexingClient.cs index 2351a2f1..0feea186 100644 --- a/Octokit/Clients/Enterprise/EnterpriseSearchIndexingClient.cs +++ b/Octokit/Clients/Enterprise/EnterpriseSearchIndexingClient.cs @@ -23,15 +23,14 @@ namespace Octokit /// /// A user or organization account /// The message. - public async Task Queue(string owner) + public Task Queue(string owner) { Ensure.ArgumentNotNull(owner, "owner"); var endpoint = ApiUrls.EnterpriseSearchIndexing(); var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}", owner)); - return await ApiConnection.Post(endpoint, target) - .ConfigureAwait(false); + return ApiConnection.Post(endpoint, target); } /// @@ -43,7 +42,7 @@ namespace Octokit /// A user or organization account /// A repository /// The message. - public async Task Queue(string owner, string repository) + public Task Queue(string owner, string repository) { Ensure.ArgumentNotNull(owner, "owner"); Ensure.ArgumentNotNull(repository, "repository"); @@ -51,8 +50,7 @@ namespace Octokit var endpoint = ApiUrls.EnterpriseSearchIndexing(); var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}/{1}", owner, repository)); - return await ApiConnection.Post(endpoint, target) - .ConfigureAwait(false); + return ApiConnection.Post(endpoint, target); } /// @@ -63,15 +61,14 @@ namespace Octokit /// /// A user or organization account /// The message. - public async Task QueueAll(string owner) + public Task QueueAll(string owner) { Ensure.ArgumentNotNull(owner, "owner"); var endpoint = ApiUrls.EnterpriseSearchIndexing(); var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}/*", owner)); - return await ApiConnection.Post(endpoint, target) - .ConfigureAwait(false); + return ApiConnection.Post(endpoint, target); } /// @@ -83,7 +80,7 @@ namespace Octokit /// A user or organization account /// A repository /// The message. - public async Task QueueAllIssues(string owner, string repository) + public Task QueueAllIssues(string owner, string repository) { Ensure.ArgumentNotNull(owner, "owner"); Ensure.ArgumentNotNull(repository, "repository"); @@ -91,8 +88,7 @@ namespace Octokit var endpoint = ApiUrls.EnterpriseSearchIndexing(); var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}/{1}/issues", owner, repository)); - return await ApiConnection.Post(endpoint, target) - .ConfigureAwait(false); + return ApiConnection.Post(endpoint, target); } /// @@ -103,15 +99,14 @@ namespace Octokit /// /// A user or organization account /// The message. - public async Task QueueAllIssues(string owner) + public Task QueueAllIssues(string owner) { Ensure.ArgumentNotNull(owner, "owner"); var endpoint = ApiUrls.EnterpriseSearchIndexing(); var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}/*/issues", owner)); - return await ApiConnection.Post(endpoint, target) - .ConfigureAwait(false); + return ApiConnection.Post(endpoint, target); } /// @@ -123,7 +118,7 @@ namespace Octokit /// A user or organization account /// A repository /// The message. - public async Task QueueAllCode(string owner, string repository) + public Task QueueAllCode(string owner, string repository) { Ensure.ArgumentNotNull(owner, "owner"); Ensure.ArgumentNotNull(repository, "repository"); @@ -131,8 +126,7 @@ namespace Octokit var endpoint = ApiUrls.EnterpriseSearchIndexing(); var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}/{1}/code", owner, repository)); - return await ApiConnection.Post(endpoint, target) - .ConfigureAwait(false); + return ApiConnection.Post(endpoint, target); } /// @@ -143,15 +137,14 @@ namespace Octokit /// /// A user or organization account /// The message. - public async Task QueueAllCode(string owner) + public Task QueueAllCode(string owner) { Ensure.ArgumentNotNull(owner, "owner"); var endpoint = ApiUrls.EnterpriseSearchIndexing(); var target = new SearchIndexTarget(string.Format(CultureInfo.InvariantCulture, "{0}/*/code", owner)); - return await ApiConnection.Post(endpoint, target) - .ConfigureAwait(false); + return ApiConnection.Post(endpoint, target); } } } From d3c43b77a9fa215febb7baddba60c4a329382576 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 6 Apr 2016 20:09:59 -0400 Subject: [PATCH 075/123] drop unnecessary awaits and specify ConfigureAwait otherwise for other core clients --- Octokit/Clients/PullRequestsClient.cs | 2 +- Octokit/Clients/RepositoriesClient.cs | 2 +- Octokit/Clients/RepositoryContentsClient.cs | 2 +- Octokit/Clients/StatisticsClient.cs | 12 ++++++------ Octokit/Clients/TeamsClient.cs | 14 +++++++------- Octokit/Clients/UserAdministrationClient.cs | 6 +++--- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Octokit/Clients/PullRequestsClient.cs b/Octokit/Clients/PullRequestsClient.cs index 85ffe16f..39d3abc9 100644 --- a/Octokit/Clients/PullRequestsClient.cs +++ b/Octokit/Clients/PullRequestsClient.cs @@ -118,7 +118,7 @@ namespace Octokit try { - return await ApiConnection.Put(ApiUrls.MergePullRequest(owner, name, number), mergePullRequest); + return await ApiConnection.Put(ApiUrls.MergePullRequest(owner, name, number), mergePullRequest).ConfigureAwait(false); } catch (ApiException ex) { diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 41af07ae..7d209297 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -87,7 +87,7 @@ namespace Octokit { try { - return await ApiConnection.Post(url, newRepository); + return await ApiConnection.Post(url, newRepository).ConfigureAwait(false); } catch (ApiValidationException e) { diff --git a/Octokit/Clients/RepositoryContentsClient.cs b/Octokit/Clients/RepositoryContentsClient.cs index cc63f00e..fbd1d850 100644 --- a/Octokit/Clients/RepositoryContentsClient.cs +++ b/Octokit/Clients/RepositoryContentsClient.cs @@ -259,7 +259,7 @@ namespace Octokit var endpoint = ApiUrls.RepositoryArchiveLink(owner, name, archiveFormat, reference); - var response = await Connection.Get(endpoint, timeout); + var response = await Connection.Get(endpoint, timeout).ConfigureAwait(false); return response.Body; } diff --git a/Octokit/Clients/StatisticsClient.cs b/Octokit/Clients/StatisticsClient.cs index f63a94ec..d55207d2 100644 --- a/Octokit/Clients/StatisticsClient.cs +++ b/Octokit/Clients/StatisticsClient.cs @@ -39,13 +39,13 @@ namespace Octokit /// The name of the repository /// A token used to cancel this potentially long running request /// A list of - public async Task> GetContributors(string owner, string repositoryName, CancellationToken cancellationToken) + public Task> GetContributors(string owner, string repositoryName, CancellationToken cancellationToken) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); var endpoint = "repos/{0}/{1}/stats/contributors".FormatUri(owner, repositoryName); - return await ApiConnection.GetQueuedOperation(endpoint, cancellationToken); + return ApiConnection.GetQueuedOperation(endpoint, cancellationToken); } /// @@ -72,7 +72,7 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); var endpoint = "repos/{0}/{1}/stats/commit_activity".FormatUri(owner, repositoryName); - var activity = await ApiConnection.GetQueuedOperation(endpoint, cancellationToken); + var activity = await ApiConnection.GetQueuedOperation(endpoint, cancellationToken).ConfigureAwait(false); return new CommitActivity(activity); } @@ -100,7 +100,7 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); var endpoint = "repos/{0}/{1}/stats/code_frequency".FormatUri(owner, repositoryName); - var rawFrequencies = await ApiConnection.GetQueuedOperation(endpoint, cancellationToken); + var rawFrequencies = await ApiConnection.GetQueuedOperation(endpoint, cancellationToken).ConfigureAwait(false); return new CodeFrequency(rawFrequencies); } @@ -128,7 +128,7 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); var endpoint = "repos/{0}/{1}/stats/participation".FormatUri(owner, repositoryName); - var result = await ApiConnection.GetQueuedOperation(endpoint, cancellationToken); + var result = await ApiConnection.GetQueuedOperation(endpoint, cancellationToken).ConfigureAwait(false); return result.FirstOrDefault(); } @@ -156,7 +156,7 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); var endpoint = "repos/{0}/{1}/stats/punch_card".FormatUri(owner, repositoryName); - var punchCardData = await ApiConnection.GetQueuedOperation(endpoint, cancellationToken); + var punchCardData = await ApiConnection.GetQueuedOperation(endpoint, cancellationToken).ConfigureAwait(false); return new PunchCard(punchCardData); } } diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index 67376b42..ae721871 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -137,7 +137,7 @@ namespace Octokit try { - response = await ApiConnection.Get>(endpoint); + response = await ApiConnection.Get>(endpoint).ConfigureAwait(false); } catch (NotFoundException) { @@ -208,7 +208,7 @@ namespace Octokit try { - response = await ApiConnection.Put>(endpoint, RequestBody.Empty); + response = await ApiConnection.Put>(endpoint, RequestBody.Empty).ConfigureAwait(false); } catch (NotFoundException) { @@ -242,7 +242,7 @@ namespace Octokit try { - var httpStatusCode = await ApiConnection.Connection.Delete(endpoint); + var httpStatusCode = await ApiConnection.Connection.Delete(endpoint).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } @@ -268,7 +268,7 @@ namespace Octokit try { - var response = await ApiConnection.Connection.GetResponse(endpoint); + var response = await ApiConnection.Connection.GetResponse(endpoint).ConfigureAwait(false); return response.HttpResponse.StatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -333,7 +333,7 @@ namespace Octokit try { - var httpStatusCode = await ApiConnection.Connection.Put(endpoint); + var httpStatusCode = await ApiConnection.Connection.Put(endpoint).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -356,7 +356,7 @@ namespace Octokit try { - var httpStatusCode = await ApiConnection.Connection.Delete(endpoint); + var httpStatusCode = await ApiConnection.Connection.Delete(endpoint).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } @@ -385,7 +385,7 @@ namespace Octokit try { - var response = await ApiConnection.Connection.GetResponse(endpoint); + var response = await ApiConnection.Connection.GetResponse(endpoint).ConfigureAwait(false); return response.HttpResponse.StatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) diff --git a/Octokit/Clients/UserAdministrationClient.cs b/Octokit/Clients/UserAdministrationClient.cs index 1b7a15e6..7245a8ad 100644 --- a/Octokit/Clients/UserAdministrationClient.cs +++ b/Octokit/Clients/UserAdministrationClient.cs @@ -95,7 +95,7 @@ namespace Octokit var endpoint = ApiUrls.UserAdministrationAuthorization(login); - var response = ((HttpStatusCode)await Connection.Delete(endpoint)); + var response = await Connection.Delete(endpoint).ConfigureAwait(false); if (response != HttpStatusCode.NoContent) { throw new ApiException("Invalid Status Code returned. Expected a 204", response); @@ -196,7 +196,7 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(login, "login"); var endpoint = ApiUrls.UserAdministration(login); - var response = ((HttpStatusCode)await Connection.Delete(endpoint)); + var response = await Connection.Delete(endpoint).ConfigureAwait(false); if (response != HttpStatusCode.NoContent) { throw new ApiException("Invalid Status Code returned. Expected a 204", response); @@ -219,7 +219,7 @@ namespace Octokit Ensure.ArgumentNotNull(keyId, "keyId"); var endpoint = ApiUrls.UserAdministrationPublicKeys(keyId); - var response = ((HttpStatusCode)await Connection.Delete(endpoint)); + var response = await Connection.Delete(endpoint).ConfigureAwait(false); if (response != HttpStatusCode.NoContent) { throw new ApiException("Invalid Status Code returned. Expected a 204", response); From c5600ce37b4ab7693e3f1f8cc91bf4880537cebb Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 6 Apr 2016 20:10:20 -0400 Subject: [PATCH 076/123] and a couple more awaits for necessary internals --- Octokit/Helpers/ReferenceExtensions.cs | 6 +++--- Octokit/Http/ApiConnection.cs | 2 +- Octokit/Http/HttpClientAdapter.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Octokit/Helpers/ReferenceExtensions.cs b/Octokit/Helpers/ReferenceExtensions.cs index 93bd4f70..1c79f503 100644 --- a/Octokit/Helpers/ReferenceExtensions.cs +++ b/Octokit/Helpers/ReferenceExtensions.cs @@ -29,7 +29,7 @@ namespace Octokit.Helpers throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, "The specified branch name '{0}' appears to be a ref name and not a branch name because it starts with the string 'refs/heads'. Either specify just the branch name or use the Create method if you need to specify the full ref name", branchName), "branchName"); } - return await referencesClient.Create(owner, name, new NewReference("refs/heads/" + branchName, baseReference.Object.Sha)); + return await referencesClient.Create(owner, name, new NewReference("refs/heads/" + branchName, baseReference.Object.Sha)).ConfigureAwait(false); } /// @@ -50,8 +50,8 @@ namespace Octokit.Helpers throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, "The specified branch name '{0}' appears to be a ref name and not a branch name because it starts with the string 'refs/heads'. Either specify just the branch name or use the Create method if you need to specify the full ref name", branchName), "branchName"); } - var baseBranch = await referencesClient.Get(owner, name, "heads/master"); - return await referencesClient.Create(owner, name, new NewReference("refs/heads/" + branchName, baseBranch.Object.Sha)); + var baseBranch = await referencesClient.Get(owner, name, "heads/master").ConfigureAwait(false); + return await referencesClient.Create(owner, name, new NewReference("refs/heads/" + branchName, baseBranch.Object.Sha)).ConfigureAwait(false); } } } diff --git a/Octokit/Http/ApiConnection.cs b/Octokit/Http/ApiConnection.cs index a08a8aeb..b4b1192c 100644 --- a/Octokit/Http/ApiConnection.cs +++ b/Octokit/Http/ApiConnection.cs @@ -494,7 +494,7 @@ namespace Octokit public async Task GetRedirect(Uri uri) { Ensure.ArgumentNotNull(uri, "uri"); - var response = await Connection.GetRedirect(uri); + var response = await Connection.GetRedirect(uri).ConfigureAwait(false); if (response.HttpResponse.StatusCode == HttpStatusCode.Redirect) { diff --git a/Octokit/Http/HttpClientAdapter.cs b/Octokit/Http/HttpClientAdapter.cs index 1c6a65a5..bbc9ca80 100644 --- a/Octokit/Http/HttpClientAdapter.cs +++ b/Octokit/Http/HttpClientAdapter.cs @@ -178,7 +178,7 @@ namespace Octokit.Internal protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { - var response = await base.SendAsync(request, cancellationToken); + var response = await base.SendAsync(request, cancellationToken).ConfigureAwait(false); // Can't redirect without somewhere to redirect too. Throw? if (response.Headers.Location == null) return response; From b751a3e44fa3f3823250efd160e8a794e0068b63 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 6 Apr 2016 20:17:39 -0400 Subject: [PATCH 077/123] cleanup some indenting to make things a bit more readable --- Octokit/Clients/PullRequestReviewCommentsClient.cs | 6 ++++-- Octokit/Clients/PullRequestsClient.cs | 7 ++++--- Octokit/Clients/RepositoriesClient.cs | 5 ++--- Octokit/Clients/WatchedClient.cs | 8 ++++---- Octokit/Helpers/ReferenceExtensions.cs | 6 ++++-- Octokit/Http/ApiConnection.cs | 3 +-- 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Octokit/Clients/PullRequestReviewCommentsClient.cs b/Octokit/Clients/PullRequestReviewCommentsClient.cs index 5d8363b2..8db0925b 100644 --- a/Octokit/Clients/PullRequestReviewCommentsClient.cs +++ b/Octokit/Clients/PullRequestReviewCommentsClient.cs @@ -93,7 +93,8 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(comment, "comment"); - var response = await ApiConnection.Connection.Post(ApiUrls.PullRequestReviewComments(owner, name, number), comment, null, null).ConfigureAwait(false); + var endpoint = ApiUrls.PullRequestReviewComments(owner, name, number); + var response = await ApiConnection.Connection.Post(endpoint, comment, null, null).ConfigureAwait(false); if (response.HttpResponse.StatusCode != HttpStatusCode.Created) { @@ -118,7 +119,8 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(comment, "comment"); - var response = await ApiConnection.Connection.Post(ApiUrls.PullRequestReviewComments(owner, name, number), comment, null, null).ConfigureAwait(false); + var endpoint = ApiUrls.PullRequestReviewComments(owner, name, number); + var response = await ApiConnection.Connection.Post(endpoint, comment, null, null).ConfigureAwait(false); if (response.HttpResponse.StatusCode != HttpStatusCode.Created) { diff --git a/Octokit/Clients/PullRequestsClient.cs b/Octokit/Clients/PullRequestsClient.cs index 39d3abc9..c8c33478 100644 --- a/Octokit/Clients/PullRequestsClient.cs +++ b/Octokit/Clients/PullRequestsClient.cs @@ -118,7 +118,8 @@ namespace Octokit try { - return await ApiConnection.Put(ApiUrls.MergePullRequest(owner, name, number), mergePullRequest).ConfigureAwait(false); + var endpoint = ApiUrls.MergePullRequest(owner, name, number); + return await ApiConnection.Put(endpoint, mergePullRequest).ConfigureAwait(false); } catch (ApiException ex) { @@ -151,8 +152,8 @@ namespace Octokit try { - var response = await Connection.Get(ApiUrls.MergePullRequest(owner, name, number), null, null) - .ConfigureAwait(false); + var endpoint = ApiUrls.MergePullRequest(owner, name, number); + var response = await Connection.Get(endpoint, null, null).ConfigureAwait(false); return response.HttpResponse.IsTrue(); } catch (NotFoundException) diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 7d209297..dfb3806e 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -518,9 +518,8 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - var data = await ApiConnection - .Get>(ApiUrls.RepositoryLanguages(owner, name)) - .ConfigureAwait(false); + var endpoint = ApiUrls.RepositoryLanguages(owner, name); + var data = await ApiConnection.Get>(endpoint).ConfigureAwait(false); return new ReadOnlyCollection( data.Select(kvp => new RepositoryLanguage(kvp.Key, kvp.Value)).ToList()); diff --git a/Octokit/Clients/WatchedClient.cs b/Octokit/Clients/WatchedClient.cs index fbc23c97..e406696a 100644 --- a/Octokit/Clients/WatchedClient.cs +++ b/Octokit/Clients/WatchedClient.cs @@ -77,8 +77,8 @@ namespace Octokit try { - var subscription = await ApiConnection.Get(ApiUrls.Watched(owner, name)) - .ConfigureAwait(false); + var endpoint = ApiUrls.Watched(owner, name); + var subscription = await ApiConnection.Get(endpoint).ConfigureAwait(false); return subscription != null; } @@ -117,8 +117,8 @@ namespace Octokit try { - var statusCode = await Connection.Delete(ApiUrls.Watched(owner, name)) - .ConfigureAwait(false); + var endpoint = ApiUrls.Watched(owner, name); + var statusCode = await Connection.Delete(endpoint).ConfigureAwait(false); return statusCode == HttpStatusCode.NoContent; } diff --git a/Octokit/Helpers/ReferenceExtensions.cs b/Octokit/Helpers/ReferenceExtensions.cs index 1c79f503..b7220a9a 100644 --- a/Octokit/Helpers/ReferenceExtensions.cs +++ b/Octokit/Helpers/ReferenceExtensions.cs @@ -29,7 +29,8 @@ namespace Octokit.Helpers throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, "The specified branch name '{0}' appears to be a ref name and not a branch name because it starts with the string 'refs/heads'. Either specify just the branch name or use the Create method if you need to specify the full ref name", branchName), "branchName"); } - return await referencesClient.Create(owner, name, new NewReference("refs/heads/" + branchName, baseReference.Object.Sha)).ConfigureAwait(false); + var newReference = new NewReference("refs/heads/" + branchName, baseReference.Object.Sha); + return await referencesClient.Create(owner, name, newReference).ConfigureAwait(false); } /// @@ -51,7 +52,8 @@ namespace Octokit.Helpers } var baseBranch = await referencesClient.Get(owner, name, "heads/master").ConfigureAwait(false); - return await referencesClient.Create(owner, name, new NewReference("refs/heads/" + branchName, baseBranch.Object.Sha)).ConfigureAwait(false); + var newReference = new NewReference("refs/heads/" + branchName, baseBranch.Object.Sha); + return await referencesClient.Create(owner, name, newReference).ConfigureAwait(false); } } } diff --git a/Octokit/Http/ApiConnection.cs b/Octokit/Http/ApiConnection.cs index b4b1192c..86b11169 100644 --- a/Octokit/Http/ApiConnection.cs +++ b/Octokit/Http/ApiConnection.cs @@ -171,8 +171,7 @@ namespace Octokit { Ensure.ArgumentNotNull(uri, "uri"); - return _pagination.GetAllPages(async () => await GetPage(uri, parameters, accepts) - .ConfigureAwait(false), uri); + return _pagination.GetAllPages(async () => await GetPage(uri, parameters, accepts).ConfigureAwait(false), uri); } public Task> GetAll(Uri uri, IDictionary parameters, string accepts, ApiOptions options) From a6c21e8649c20a470b3677f539cddb5854a8bce4 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 6 Apr 2016 20:17:57 -0400 Subject: [PATCH 078/123] one more internal usage to configure --- Octokit/Http/HttpClientAdapter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Http/HttpClientAdapter.cs b/Octokit/Http/HttpClientAdapter.cs index bbc9ca80..d65fa306 100644 --- a/Octokit/Http/HttpClientAdapter.cs +++ b/Octokit/Http/HttpClientAdapter.cs @@ -213,7 +213,7 @@ namespace Octokit.Internal { if (request.Content != null && request.Content.Headers.ContentLength != 0) { - var stream = await request.Content.ReadAsStreamAsync(); + var stream = await request.Content.ReadAsStreamAsync().ConfigureAwait(false); if (stream.CanSeek) { stream.Position = 0; From ff7fcfa0348886ad4b5b3d56942fea8a3728536e Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 6 Apr 2016 20:21:33 -0400 Subject: [PATCH 079/123] one more usage in client --- Octokit/Clients/OAuthClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Clients/OAuthClient.cs b/Octokit/Clients/OAuthClient.cs index d283b5a4..e6e17fb8 100644 --- a/Octokit/Clients/OAuthClient.cs +++ b/Octokit/Clients/OAuthClient.cs @@ -62,7 +62,7 @@ namespace Octokit var body = new FormUrlEncodedContent(request.ToParametersDictionary()); - var response = await connection.Post(endPoint, body, "application/json", null, hostAddress); + var response = await connection.Post(endPoint, body, "application/json", null, hostAddress).ConfigureAwait(false); return response.Body; } } From 01c55763c7187c5e384efda0d63d3e69a36a1611 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 6 Apr 2016 20:22:21 -0400 Subject: [PATCH 080/123] some more usages in internals that need ConfigureAwait --- Octokit/Clients/OrganizationMembersClient.cs | 3 +-- Octokit/Http/Connection.cs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Octokit/Clients/OrganizationMembersClient.cs b/Octokit/Clients/OrganizationMembersClient.cs index 02eb939a..e657eb2e 100644 --- a/Octokit/Clients/OrganizationMembersClient.cs +++ b/Octokit/Clients/OrganizationMembersClient.cs @@ -211,8 +211,7 @@ namespace Octokit try { - var response = await Connection.Get(ApiUrls.CheckMember(org, user), null, null) - .ConfigureAwait(false); + var response = await Connection.Get(ApiUrls.CheckMember(org, user), null, null).ConfigureAwait(false); var statusCode = response.HttpResponse.StatusCode; if (statusCode != HttpStatusCode.NotFound && statusCode != HttpStatusCode.NoContent diff --git a/Octokit/Http/Connection.cs b/Octokit/Http/Connection.cs index 60e81df9..c9837c6f 100644 --- a/Octokit/Http/Connection.cs +++ b/Octokit/Http/Connection.cs @@ -233,7 +233,7 @@ namespace Octokit { Ensure.ArgumentNotNull(uri, "uri"); - var response = await SendData(uri, HttpMethod.Post, null, null, null, CancellationToken.None); + var response = await SendData(uri, HttpMethod.Post, null, null, null, CancellationToken.None).ConfigureAwait(false); return response.HttpResponse.StatusCode; } @@ -399,7 +399,7 @@ namespace Octokit BaseAddress = BaseAddress, Endpoint = uri }; - var response = await Run(request, CancellationToken.None); + var response = await Run(request, CancellationToken.None).ConfigureAwait(false); return response.HttpResponse.StatusCode; } @@ -418,7 +418,7 @@ namespace Octokit BaseAddress = BaseAddress, Endpoint = uri }; - var response = await Run(request, CancellationToken.None); + var response = await Run(request, CancellationToken.None).ConfigureAwait(false); return response.HttpResponse.StatusCode; } @@ -437,7 +437,7 @@ namespace Octokit BaseAddress = BaseAddress, Endpoint = uri }; - var response = await Run(request, CancellationToken.None); + var response = await Run(request, CancellationToken.None).ConfigureAwait(false); return response.HttpResponse.StatusCode; } @@ -458,7 +458,7 @@ namespace Octokit null, null, CancellationToken.None, - twoFactorAuthenticationCode); + twoFactorAuthenticationCode).ConfigureAwait(false); return response.HttpResponse.StatusCode; } @@ -480,7 +480,7 @@ namespace Octokit BaseAddress = BaseAddress, Endpoint = uri }; - var response = await Run(request, CancellationToken.None); + var response = await Run(request, CancellationToken.None).ConfigureAwait(false); return response.HttpResponse.StatusCode; } @@ -496,7 +496,7 @@ namespace Octokit Ensure.ArgumentNotNull(uri, "uri"); Ensure.ArgumentNotNull(accepts, "accepts"); - var response = await SendData(uri, HttpMethod.Delete, data, accepts, null, CancellationToken.None); + var response = await SendData(uri, HttpMethod.Delete, data, accepts, null, CancellationToken.None).ConfigureAwait(false); return response.HttpResponse.StatusCode; } @@ -543,7 +543,7 @@ namespace Octokit async Task> GetHtml(IRequest request) { request.Headers.Add("Accept", AcceptHeaders.StableVersionHtml); - var response = await RunRequest(request, CancellationToken.None); + var response = await RunRequest(request, CancellationToken.None).ConfigureAwait(false); return new ApiResponse(response, response.Body as string); } From 6ba88602e4974754f1b03e7292d4518c20943918 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 6 Apr 2016 20:22:39 -0400 Subject: [PATCH 081/123] cleanup so that await and ConfigureAwait are on same line --- Octokit/Clients/AuthorizationsClient.cs | 5 +---- Octokit/Clients/FollowersClient.cs | 9 +++------ Octokit/Clients/GistsClient.cs | 3 +-- Octokit/Clients/MiscellaneousClient.cs | 21 +++++++-------------- 4 files changed, 12 insertions(+), 26 deletions(-) diff --git a/Octokit/Clients/AuthorizationsClient.cs b/Octokit/Clients/AuthorizationsClient.cs index 12f1d590..4d6e0340 100644 --- a/Octokit/Clients/AuthorizationsClient.cs +++ b/Octokit/Clients/AuthorizationsClient.cs @@ -320,10 +320,7 @@ namespace Octokit { var endpoint = ApiUrls.AuthorizationsForClient(clientId); - return await ApiConnection.Put( - endpoint, - requestData, - twoFactorAuthenticationCode).ConfigureAwait(false); + return await ApiConnection.Put(endpoint, requestData, twoFactorAuthenticationCode).ConfigureAwait(false); } catch (AuthorizationException e) { diff --git a/Octokit/Clients/FollowersClient.cs b/Octokit/Clients/FollowersClient.cs index 5a6dcd44..b2cfe95f 100644 --- a/Octokit/Clients/FollowersClient.cs +++ b/Octokit/Clients/FollowersClient.cs @@ -88,8 +88,7 @@ namespace Octokit try { - var response = await Connection.Get(ApiUrls.IsFollowing(following), null, null) - .ConfigureAwait(false); + var response = await Connection.Get(ApiUrls.IsFollowing(following), null, null).ConfigureAwait(false); return response.HttpResponse.IsTrue(); } catch (NotFoundException) @@ -114,8 +113,7 @@ namespace Octokit try { - var response = await Connection.Get(ApiUrls.IsFollowing(login, following), null, null) - .ConfigureAwait(false); + var response = await Connection.Get(ApiUrls.IsFollowing(login, following), null, null).ConfigureAwait(false); return response.HttpResponse.IsTrue(); } catch (NotFoundException) @@ -139,8 +137,7 @@ namespace Octokit try { var requestData = new { }; - var response = await Connection.Put(ApiUrls.IsFollowing(login), requestData) - .ConfigureAwait(false); + var response = await Connection.Put(ApiUrls.IsFollowing(login), requestData).ConfigureAwait(false); if (response.HttpResponse.StatusCode != HttpStatusCode.NoContent) { throw new ApiException("Invalid Status Code returned. Expected a 204", response.HttpResponse.StatusCode); diff --git a/Octokit/Clients/GistsClient.cs b/Octokit/Clients/GistsClient.cs index 87807656..929d08e2 100644 --- a/Octokit/Clients/GistsClient.cs +++ b/Octokit/Clients/GistsClient.cs @@ -289,8 +289,7 @@ namespace Octokit try { - var response = await Connection.Get(ApiUrls.StarGist(id), null, null) - .ConfigureAwait(false); + var response = await Connection.Get(ApiUrls.StarGist(id), null, null).ConfigureAwait(false); return response.HttpResponse.IsTrue(); } catch (NotFoundException) diff --git a/Octokit/Clients/MiscellaneousClient.cs b/Octokit/Clients/MiscellaneousClient.cs index c9f03d54..cf6242b9 100644 --- a/Octokit/Clients/MiscellaneousClient.cs +++ b/Octokit/Clients/MiscellaneousClient.cs @@ -38,8 +38,7 @@ namespace Octokit public async Task> GetAllEmojis() { var endpoint = new Uri("emojis", UriKind.Relative); - var response = await _connection.Get>(endpoint, null, null) - .ConfigureAwait(false); + var response = await _connection.Get>(endpoint, null, null).ConfigureAwait(false); return new ReadOnlyCollection( response.Body.Select(kvp => new Emoji(kvp.Key, new Uri(kvp.Value))).ToArray()); } @@ -53,8 +52,7 @@ namespace Octokit public async Task RenderRawMarkdown(string markdown) { var endpoint = new Uri("markdown/raw", UriKind.Relative); - var response = await _connection.Post(endpoint, markdown, "text/html", "text/plain") - .ConfigureAwait(false); + var response = await _connection.Post(endpoint, markdown, "text/html", "text/plain").ConfigureAwait(false); return response.Body; } @@ -67,8 +65,7 @@ namespace Octokit public async Task RenderArbitraryMarkdown(NewArbitraryMarkdown markdown) { var endpoint = new Uri("markdown", UriKind.Relative); - var response = await _connection.Post(endpoint, markdown, "text/html", "text/plain") - .ConfigureAwait(false); + var response = await _connection.Post(endpoint, markdown, "text/html", "text/plain").ConfigureAwait(false); return response.Body; } @@ -80,8 +77,7 @@ namespace Octokit { var endpoint = new Uri("gitignore/templates", UriKind.Relative); - var response = await _connection.Get(endpoint, null, null) - .ConfigureAwait(false); + var response = await _connection.Get(endpoint, null, null).ConfigureAwait(false); return new ReadOnlyCollection(response.Body); } @@ -96,8 +92,7 @@ namespace Octokit var endpoint = new Uri("gitignore/templates/" + Uri.EscapeUriString(templateName), UriKind.Relative); - var response = await _connection.Get(endpoint, null, null) - .ConfigureAwait(false); + var response = await _connection.Get(endpoint, null, null).ConfigureAwait(false); return response.Body; } @@ -111,8 +106,7 @@ namespace Octokit { var endpoint = new Uri("licenses", UriKind.Relative); - var response = await _connection.Get(endpoint, null, AcceptHeaders.LicensesApiPreview) - .ConfigureAwait(false); + var response = await _connection.Get(endpoint, null, AcceptHeaders.LicensesApiPreview).ConfigureAwait(false); return new ReadOnlyCollection(response.Body); } @@ -125,8 +119,7 @@ namespace Octokit { var endpoint = new Uri("licenses/" + Uri.EscapeUriString(key), UriKind.Relative); - var response = await _connection.Get(endpoint, null, AcceptHeaders.LicensesApiPreview) - .ConfigureAwait(false); + var response = await _connection.Get(endpoint, null, AcceptHeaders.LicensesApiPreview).ConfigureAwait(false); return response.Body; } From 5b3d5402071022ab52927f031bf072280825a997 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 6 Apr 2016 20:26:59 -0400 Subject: [PATCH 082/123] a couple of other usages found --- Octokit/Http/ApiConnection.cs | 2 +- Octokit/Http/HttpClientAdapter.cs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Octokit/Http/ApiConnection.cs b/Octokit/Http/ApiConnection.cs index 86b11169..1236716a 100644 --- a/Octokit/Http/ApiConnection.cs +++ b/Octokit/Http/ApiConnection.cs @@ -521,7 +521,7 @@ namespace Octokit { Ensure.ArgumentNotNull(uri, "uri"); - var response = await Connection.GetResponse>(uri, cancellationToken); + var response = await Connection.GetResponse>(uri, cancellationToken).ConfigureAwait(false); switch (response.HttpResponse.StatusCode) { diff --git a/Octokit/Http/HttpClientAdapter.cs b/Octokit/Http/HttpClientAdapter.cs index d65fa306..16bb8868 100644 --- a/Octokit/Http/HttpClientAdapter.cs +++ b/Octokit/Http/HttpClientAdapter.cs @@ -43,8 +43,7 @@ namespace Octokit.Internal using (var requestMessage = BuildRequestMessage(request)) { // Make the request - var responseMessage = await _http.SendAsync(requestMessage, HttpCompletionOption.ResponseContentRead, cancellationTokenForRequest) - .ConfigureAwait(false); + var responseMessage = await _http.SendAsync(requestMessage, HttpCompletionOption.ResponseContentRead, cancellationTokenForRequest).ConfigureAwait(false); return await BuildResponse(responseMessage).ConfigureAwait(false); } } @@ -230,7 +229,7 @@ namespace Octokit.Internal { newRequest.Headers.Authorization = null; } - response = await SendAsync(newRequest, cancellationToken); + response = await SendAsync(newRequest, cancellationToken).ConfigureAwait(false); } return response; From c1c035cf01225ff200dab8778c519c2bf4869da2 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 6 Apr 2016 20:27:13 -0400 Subject: [PATCH 083/123] moved ConfigureAwait onto same line as await --- Octokit/Clients/AssigneesClient.cs | 3 +-- Octokit/Clients/OrganizationMembersClient.cs | 6 ++--- Octokit/Clients/RepoCollaboratorsClient.cs | 3 +-- Octokit/Clients/StarredClient.cs | 12 +++------- Octokit/Helpers/AuthorizationExtensions.cs | 3 +-- Octokit/Http/ApiConnection.cs | 23 ++++---------------- Octokit/Http/Connection.cs | 9 +------- 7 files changed, 13 insertions(+), 46 deletions(-) diff --git a/Octokit/Clients/AssigneesClient.cs b/Octokit/Clients/AssigneesClient.cs index 58ca8666..0cd692c7 100644 --- a/Octokit/Clients/AssigneesClient.cs +++ b/Octokit/Clients/AssigneesClient.cs @@ -66,8 +66,7 @@ namespace Octokit try { - var response = await Connection.Get(ApiUrls.CheckAssignee(owner, name, assignee), null, null) - .ConfigureAwait(false); + var response = await Connection.Get(ApiUrls.CheckAssignee(owner, name, assignee), null, null).ConfigureAwait(false); return response.HttpResponse.IsTrue(); } catch (NotFoundException) diff --git a/Octokit/Clients/OrganizationMembersClient.cs b/Octokit/Clients/OrganizationMembersClient.cs index e657eb2e..3f24c984 100644 --- a/Octokit/Clients/OrganizationMembersClient.cs +++ b/Octokit/Clients/OrganizationMembersClient.cs @@ -244,8 +244,7 @@ namespace Octokit try { - var response = await Connection.Get(ApiUrls.CheckMemberPublic(org, user), null, null) - .ConfigureAwait(false); + var response = await Connection.Get(ApiUrls.CheckMemberPublic(org, user), null, null).ConfigureAwait(false); return response.HttpResponse.IsTrue(); } catch (NotFoundException) @@ -293,8 +292,7 @@ namespace Octokit try { var requestData = new { }; - var response = await Connection.Put(ApiUrls.OrganizationMembership(org, user), requestData) - .ConfigureAwait(false); + var response = await Connection.Put(ApiUrls.OrganizationMembership(org, user), requestData).ConfigureAwait(false); if (response.HttpResponse.StatusCode != HttpStatusCode.NoContent) { throw new ApiException("Invalid Status Code returned. Expected a 204", response.HttpResponse.StatusCode); diff --git a/Octokit/Clients/RepoCollaboratorsClient.cs b/Octokit/Clients/RepoCollaboratorsClient.cs index af46fc91..db0d41d0 100644 --- a/Octokit/Clients/RepoCollaboratorsClient.cs +++ b/Octokit/Clients/RepoCollaboratorsClient.cs @@ -57,8 +57,7 @@ namespace Octokit try { - var response = await Connection.Get(endpoint, null, null) - .ConfigureAwait(false); + var response = await Connection.Get(endpoint, null, null).ConfigureAwait(false); return response.HttpResponse.IsTrue(); } catch (NotFoundException) diff --git a/Octokit/Clients/StarredClient.cs b/Octokit/Clients/StarredClient.cs index 1ed20dcd..132ca2dc 100644 --- a/Octokit/Clients/StarredClient.cs +++ b/Octokit/Clients/StarredClient.cs @@ -189,9 +189,7 @@ namespace Octokit try { - var response = await Connection.Get(ApiUrls.Starred(owner, name), null, null) - .ConfigureAwait(false); - + var response = await Connection.Get(ApiUrls.Starred(owner, name), null, null).ConfigureAwait(false); return response.HttpResponse.StatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -213,9 +211,7 @@ namespace Octokit try { - var response = await Connection.Put(ApiUrls.Starred(owner, name), null, null) - .ConfigureAwait(false); - + var response = await Connection.Put(ApiUrls.Starred(owner, name), null, null).ConfigureAwait(false); return response.HttpResponse.StatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -237,9 +233,7 @@ namespace Octokit try { - var statusCode = await Connection.Delete(ApiUrls.Starred(owner, name)) - .ConfigureAwait(false); - + var statusCode = await Connection.Delete(ApiUrls.Starred(owner, name)).ConfigureAwait(false); return statusCode == HttpStatusCode.NoContent; } catch (NotFoundException) diff --git a/Octokit/Helpers/AuthorizationExtensions.cs b/Octokit/Helpers/AuthorizationExtensions.cs index 0d115ab9..1a490e8f 100644 --- a/Octokit/Helpers/AuthorizationExtensions.cs +++ b/Octokit/Helpers/AuthorizationExtensions.cs @@ -41,8 +41,7 @@ namespace Octokit TwoFactorRequiredException twoFactorException = null; try { - return await authorizationsClient.GetOrCreateApplicationAuthentication(clientId, clientSecret, newAuthorization) - .ConfigureAwait(false); + return await authorizationsClient.GetOrCreateApplicationAuthentication(clientId, clientSecret, newAuthorization).ConfigureAwait(false); } catch (TwoFactorRequiredException exception) { diff --git a/Octokit/Http/ApiConnection.cs b/Octokit/Http/ApiConnection.cs index 1236716a..3838e555 100644 --- a/Octokit/Http/ApiConnection.cs +++ b/Octokit/Http/ApiConnection.cs @@ -181,8 +181,7 @@ namespace Octokit parameters = Pagination.Setup(parameters, options); - return _pagination.GetAllPages(async () => await GetPage(uri, parameters, accepts, options) - .ConfigureAwait(false), uri); + return _pagination.GetAllPages(async () => await GetPage(uri, parameters, accepts, options).ConfigureAwait(false), uri); } /// @@ -258,11 +257,7 @@ namespace Octokit Ensure.ArgumentNotNull(uri, "uri"); Ensure.ArgumentNotNull(data, "data"); - var response = await Connection.Post( - uri, - data, - accepts, - contentType).ConfigureAwait(false); + var response = await Connection.Post(uri, data, accepts, contentType).ConfigureAwait(false); return response.Body; } @@ -283,12 +278,7 @@ namespace Octokit Ensure.ArgumentNotNull(data, "data"); Ensure.ArgumentNotNull(twoFactorAuthenticationCode, "twoFactorAuthenticationCode"); - var response = await Connection.Post( - uri, - data, - accepts, - contentType, - twoFactorAuthenticationCode).ConfigureAwait(false); + var response = await Connection.Post(uri, data, accepts, contentType, twoFactorAuthenticationCode).ConfigureAwait(false); return response.Body; } @@ -298,12 +288,7 @@ namespace Octokit Ensure.ArgumentNotNull(uri, "uri"); Ensure.ArgumentNotNull(data, "data"); - var response = await Connection.Post( - uri, - data, - accepts, - contentType, - timeout).ConfigureAwait(false); + var response = await Connection.Post(uri, data, accepts, contentType, timeout).ConfigureAwait(false); return response.Body; } diff --git a/Octokit/Http/Connection.cs b/Octokit/Http/Connection.cs index c9837c6f..ac997f7c 100644 --- a/Octokit/Http/Connection.cs +++ b/Octokit/Http/Connection.cs @@ -451,14 +451,7 @@ namespace Octokit { Ensure.ArgumentNotNull(uri, "uri"); - var response = await SendData( - uri, - HttpMethod.Delete, - null, - null, - null, - CancellationToken.None, - twoFactorAuthenticationCode).ConfigureAwait(false); + var response = await SendData(uri, HttpMethod.Delete, null, null, null, CancellationToken.None, twoFactorAuthenticationCode).ConfigureAwait(false); return response.HttpResponse.StatusCode; } From 49f246f15b3c78db72b64666cbd1e5ca8f67c029 Mon Sep 17 00:00:00 2001 From: Elhamer Date: Thu, 7 Apr 2016 15:01:58 +0100 Subject: [PATCH 084/123] Fix a broken link * Fix a broken link (after merging/deleting the rewrite-contributing branch) --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 64a9bb71..f55ffc71 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -123,7 +123,7 @@ flagged as a spammer. ### Testing Documentation If you are making changes to the documentation for Octokit, you can test these -changes locally using the [guide](https://github.com/shiftkey/octokit.net/blob/rewrite-contributing/docs/contributing.md) +changes locally using the [guide](https://github.com/octokit/octokit.net/blob/master/docs/contributing.md) under the `docs` folder. ### Submitting Changes From cdd46465dbe8002377bc710cb8356d16197a519e Mon Sep 17 00:00:00 2001 From: Devesh Khandelwal Date: Sun, 10 Apr 2016 23:37:18 +0530 Subject: [PATCH 085/123] Add custom exception for the HTTP 451 response (#1239) * Add HTTP 451: Legal Takedown Exception. * Add LegalRestrictionException in HandleErrors. * Cast 451 to HttpStatusCode and include exception in csproj files. * Tests added and "FixProjects". * Fix: 403 -> 451 in 451Tests. --- .../LegalRestrictionExceptionTests.cs | 19 +++++ Octokit.Tests/Octokit.Tests.csproj | 1 + .../Exceptions/LegalRestrictionException.cs | 73 +++++++++++++++++++ Octokit/Http/Connection.cs | 3 +- Octokit/Octokit-Mono.csproj | 1 + Octokit/Octokit-MonoAndroid.csproj | 3 +- Octokit/Octokit-Monotouch.csproj | 3 +- Octokit/Octokit-Portable.csproj | 1 + Octokit/Octokit-netcore45.csproj | 1 + Octokit/Octokit.csproj | 1 + 10 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 Octokit.Tests/Exceptions/LegalRestrictionExceptionTests.cs create mode 100644 Octokit/Exceptions/LegalRestrictionException.cs diff --git a/Octokit.Tests/Exceptions/LegalRestrictionExceptionTests.cs b/Octokit.Tests/Exceptions/LegalRestrictionExceptionTests.cs new file mode 100644 index 00000000..c6190cea --- /dev/null +++ b/Octokit.Tests/Exceptions/LegalRestrictionExceptionTests.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using System.Net; +using Octokit.Internal; +using Xunit; + +namespace Octokit.Tests.Exceptions +{ + public class LegalRestrictionExceptionTests + { + [Fact] + public void HasDefaultMessage() + { + var response = new Response((HttpStatusCode)451, null, new Dictionary(), "application/json"); + var legalRestrictionException = new LegalRestrictionException(response); + + Assert.Equal("Resource taken down due to a DMCA notice.", legalRestrictionException.Message); + } + } +} \ No newline at end of file diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 8aee294e..1ba8aca1 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -136,6 +136,7 @@ + diff --git a/Octokit/Exceptions/LegalRestrictionException.cs b/Octokit/Exceptions/LegalRestrictionException.cs new file mode 100644 index 00000000..df115d4d --- /dev/null +++ b/Octokit/Exceptions/LegalRestrictionException.cs @@ -0,0 +1,73 @@ +using System; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Net; +using System.Runtime.Serialization; + +namespace Octokit +{ + /// + /// Represents a HTTP 451 - Unavailable For Legal Reasons response returned from the API. + /// This will returned if GitHub has been asked to takedown the requested resource due to + /// a DMCA takedown. + /// +#if !NETFX_CORE + [Serializable] +#endif + [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", + Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] + public class LegalRestrictionException : ApiException + { + public override string Message + { + get { return ApiErrorMessageSafe ?? "Resource taken down due to a DMCA notice."; } + } + + /// + /// Constructs an instance of LegalRestrictionException + /// + /// The HTTP payload from the server + public LegalRestrictionException(IResponse response) : this(response, null) + { + } + + /// + /// Constructs an instance of LegalRestrictionException + /// + /// The exception message + /// The http status code returned by the response + public LegalRestrictionException(string message, HttpStatusCode statusCode) : base(message, statusCode) + { + } + + /// + /// Constructs an instance of LegalRestrictionException + /// + /// The HTTP payload from the server + /// The inner exception + public LegalRestrictionException(IResponse response, Exception innerException) + : base(response, innerException) + { + Debug.Assert(response != null && response.StatusCode == (HttpStatusCode)451, + "LegalRestrictionException created with wrong status code"); + } + +#if !NETFX_CORE + /// + /// Constructs an instance of LegalRestrictionException + /// + /// + /// The that holds the + /// serialized object data about the exception being thrown. + /// + /// + /// The that contains + /// contextual information about the source or destination. + /// + protected LegalRestrictionException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } +#endif + } +} diff --git a/Octokit/Http/Connection.cs b/Octokit/Http/Connection.cs index ac997f7c..ed5dd957 100644 --- a/Octokit/Http/Connection.cs +++ b/Octokit/Http/Connection.cs @@ -568,7 +568,8 @@ namespace Octokit { HttpStatusCode.Unauthorized, GetExceptionForUnauthorized }, { HttpStatusCode.Forbidden, GetExceptionForForbidden }, { HttpStatusCode.NotFound, response => new NotFoundException(response) }, - { (HttpStatusCode)422, response => new ApiValidationException(response) } + { (HttpStatusCode)422, response => new ApiValidationException(response) }, + { (HttpStatusCode)451, response => new LegalRestrictionException(response) } }; static void HandleErrors(IResponse response) diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index abbfe348..4b28ca06 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -458,6 +458,7 @@ + \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index 60896d14..4396b3c8 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -467,6 +467,7 @@ + - + \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index 41d2a7e0..10562bbe 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -463,7 +463,8 @@ + - + \ No newline at end of file diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj index 0f950019..17259fe6 100644 --- a/Octokit/Octokit-Portable.csproj +++ b/Octokit/Octokit-Portable.csproj @@ -455,6 +455,7 @@ + diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index 3cfdc341..73e36516 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -462,6 +462,7 @@ + diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index f6004fb9..f4944f25 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -91,6 +91,7 @@ + From d149b342143bc7b051fe8b35122dfa110aba7e42 Mon Sep 17 00:00:00 2001 From: Elhamer Date: Sun, 10 Apr 2016 19:51:55 +0100 Subject: [PATCH 086/123] Add ApiOption overloads to methods on IGistCommentsClient (#1260) * Add GetAllForGist with apiOption overload to IGistCommentsClient + implementation * Add GetAllForGist overload + implementation * Add RequestsCorrectUrlWithApiOptions unit test * One more test to the GistCommentsClient * Ensure argument is not null or empty * Clean up GistCommentsClientTests class * Implement Integration test for the GetAllForGist method * Clean up --- .../Clients/IObservableGistCommentsClient.cs | 9 + .../Clients/ObservableGistCommentsClient.cs | 19 +- .../Octokit.Tests.Integration.csproj | 1 + .../ObservableGistCommentsClientTests.cs | 86 ++++++++ .../Clients/GistCommentsClientTests.cs | 196 ++++++++++-------- Octokit/Clients/GistCommentsClient.cs | 19 +- Octokit/Clients/IGistCommentsClient.cs | 9 + 7 files changed, 255 insertions(+), 84 deletions(-) create mode 100644 Octokit.Tests.Integration/Reactive/ObservableGistCommentsClientTests.cs diff --git a/Octokit.Reactive/Clients/IObservableGistCommentsClient.cs b/Octokit.Reactive/Clients/IObservableGistCommentsClient.cs index be577f16..ea817b2f 100644 --- a/Octokit.Reactive/Clients/IObservableGistCommentsClient.cs +++ b/Octokit.Reactive/Clients/IObservableGistCommentsClient.cs @@ -25,6 +25,15 @@ namespace Octokit.Reactive /// IObservable{GistComment}. IObservable GetAllForGist(string gistId); + /// + /// Gets all comments for the gist with the specified id. + /// + /// http://developer.github.com/v3/gists/comments/#list-comments-on-a-gist + /// The id of the gist + /// Options for changing the API response + /// IObservable{GistComment}. + IObservable GetAllForGist(string gistId, ApiOptions options); + /// /// Creates a comment for the gist with the specified id. /// diff --git a/Octokit.Reactive/Clients/ObservableGistCommentsClient.cs b/Octokit.Reactive/Clients/ObservableGistCommentsClient.cs index 7dc639bf..57165687 100644 --- a/Octokit.Reactive/Clients/ObservableGistCommentsClient.cs +++ b/Octokit.Reactive/Clients/ObservableGistCommentsClient.cs @@ -38,7 +38,24 @@ namespace Octokit.Reactive /// IObservable{GistComment}. public IObservable GetAllForGist(string gistId) { - return _connection.GetAndFlattenAllPages(ApiUrls.GistComments(gistId)); + Ensure.ArgumentNotNullOrEmptyString(gistId, "gistId"); + + return GetAllForGist(gistId, ApiOptions.None); + } + + /// + /// Gets all comments for the gist with the specified id. + /// + /// http://developer.github.com/v3/gists/comments/#list-comments-on-a-gist + /// The id of the gist + /// Options for changing the API response + /// IObservable{GistComment}. + public IObservable GetAllForGist(string gistId, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(gistId, "gistId"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.GistComments(gistId), options); } /// diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 9e4162f0..f79e88e2 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -139,6 +139,7 @@ + diff --git a/Octokit.Tests.Integration/Reactive/ObservableGistCommentsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableGistCommentsClientTests.cs new file mode 100644 index 00000000..1f350dbe --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableGistCommentsClientTests.cs @@ -0,0 +1,86 @@ +using System.Reactive.Linq; +using System.Threading.Tasks; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Integration.Reactive +{ + public class ObservableGistCommentsClientTests + { + public class TheGetAllForGistMethod + { + readonly ObservableGistCommentsClient _gistCommentsClient; + const string gistId = "7783a2c14a15a2e3c93b"; + + public TheGetAllForGistMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _gistCommentsClient = new ObservableGistCommentsClient(github); + } + + [IntegrationTest] + public async Task ReturnsGistComments() + { + var comments = await _gistCommentsClient.GetAllForGist(gistId).ToList(); + + Assert.NotEmpty(comments); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfGistCommentsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var comments = await _gistCommentsClient.GetAllForGist(gistId, options).ToList(); + + Assert.Equal(5, comments.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfGistCommentsWithStart() + { + var options = new ApiOptions + { + PageSize = 4, + PageCount = 1, + StartPage = 2 + }; + + var comments = await _gistCommentsClient.GetAllForGist(gistId, options).ToList(); + + Assert.Equal(4, comments.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 4, + PageCount = 1 + }; + + var firstCommentsPage = await _gistCommentsClient.GetAllForGist(gistId, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 4, + PageCount = 1, + StartPage = 2 + }; + + var secondCommentsPage = await _gistCommentsClient.GetAllForGist(gistId, skipStartOptions).ToList(); + + Assert.NotEqual(firstCommentsPage[0].Id, secondCommentsPage[0].Id); + Assert.NotEqual(firstCommentsPage[1].Id, secondCommentsPage[1].Id); + Assert.NotEqual(firstCommentsPage[2].Id, secondCommentsPage[2].Id); + Assert.NotEqual(firstCommentsPage[3].Id, secondCommentsPage[3].Id); + } + } + } +} diff --git a/Octokit.Tests/Clients/GistCommentsClientTests.cs b/Octokit.Tests/Clients/GistCommentsClientTests.cs index 7689dcc4..66b33d38 100644 --- a/Octokit.Tests/Clients/GistCommentsClientTests.cs +++ b/Octokit.Tests/Clients/GistCommentsClientTests.cs @@ -1,108 +1,140 @@ using System; using System.Threading.Tasks; using NSubstitute; -using Octokit; -using Octokit.Tests.Helpers; using Xunit; -public class GistCommentsClientTests +namespace Octokit.Tests.Clients { - public class TheCtor + public class GistCommentsClientTests { - [Fact] - public void EnsuresArgument() + public class TheCtor { - Assert.Throws(() => new GistCommentsClient(null)); - } - } - - public class TheGetMethod - { - [Fact] - public async Task RequestsCorrectUrl() - { - var connection = Substitute.For(); - var client = new GistCommentsClient(connection); - - await client.Get("24", 1337); - - connection.Received().Get(Arg.Is(u => u.ToString() == "gists/24/comments/1337")); - } - } - - public class TheGetForGistMethod - { - [Fact] - public async Task RequestsCorrectUrl() - { - var connection = Substitute.For(); - var client = new GistCommentsClient(connection); - - await client.GetAllForGist("24"); - - connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/24/comments")); - } - } - - public class TheCreateMethod - { - [Fact] - public async Task EnsuresNonNullArguments() - { - var client = new GistCommentsClient(Substitute.For()); - - await Assert.ThrowsAsync(() => client.Create("24", null)); - await Assert.ThrowsAsync(() => client.Create("24", "")); + [Fact] + public void EnsuresArgument() + { + Assert.Throws(() => new GistCommentsClient(null)); + } } - [Fact] - public async Task PostsToCorrectUrl() + public class TheGetMethod { - var comment = "This is a comment."; - var connection = Substitute.For(); - var client = new GistCommentsClient(connection); + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new GistCommentsClient(connection); - await client.Create("24", comment); + await client.Get("24", 1337); - connection.Received().Post(Arg.Is(u => u.ToString() == "gists/24/comments"), Arg.Is(x => x.Body == comment)); - } - } - - public class TheUpdateMethod - { - [Fact] - public async Task EnsuresNonNullArguments() - { - var client = new GistCommentsClient(Substitute.For()); - - await Assert.ThrowsAsync(() => client.Update("24", 1337, null)); - await Assert.ThrowsAsync(() => client.Update("24", 1337, "")); + connection.Received().Get(Arg.Is(u => u.ToString() == "gists/24/comments/1337")); + } } - [Fact] - public async Task PostsToCorrectUrl() + public class TheGetAllForGistMethod { - var comment = "This is a comment."; - var connection = Substitute.For(); - var client = new GistCommentsClient(connection); + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new GistCommentsClient(connection); - await client.Update("24", 1337, comment); + await client.GetAllForGist("24"); - connection.Received().Patch(Arg.Is(u => u.ToString() == "gists/24/comments/1337"), Arg.Is(x => x.Body == comment)); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/24/comments"), Args.ApiOptions); + } + + [Fact] + public async Task RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new GistCommentsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + await client.GetAllForGist("24", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/24/comments"), options); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new GistCommentsClient(connection); + + await Assert.ThrowsAsync(() => client.GetAllForGist(null)); + await Assert.ThrowsAsync(() => client.GetAllForGist("")); + await Assert.ThrowsAsync(() => client.GetAllForGist("24", null)); + await Assert.ThrowsAsync(() => client.GetAllForGist("", ApiOptions.None)); + + } } - } - public class TheDeleteMethod - { - [Fact] - public async Task PostsToCorrectUrl() + public class TheCreateMethod { - var connection = Substitute.For(); - var client = new GistCommentsClient(connection); + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new GistCommentsClient(Substitute.For()); - await client.Delete("24", 1337); + await Assert.ThrowsAsync(() => client.Create("24", null)); + await Assert.ThrowsAsync(() => client.Create("24", "")); + } - connection.Received().Delete(Arg.Is(u => u.ToString() == "gists/24/comments/1337")); + [Fact] + public async Task PostsToCorrectUrl() + { + var comment = "This is a comment."; + var connection = Substitute.For(); + var client = new GistCommentsClient(connection); + + await client.Create("24", comment); + + connection.Received().Post(Arg.Is(u => u.ToString() == "gists/24/comments"), Arg.Is(x => x.Body == comment)); + } + } + + public class TheUpdateMethod + { + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new GistCommentsClient(Substitute.For()); + + await Assert.ThrowsAsync(() => client.Update("24", 1337, null)); + await Assert.ThrowsAsync(() => client.Update("24", 1337, "")); + } + + [Fact] + public async Task PostsToCorrectUrl() + { + var comment = "This is a comment."; + var connection = Substitute.For(); + var client = new GistCommentsClient(connection); + + await client.Update("24", 1337, comment); + + connection.Received().Patch(Arg.Is(u => u.ToString() == "gists/24/comments/1337"), Arg.Is(x => x.Body == comment)); + } + } + + public class TheDeleteMethod + { + [Fact] + public async Task PostsToCorrectUrl() + { + var connection = Substitute.For(); + var client = new GistCommentsClient(connection); + + await client.Delete("24", 1337); + + connection.Received().Delete(Arg.Is(u => u.ToString() == "gists/24/comments/1337")); + } } } } \ No newline at end of file diff --git a/Octokit/Clients/GistCommentsClient.cs b/Octokit/Clients/GistCommentsClient.cs index 47487159..23eccda0 100644 --- a/Octokit/Clients/GistCommentsClient.cs +++ b/Octokit/Clients/GistCommentsClient.cs @@ -39,7 +39,24 @@ namespace Octokit /// Task{IReadOnlyList{GistComment}}. public Task> GetAllForGist(string gistId) { - return ApiConnection.GetAll(ApiUrls.GistComments(gistId)); + Ensure.ArgumentNotNullOrEmptyString(gistId, "gistId"); + + return GetAllForGist(gistId, ApiOptions.None); + } + + /// + /// Gets all comments for the gist with the specified id. + /// + /// http://developer.github.com/v3/gists/comments/#list-comments-on-a-gist + /// The id of the gist + /// Options for changing the API response + /// Task{IReadOnlyList{GistComment}}. + public Task> GetAllForGist(string gistId, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(gistId, "gistId"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.GistComments(gistId), options); } /// diff --git a/Octokit/Clients/IGistCommentsClient.cs b/Octokit/Clients/IGistCommentsClient.cs index bf91680c..30867774 100644 --- a/Octokit/Clients/IGistCommentsClient.cs +++ b/Octokit/Clients/IGistCommentsClient.cs @@ -31,6 +31,15 @@ namespace Octokit /// Task{IReadOnlyList{GistComment}}. Task> GetAllForGist(string gistId); + /// + /// Gets all comments for the gist with the specified id. + /// + /// http://developer.github.com/v3/gists/comments/#list-comments-on-a-gist + /// The id of the gist + /// Options for changing the API response + /// Task{IReadOnlyList{GistComment}}. + Task> GetAllForGist(string gistId, ApiOptions options); + /// /// Creates a comment for the gist with the specified id. /// From 4ae6000ac16e6c1377153d8677764ca553f65417 Mon Sep 17 00:00:00 2001 From: Elhamer Date: Sun, 10 Apr 2016 22:23:46 +0100 Subject: [PATCH 087/123] Add overloads to the GetAll methods in the IEventsClient (#1240) * Add overloads to the GetAll methods in the IEventsClient Interface * Implement GetAll* overload methods in the EventClient class to allow ApiOptions as parameter * Fix the failling tests after refactoring the GetAll* methds * Add the overload GetAlls methods to the IObservableEventsClient interface * Implement the GetAll* overloads in the ObservableEventsClient class * Fix the failling tests after refactoring the GetAll* methods * Make sure the ApiOtions arn't null in the newly added overload methods + implement RequestsCorrectUrlWithApiOptions test * Implement unit tests for the EventClient's GetAll* overload methods * Add missing test cases in the ReleaseClientTest's EnsuresNonNullArguments test * Fix the last commit * Add the ObservableEventsClientTests class * Add an ArgumentException check to the EnsuresArgumentsNotNull methodS + some clean up * Events GetAll Method Integration Tests * Implement the GetAll* IntegrationTests * TheGetAllForAnOrganizationMethod Integrations test [WIP] * Fix a failing integration test * Proper way to call Organization and UserName in the integration test * Remove .swp file * Fixe after merging * Add more checks to EnsuresNonNullArguments --- .../Clients/IObservableEventsClient.cs | 101 +++ .../Clients/ObservableEventsClient.cs | 175 ++++- .../Octokit.Tests.Integration.csproj | 1 + .../Reactive/ObservableEventsClientTests.cs | 699 ++++++++++++++++++ Octokit.Tests/Clients/EventsClientTests.cs | 207 +++++- Octokit.Tests/Clients/ReleasesClientTests.cs | 4 + .../Reactive/ObservableEventsClientTests.cs | 18 +- Octokit/Clients/EventsClient.cs | 175 ++++- Octokit/Clients/IEventsClient.cs | 103 +++ 9 files changed, 1447 insertions(+), 36 deletions(-) create mode 100644 Octokit.Tests.Integration/Reactive/ObservableEventsClientTests.cs diff --git a/Octokit.Reactive/Clients/IObservableEventsClient.cs b/Octokit.Reactive/Clients/IObservableEventsClient.cs index 5c037fdb..50f49490 100644 --- a/Octokit.Reactive/Clients/IObservableEventsClient.cs +++ b/Octokit.Reactive/Clients/IObservableEventsClient.cs @@ -14,6 +14,16 @@ namespace Octokit.Reactive [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] IObservable GetAll(); + /// + /// Gets all the public events + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events + /// + /// Options for changing the API response + /// All the public s for the particular user. + IObservable GetAll(ApiOptions options); + /// /// Gets all the events for a given repository /// @@ -25,6 +35,18 @@ namespace Octokit.Reactive /// All the s for the particular repository. IObservable GetAllForRepository(string owner, string name); + /// + /// Gets all the events for a given repository + /// + /// + /// http://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the particular repository. + IObservable GetAllForRepository(string owner, string name, ApiOptions options); + /// /// Gets all the events for a given repository network /// @@ -36,6 +58,18 @@ namespace Octokit.Reactive /// All the s for the particular repository network. IObservable GetAllForRepositoryNetwork(string owner, string name); + /// + /// Gets all the events for a given repository network + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-a-network-of-repositories + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the particular repository network. + IObservable GetAllForRepositoryNetwork(string owner, string name, ApiOptions options); + /// /// Gets all the events for a given organization /// @@ -46,6 +80,17 @@ namespace Octokit.Reactive /// All the s for the particular organization. IObservable GetAllForOrganization(string organization); + /// + /// Gets all the events for a given organization + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-an-organization + /// + /// The name of the organization + /// Options for changing the API response + /// All the s for the particular organization. + IObservable GetAllForOrganization(string organization, ApiOptions options); + /// /// Gets all the events that have been received by a given user. /// @@ -56,6 +101,17 @@ namespace Octokit.Reactive /// All the s that a particular user has received. IObservable GetAllUserReceived(string user); + /// + /// Gets all the events that have been received by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-that-a-user-has-received + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has received. + IObservable GetAllUserReceived(string user, ApiOptions options); + /// /// Gets all the events that have been received by a given user. /// @@ -66,6 +122,17 @@ namespace Octokit.Reactive /// All the s that a particular user has received. IObservable GetAllUserReceivedPublic(string user); + /// + /// Gets all the events that have been received by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-that-a-user-has-received + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has received. + IObservable GetAllUserReceivedPublic(string user, ApiOptions options); + /// /// Gets all the events that have been performed by a given user. /// @@ -76,6 +143,17 @@ namespace Octokit.Reactive /// All the s that a particular user has performed. IObservable GetAllUserPerformed(string user); + /// + /// Gets all the events that have been performed by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-performed-by-a-user + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has performed. + IObservable GetAllUserPerformed(string user, ApiOptions options); + /// /// Gets all the public events that have been performed by a given user. /// @@ -86,6 +164,17 @@ namespace Octokit.Reactive /// All the public s that a particular user has performed. IObservable GetAllUserPerformedPublic(string user); + /// + /// Gets all the public events that have been performed by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-performed-by-a-user + /// + /// The login of the user + /// Options for changing the API response + /// All the public s that a particular user has performed. + IObservable GetAllUserPerformedPublic(string user, ApiOptions options); + /// /// Gets all the events that are associated with an organization. /// @@ -96,5 +185,17 @@ namespace Octokit.Reactive /// The name of the organization /// All the public s that are associated with an organization. IObservable GetAllForAnOrganization(string user, string organization); + + /// + /// Gets all the events that are associated with an organization. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-for-an-organization + /// + /// The login of the user + /// The name of the organization + /// Options for changing the API response + /// All the public s that are associated with an organization. + IObservable GetAllForAnOrganization(string user, string organization, ApiOptions options); } } \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservableEventsClient.cs b/Octokit.Reactive/Clients/ObservableEventsClient.cs index ad871c29..18de33fd 100644 --- a/Octokit.Reactive/Clients/ObservableEventsClient.cs +++ b/Octokit.Reactive/Clients/ObservableEventsClient.cs @@ -23,7 +23,22 @@ namespace Octokit.Reactive /// All the public s for the particular user. public IObservable GetAll() { - return _connection.GetAndFlattenAllPages(ApiUrls.Events()); + return GetAll(ApiOptions.None); + } + + /// + /// Gets all the public events + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events + /// + /// Options for changing the API response + /// All the public s for the particular user. + public IObservable GetAll(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.Events(), options); } /// @@ -40,7 +55,26 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return _connection.GetAndFlattenAllPages(ApiUrls.IssuesEvents(owner, name)); + return GetAllForRepository(owner, name, ApiOptions.None); + } + + /// + /// Gets all the events for a given repository + /// + /// + /// http://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the particular repository. + public IObservable GetAllForRepository(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.IssuesEvents(owner, name), options); } /// @@ -57,7 +91,26 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return _connection.GetAndFlattenAllPages(ApiUrls.NetworkEvents(owner, name)); + return GetAllForRepositoryNetwork(owner, name, ApiOptions.None); + } + + /// + /// Gets all the events for a given repository network + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-a-network-of-repositories + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the particular repository network. + public IObservable GetAllForRepositoryNetwork(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.NetworkEvents(owner, name), options); } /// @@ -72,7 +125,24 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); - return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationEvents(organization)); + return GetAllForOrganization(organization, ApiOptions.None); + } + + /// + /// Gets all the events for a given organization + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-an-organization + /// + /// The name of the organization + /// Options for changing the API response + /// All the s for the particular organization. + public IObservable GetAllForOrganization(string organization, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationEvents(organization), options); } /// @@ -87,7 +157,24 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return _connection.GetAndFlattenAllPages(ApiUrls.ReceivedEvents(user)); + return GetAllUserReceived(user, ApiOptions.None); + } + + /// + /// Gets all the events that have been received by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-that-a-user-has-received + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has received. + public IObservable GetAllUserReceived(string user, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.ReceivedEvents(user), options); } /// @@ -102,7 +189,24 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return _connection.GetAndFlattenAllPages(ApiUrls.ReceivedEvents(user, true)); + return GetAllUserReceivedPublic(user, ApiOptions.None); + } + + /// + /// Gets all the events that have been received by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-that-a-user-has-received + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has received. + public IObservable GetAllUserReceivedPublic(string user, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.ReceivedEvents(user, true), options); } /// @@ -117,7 +221,24 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return _connection.GetAndFlattenAllPages(ApiUrls.PerformedEvents(user)); + return GetAllUserPerformed(user, ApiOptions.None); + } + + /// + /// Gets all the events that have been performed by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-performed-by-a-user + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has performed. + public IObservable GetAllUserPerformed(string user, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.PerformedEvents(user), options); } /// @@ -132,7 +253,24 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return _connection.GetAndFlattenAllPages(ApiUrls.PerformedEvents(user, true)); + return GetAllUserPerformedPublic(user, ApiOptions.None); + } + + /// + /// Gets all the public events that have been performed by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-performed-by-a-user + /// + /// The login of the user + /// Options for changing the API response + /// All the public s that a particular user has performed. + public IObservable GetAllUserPerformedPublic(string user, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.PerformedEvents(user, true), options); } /// @@ -149,7 +287,26 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(user, "user"); Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); - return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationEvents(user, organization)); + return GetAllForAnOrganization(user, organization, ApiOptions.None); + } + + /// + /// Gets all the events that are associated with an organization. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-for-an-organization + /// + /// The login of the user + /// The name of the organization + /// Options for changing the API response + /// All the public s that are associated with an organization. + public IObservable GetAllForAnOrganization(string user, string organization, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.OrganizationEvents(user, organization),options); } } } diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index f79e88e2..5cd0ff60 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -139,6 +139,7 @@ + diff --git a/Octokit.Tests.Integration/Reactive/ObservableEventsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableEventsClientTests.cs new file mode 100644 index 00000000..3308120c --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableEventsClientTests.cs @@ -0,0 +1,699 @@ +using System.Linq; +using System.Reactive.Linq; +using System.Threading.Tasks; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Integration.Reactive +{ + public class ObservableEventsClientTests + { + public class TheGetAllMethod + { + readonly ObservableEventsClient _eventsClient; + + public TheGetAllMethod() + { + _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient()); + } + [IntegrationTest] + public async Task ReturnsEvents() + { + var events = await _eventsClient.GetAll().ToList(); + + Assert.NotEmpty(events); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfEventsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var events = await _eventsClient.GetAll(options).ToList(); + + Assert.Equal(5, events.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfEventsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var events = await _eventsClient.GetAll(options).ToList(); + + Assert.Equal(5, events.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctEventsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstEventsPage = await _eventsClient.GetAll(startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondEventsPage = await _eventsClient.GetAll(skipStartOptions).ToList(); + + Assert.NotEqual(firstEventsPage[0].Id, secondEventsPage[0].Id); + Assert.NotEqual(firstEventsPage[1].Id, secondEventsPage[1].Id); + Assert.NotEqual(firstEventsPage[2].Id, secondEventsPage[2].Id); + Assert.NotEqual(firstEventsPage[3].Id, secondEventsPage[3].Id); + Assert.NotEqual(firstEventsPage[4].Id, secondEventsPage[4].Id); + } + + } + + public class TheGetAllForRepositoryMethod + { + + readonly ObservableEventsClient _eventsClient; + const string owner = "octokit"; + const string name = "octokit.net"; + + public TheGetAllForRepositoryMethod() + { + _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient()); + } + [IntegrationTest] + public async Task ReturnsRepositoryEvents() + { + var repositoryEvents = await _eventsClient.GetAllForRepository(owner, name).ToList(); + + Assert.NotEmpty(repositoryEvents); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfRepositoryEventsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var repositoryEvents = await _eventsClient.GetAllForRepository(owner, name, options).ToList(); + + Assert.Equal(5, repositoryEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfRepositoryEventsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var repositoryEvents = await _eventsClient.GetAllForRepository(owner, name, options).ToList(); + + Assert.Equal(5, repositoryEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctRepositoryEventsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstRepositoryEventsPage = await _eventsClient.GetAllForRepository(owner, name, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondRepositoryEventsPage = await _eventsClient.GetAllForRepository(owner, name, skipStartOptions).ToList(); + + Assert.NotEqual(firstRepositoryEventsPage[0].Id, secondRepositoryEventsPage[0].Id); + Assert.NotEqual(firstRepositoryEventsPage[1].Id, secondRepositoryEventsPage[1].Id); + Assert.NotEqual(firstRepositoryEventsPage[2].Id, secondRepositoryEventsPage[2].Id); + Assert.NotEqual(firstRepositoryEventsPage[3].Id, secondRepositoryEventsPage[3].Id); + Assert.NotEqual(firstRepositoryEventsPage[4].Id, secondRepositoryEventsPage[4].Id); + } + + } + + public class TheGetAllForRepositoryNetworkMethod + { + readonly ObservableEventsClient _eventsClient; + const string owner = "octokit"; + const string name = "octokit.net"; + + public TheGetAllForRepositoryNetworkMethod() + { + _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient()); + } + [IntegrationTest] + public async Task ReturnsRepositoryNetworkEvents() + { + var repositoryNetworkEvents = await _eventsClient.GetAllForRepositoryNetwork(owner, name).ToList(); + + Assert.NotEmpty(repositoryNetworkEvents); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfRepositoryNetworkEventsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var repositoryNetworkEvents = await _eventsClient.GetAllForRepositoryNetwork(owner, name, options).ToList(); + + Assert.Equal(5, repositoryNetworkEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfRepositoryNetworkEventsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var repositoryNetworkEvents = await _eventsClient.GetAllForRepositoryNetwork(owner, name, options).ToList(); + + Assert.Equal(5, repositoryNetworkEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctRepositoryNetworkEventsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstRepositoryNetworkEventsPage = await _eventsClient.GetAllForRepositoryNetwork(owner, name, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondRepositoryNetworkEventsPage = await _eventsClient.GetAllForRepositoryNetwork(owner, name, skipStartOptions).ToList(); + + Assert.NotEqual(firstRepositoryNetworkEventsPage[0].Id, secondRepositoryNetworkEventsPage[0].Id); + Assert.NotEqual(firstRepositoryNetworkEventsPage[1].Id, secondRepositoryNetworkEventsPage[1].Id); + Assert.NotEqual(firstRepositoryNetworkEventsPage[2].Id, secondRepositoryNetworkEventsPage[2].Id); + Assert.NotEqual(firstRepositoryNetworkEventsPage[3].Id, secondRepositoryNetworkEventsPage[3].Id); + Assert.NotEqual(firstRepositoryNetworkEventsPage[4].Id, secondRepositoryNetworkEventsPage[4].Id); + } + + } + + public class TheGetAllForOrganizationMethod + { + + readonly ObservableEventsClient _eventsClient; + const string organization = "octokit"; + + public TheGetAllForOrganizationMethod() + { + _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient()); + } + + [IntegrationTest] + public async Task ReturnsOrganizationEvents() + { + var organizationEvents = await _eventsClient.GetAllForOrganization(organization).ToList(); + + Assert.NotEmpty(organizationEvents); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfOrganizationEventsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var organizationEvents = await _eventsClient.GetAllForOrganization(organization, options).ToList(); + + Assert.Equal(5, organizationEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfOrganizationEventsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var organizationEvents = await _eventsClient.GetAllForOrganization(organization, options).ToList(); + + Assert.Equal(5, organizationEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctOrganizationEventsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstOrganizationEventsPage = await _eventsClient.GetAllForOrganization(organization, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondOrganizationEventsPage = await _eventsClient.GetAllForOrganization(organization, skipStartOptions).ToList(); + + Assert.NotEqual(firstOrganizationEventsPage[0].Id, secondOrganizationEventsPage[0].Id); + Assert.NotEqual(firstOrganizationEventsPage[1].Id, secondOrganizationEventsPage[1].Id); + Assert.NotEqual(firstOrganizationEventsPage[2].Id, secondOrganizationEventsPage[2].Id); + Assert.NotEqual(firstOrganizationEventsPage[3].Id, secondOrganizationEventsPage[3].Id); + Assert.NotEqual(firstOrganizationEventsPage[4].Id, secondOrganizationEventsPage[4].Id); + } + + } + + public class TheGetAllUserReceivedMethod + { + readonly ObservableEventsClient _eventsClient; + const string user = "shiftkey"; + + public TheGetAllUserReceivedMethod() + { + _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient()); + } + + [IntegrationTest] + public async Task ReturnsUserReceivedEvents() + { + var userReceivedEvents = await _eventsClient.GetAllUserReceived(user).ToList(); + + Assert.NotEmpty(userReceivedEvents); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserReceivedEventsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var userReceivedEvents = await _eventsClient.GetAllUserReceived(user, options).ToList(); + + Assert.Equal(5, userReceivedEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserReceivedEventsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var userReceivedEvents = await _eventsClient.GetAllUserReceived(user, options).ToList(); + + Assert.Equal(5, userReceivedEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctUserReceivedEventsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstUserReceivedEventsPage = await _eventsClient.GetAllUserReceived(user, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondUserReceivedEventsPage = await _eventsClient.GetAllUserReceived(user, skipStartOptions).ToList(); + + Assert.NotEqual(firstUserReceivedEventsPage[0].Id, secondUserReceivedEventsPage[0].Id); + Assert.NotEqual(firstUserReceivedEventsPage[1].Id, secondUserReceivedEventsPage[1].Id); + Assert.NotEqual(firstUserReceivedEventsPage[2].Id, secondUserReceivedEventsPage[2].Id); + Assert.NotEqual(firstUserReceivedEventsPage[3].Id, secondUserReceivedEventsPage[3].Id); + Assert.NotEqual(firstUserReceivedEventsPage[4].Id, secondUserReceivedEventsPage[4].Id); + } + } + + public class TheGetAllUserReceivedPublicMethod + { + + readonly ObservableEventsClient _eventsClient; + const string user = "shiftkey"; + + public TheGetAllUserReceivedPublicMethod() + { + _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient()); + } + + [IntegrationTest] + public async Task ReturnsUserReceivedPublicEvents() + { + var userReceivedPublicEvents = await _eventsClient.GetAllUserReceivedPublic(user).ToList(); + + Assert.NotEmpty(userReceivedPublicEvents); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserReceivedPublicEventsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var userReceivedPublicEvents = await _eventsClient.GetAllUserReceivedPublic(user, options).ToList(); + + Assert.Equal(5, userReceivedPublicEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserReceivedPublicEventsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var userReceivedPublicEvents = await _eventsClient.GetAllUserReceivedPublic(user, options).ToList(); + + Assert.Equal(5, userReceivedPublicEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctUserReceivedPublicEventsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstUserReceivedPublicEventsPage = await _eventsClient.GetAllUserReceivedPublic(user, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondUserReceivedPublicEventsPage = await _eventsClient.GetAllUserReceivedPublic(user, skipStartOptions).ToList(); + + Assert.NotEqual(firstUserReceivedPublicEventsPage[0].Id, secondUserReceivedPublicEventsPage[0].Id); + Assert.NotEqual(firstUserReceivedPublicEventsPage[1].Id, secondUserReceivedPublicEventsPage[1].Id); + Assert.NotEqual(firstUserReceivedPublicEventsPage[2].Id, secondUserReceivedPublicEventsPage[2].Id); + Assert.NotEqual(firstUserReceivedPublicEventsPage[3].Id, secondUserReceivedPublicEventsPage[3].Id); + Assert.NotEqual(firstUserReceivedPublicEventsPage[4].Id, secondUserReceivedPublicEventsPage[4].Id); + } + + } + + public class TheGetAllUserPerformedMethod + { + readonly ObservableEventsClient _eventsClient; + const string user = "shiftkey"; + + public TheGetAllUserPerformedMethod() + { + _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient()); + } + + [IntegrationTest] + public async Task ReturnsUserPerformedEvents() + { + var userPerformedEvents = await _eventsClient.GetAllUserPerformed(user).ToList(); + + Assert.NotEmpty(userPerformedEvents); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserPerformedEventsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var userPerformedEvents = await _eventsClient.GetAllUserPerformed(user, options).ToList(); + + Assert.Equal(5, userPerformedEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserPerformedEventsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var userPerformedEvents = await _eventsClient.GetAllUserPerformed(user, options).ToList(); + + Assert.Equal(5, userPerformedEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctUserPerformedEventsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstUserPerformedEventsPage = await _eventsClient.GetAllUserPerformed(user, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondUserPerformedEventsPage = await _eventsClient.GetAllUserPerformed(user, skipStartOptions).ToList(); + + Assert.NotEqual(firstUserPerformedEventsPage[0].Id, secondUserPerformedEventsPage[0].Id); + Assert.NotEqual(firstUserPerformedEventsPage[1].Id, secondUserPerformedEventsPage[1].Id); + Assert.NotEqual(firstUserPerformedEventsPage[2].Id, secondUserPerformedEventsPage[2].Id); + Assert.NotEqual(firstUserPerformedEventsPage[3].Id, secondUserPerformedEventsPage[3].Id); + Assert.NotEqual(firstUserPerformedEventsPage[4].Id, secondUserPerformedEventsPage[4].Id); + } + + } + + public class TheGetAllUserPerformedPublicMethod + { + readonly ObservableEventsClient _eventsClient; + const string user = "shiftkey"; + + public TheGetAllUserPerformedPublicMethod() + { + _eventsClient = new ObservableEventsClient(Helper.GetAuthenticatedClient()); + } + + [IntegrationTest] + public async Task ReturnsUserPerformedPublicEvents() + { + var userPerformedPublicEvents = await _eventsClient.GetAllUserPerformedPublic(user).ToList(); + + Assert.NotEmpty(userPerformedPublicEvents); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserPerformedPublicEventsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var userPerformedPublicEvents = await _eventsClient.GetAllUserPerformedPublic(user, options).ToList(); + + Assert.Equal(5, userPerformedPublicEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserPerformedPublicEventsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var userPerformedPublicEvents = await _eventsClient.GetAllUserPerformedPublic(user, options).ToList(); + + Assert.Equal(5, userPerformedPublicEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctUserPerformedPublicEventsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstUserPerformedPublicEventsPage = await _eventsClient.GetAllUserPerformedPublic(user, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondUserPerformedPublicEventsPage = await _eventsClient.GetAllUserPerformedPublic(user, skipStartOptions).ToList(); + + Assert.NotEqual(firstUserPerformedPublicEventsPage[0].Id, secondUserPerformedPublicEventsPage[0].Id); + Assert.NotEqual(firstUserPerformedPublicEventsPage[1].Id, secondUserPerformedPublicEventsPage[1].Id); + Assert.NotEqual(firstUserPerformedPublicEventsPage[2].Id, secondUserPerformedPublicEventsPage[2].Id); + Assert.NotEqual(firstUserPerformedPublicEventsPage[3].Id, secondUserPerformedPublicEventsPage[3].Id); + Assert.NotEqual(firstUserPerformedPublicEventsPage[4].Id, secondUserPerformedPublicEventsPage[4].Id); + } + + } + + public class TheGetAllForAnOrganizationMethod + { + readonly ObservableEventsClient _eventsClient; + readonly string _organization; + readonly string _user; + + public TheGetAllForAnOrganizationMethod() + { + var github = Helper.GetAuthenticatedClient(); + _eventsClient = new ObservableEventsClient(github); + _user = Helper.UserName; + _organization = Helper.Organization; + } + + [IntegrationTest] + public async Task ReturnsUserOrganizationEvents() + { + var userOrganizationEvents = await _eventsClient.GetAllForAnOrganization(_user,_organization).ToList(); + + Assert.NotEmpty(userOrganizationEvents); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserOrganizationEventsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var userOrganizationEvents = await _eventsClient.GetAllForAnOrganization(_user, _organization, options).ToList(); + + Assert.Equal(5, userOrganizationEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserOrganizationEventsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var userOrganizationEvents = await _eventsClient.GetAllForAnOrganization(_user, _organization, options).ToList(); + + Assert.Equal(5, userOrganizationEvents.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctUserOrganizationEventsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstUserOrganizationEventsPage = await _eventsClient.GetAllForAnOrganization(_user, _organization, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondUserOrganizationEventsPage = await _eventsClient.GetAllForAnOrganization(_user, _organization, skipStartOptions).ToList(); + + Assert.NotEqual(firstUserOrganizationEventsPage[0].Id, secondUserOrganizationEventsPage[0].Id); + Assert.NotEqual(firstUserOrganizationEventsPage[1].Id, secondUserOrganizationEventsPage[1].Id); + Assert.NotEqual(firstUserOrganizationEventsPage[2].Id, secondUserOrganizationEventsPage[2].Id); + Assert.NotEqual(firstUserOrganizationEventsPage[3].Id, secondUserOrganizationEventsPage[3].Id); + Assert.NotEqual(firstUserOrganizationEventsPage[4].Id, secondUserOrganizationEventsPage[4].Id); + } + + } + } +} diff --git a/Octokit.Tests/Clients/EventsClientTests.cs b/Octokit.Tests/Clients/EventsClientTests.cs index 57437d82..3defac5b 100644 --- a/Octokit.Tests/Clients/EventsClientTests.cs +++ b/Octokit.Tests/Clients/EventsClientTests.cs @@ -24,7 +24,33 @@ namespace Octokit.Tests.Clients client.GetAll(); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "events")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "events"), Args.ApiOptions); + } + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new EventsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAll(options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "events"), options); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new EventsClient(connection); + + await Assert.ThrowsAsync(() => client.GetAll(null)); } } @@ -38,7 +64,25 @@ namespace Octokit.Tests.Clients client.GetAllForRepository("fake", "repo"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/events")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/events"), Args.ApiOptions); + } + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new EventsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + + client.GetAllForRepository("fake", "repo", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/events"), options); } [Fact] @@ -51,6 +95,9 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name")); await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null)); await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "")); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name",null)); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "",ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name", ApiOptions.None)); } } @@ -64,7 +111,25 @@ namespace Octokit.Tests.Clients client.GetAllForRepositoryNetwork("fake", "repo"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "networks/fake/repo/events")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "networks/fake/repo/events"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new EventsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAllForRepositoryNetwork("fake", "repo", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "networks/fake/repo/events"), options); } [Fact] @@ -77,6 +142,9 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAllForRepositoryNetwork("", "name")); await Assert.ThrowsAsync(() => client.GetAllForRepositoryNetwork("owner", null)); await Assert.ThrowsAsync(() => client.GetAllForRepositoryNetwork("owner", "")); + await Assert.ThrowsAsync(() => client.GetAllForRepositoryNetwork("owner", "name", null)); + await Assert.ThrowsAsync(() => client.GetAllForRepositoryNetwork("owner", "", ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAllForRepositoryNetwork("", "name", ApiOptions.None)); } } @@ -90,7 +158,25 @@ namespace Octokit.Tests.Clients client.GetAllForOrganization("fake"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/fake/events")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/fake/events"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new EventsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAllForOrganization("fake", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/fake/events"), options); } [Fact] @@ -101,6 +187,8 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAllForOrganization(null)); await Assert.ThrowsAsync(() => client.GetAllForOrganization("")); + await Assert.ThrowsAsync(() => client.GetAllForOrganization("fake", null)); + await Assert.ThrowsAsync(() => client.GetAllForOrganization("", ApiOptions.None)); } } @@ -114,7 +202,25 @@ namespace Octokit.Tests.Clients client.GetAllUserReceived("fake"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/received_events")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/received_events"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new EventsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAllUserReceived("fake", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/received_events"), options); } [Fact] @@ -125,6 +231,8 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAllUserReceived(null)); await Assert.ThrowsAsync(() => client.GetAllUserReceived("")); + await Assert.ThrowsAsync(() => client.GetAllUserReceived("fake", null)); + await Assert.ThrowsAsync(() => client.GetAllUserReceived("", ApiOptions.None)); } } @@ -138,7 +246,25 @@ namespace Octokit.Tests.Clients client.GetAllUserReceivedPublic("fake"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/received_events/public")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/received_events/public"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new EventsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAllUserReceivedPublic("fake", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/received_events/public"), options); } [Fact] @@ -149,6 +275,8 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAllUserReceivedPublic(null)); await Assert.ThrowsAsync(() => client.GetAllUserReceivedPublic("")); + await Assert.ThrowsAsync(() => client.GetAllUserReceivedPublic("fake", null)); + await Assert.ThrowsAsync(() => client.GetAllUserReceivedPublic("", ApiOptions.None)); } } @@ -162,7 +290,25 @@ namespace Octokit.Tests.Clients client.GetAllUserPerformed("fake"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/events")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/events"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new EventsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAllUserPerformed("fake", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/events"), options); } [Fact] @@ -173,6 +319,8 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAllUserPerformed(null)); await Assert.ThrowsAsync(() => client.GetAllUserPerformed("")); + await Assert.ThrowsAsync(() => client.GetAllUserPerformed("fake", null)); + await Assert.ThrowsAsync(() => client.GetAllUserPerformed("", ApiOptions.None)); } } @@ -186,7 +334,25 @@ namespace Octokit.Tests.Clients client.GetAllUserPerformedPublic("fake"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/events/public")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/events/public"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new EventsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAllUserPerformedPublic("fake", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/events/public"), options); } [Fact] @@ -197,6 +363,8 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAllUserPerformedPublic(null)); await Assert.ThrowsAsync(() => client.GetAllUserPerformedPublic("")); + await Assert.ThrowsAsync(() => client.GetAllUserPerformedPublic("fake",null)); + await Assert.ThrowsAsync(() => client.GetAllUserPerformedPublic("",ApiOptions.None)); } } @@ -210,7 +378,25 @@ namespace Octokit.Tests.Clients client.GetAllForAnOrganization("fake", "org"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/events/orgs/org")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/events/orgs/org"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new EventsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAllForAnOrganization("fake", "org", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/fake/events/orgs/org"), options); } [Fact] @@ -223,6 +409,9 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAllForAnOrganization("", "org")); await Assert.ThrowsAsync(() => client.GetAllForAnOrganization("fake", null)); await Assert.ThrowsAsync(() => client.GetAllForAnOrganization("fake", "")); + await Assert.ThrowsAsync(() => client.GetAllForAnOrganization("fake", "org", null)); + await Assert.ThrowsAsync(() => client.GetAllForAnOrganization("fake", "", ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAllForAnOrganization("", "org", ApiOptions.None)); } } diff --git a/Octokit.Tests/Clients/ReleasesClientTests.cs b/Octokit.Tests/Clients/ReleasesClientTests.cs index 10ce49a8..645ce6c2 100644 --- a/Octokit.Tests/Clients/ReleasesClientTests.cs +++ b/Octokit.Tests/Clients/ReleasesClientTests.cs @@ -51,8 +51,12 @@ namespace Octokit.Tests.Clients var releasesClient = new ReleasesClient(Substitute.For()); await Assert.ThrowsAsync(() => releasesClient.GetAll(null, "name")); + await Assert.ThrowsAsync(() => releasesClient.GetAll("", "name")); await Assert.ThrowsAsync(() => releasesClient.GetAll("owner", null)); + await Assert.ThrowsAsync(() => releasesClient.GetAll("owner", "")); await Assert.ThrowsAsync(() => releasesClient.GetAll("owner", "name", null)); + await Assert.ThrowsAsync(() => releasesClient.GetAll("", "name", ApiOptions.None)); + await Assert.ThrowsAsync(() => releasesClient.GetAll("owner", "", ApiOptions.None)); } } diff --git a/Octokit.Tests/Reactive/ObservableEventsClientTests.cs b/Octokit.Tests/Reactive/ObservableEventsClientTests.cs index 0c8d7e64..bc44a1fd 100644 --- a/Octokit.Tests/Reactive/ObservableEventsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableEventsClientTests.cs @@ -22,7 +22,7 @@ namespace Octokit.Tests.Reactive client.GetAll(); - gitHubClient.Connection.Received(1).Get>(new Uri("events", UriKind.Relative), null, null); + gitHubClient.Connection.Received(1).Get>(new Uri("events", UriKind.Relative), Args.EmptyDictionary, null); } } @@ -36,7 +36,7 @@ namespace Octokit.Tests.Reactive client.GetAllForRepository("fake", "repo"); - gitHubClient.Connection.Received(1).Get>(new Uri("repos/fake/repo/issues/events", UriKind.Relative), null, null); + gitHubClient.Connection.Received(1).Get>(new Uri("repos/fake/repo/issues/events", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] @@ -62,7 +62,7 @@ namespace Octokit.Tests.Reactive client.GetAllForRepositoryNetwork("fake", "repo"); - gitHubClient.Connection.Received(1).Get>(new Uri("networks/fake/repo/events", UriKind.Relative), null, null); + gitHubClient.Connection.Received(1).Get>(new Uri("networks/fake/repo/events", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] @@ -88,7 +88,7 @@ namespace Octokit.Tests.Reactive client.GetAllForOrganization("fake"); - gitHubClient.Connection.Received(1).Get>(new Uri("orgs/fake/events", UriKind.Relative), null, null); + gitHubClient.Connection.Received(1).Get>(new Uri("orgs/fake/events", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] @@ -112,7 +112,7 @@ namespace Octokit.Tests.Reactive client.GetAllUserReceived("fake"); - gitHubClient.Connection.Received(1).Get>(new Uri("users/fake/received_events", UriKind.Relative), null, null); + gitHubClient.Connection.Received(1).Get>(new Uri("users/fake/received_events", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] @@ -136,7 +136,7 @@ namespace Octokit.Tests.Reactive client.GetAllUserReceivedPublic("fake"); - gitHubClient.Connection.Received(1).Get>(new Uri("users/fake/received_events/public", UriKind.Relative), null, null); + gitHubClient.Connection.Received(1).Get>(new Uri("users/fake/received_events/public", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] @@ -160,7 +160,7 @@ namespace Octokit.Tests.Reactive client.GetAllUserPerformed("fake"); - gitHubClient.Connection.Received(1).Get>(new Uri("users/fake/events", UriKind.Relative), null, null); + gitHubClient.Connection.Received(1).Get>(new Uri("users/fake/events", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] @@ -184,7 +184,7 @@ namespace Octokit.Tests.Reactive client.GetAllUserPerformedPublic("fake"); - gitHubClient.Connection.Received(1).Get>(new Uri("users/fake/events/public", UriKind.Relative), null, null); + gitHubClient.Connection.Received(1).Get>(new Uri("users/fake/events/public", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] @@ -208,7 +208,7 @@ namespace Octokit.Tests.Reactive client.GetAllForAnOrganization("fake", "org"); - gitHubClient.Connection.Received(1).Get>(new Uri("users/fake/events/orgs/org", UriKind.Relative), null, null); + gitHubClient.Connection.Received(1).Get>(new Uri("users/fake/events/orgs/org", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] diff --git a/Octokit/Clients/EventsClient.cs b/Octokit/Clients/EventsClient.cs index 65e420f0..a1586ca2 100644 --- a/Octokit/Clients/EventsClient.cs +++ b/Octokit/Clients/EventsClient.cs @@ -29,7 +29,22 @@ namespace Octokit /// All the public s for the particular user. public Task> GetAll() { - return ApiConnection.GetAll(ApiUrls.Events()); + return GetAll(ApiOptions.None); + } + + /// + /// Gets all the public events + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events + /// + /// Options for changing the API response + /// All the public s for the particular user. + public Task> GetAll(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.Events(),options); } /// @@ -46,7 +61,26 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return ApiConnection.GetAll(ApiUrls.IssuesEvents(owner, name)); + return GetAllForRepository(owner,name,ApiOptions.None); + } + + /// + /// Gets all the events for a given repository + /// + /// + /// http://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the particular repository. + public Task> GetAllForRepository(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.IssuesEvents(owner, name),options); } /// @@ -63,7 +97,26 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return ApiConnection.GetAll(ApiUrls.NetworkEvents(owner, name)); + return GetAllForRepositoryNetwork(owner,name,ApiOptions.None); + } + + /// + /// Gets all the events for a given repository network + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-a-network-of-repositories + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the particular repository network. + public Task> GetAllForRepositoryNetwork(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.NetworkEvents(owner, name), options); } /// @@ -78,7 +131,24 @@ namespace Octokit { Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); - return ApiConnection.GetAll(ApiUrls.OrganizationEvents(organization)); + return GetAllForOrganization(organization, ApiOptions.None); + } + + /// + /// Gets all the events for a given organization + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-an-organization + /// + /// The name of the organization + /// Options for changing the API response + /// All the s for the particular organization. + public Task> GetAllForOrganization(string organization, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.OrganizationEvents(organization), options); } /// @@ -93,7 +163,24 @@ namespace Octokit { Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return ApiConnection.GetAll(ApiUrls.ReceivedEvents(user)); + return GetAllUserReceived(user, ApiOptions.None); + } + + /// + /// Gets all the events that have been received by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-that-a-user-has-received + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has received. + public Task> GetAllUserReceived(string user, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.ReceivedEvents(user), options); } /// @@ -108,7 +195,24 @@ namespace Octokit { Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return ApiConnection.GetAll(ApiUrls.ReceivedEvents(user, true)); + return GetAllUserReceivedPublic(user, ApiOptions.None); + } + + /// + /// Gets all the events that have been received by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-that-a-user-has-received + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has received. + public Task> GetAllUserReceivedPublic(string user, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.ReceivedEvents(user, true),options); } /// @@ -123,7 +227,24 @@ namespace Octokit { Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return ApiConnection.GetAll(ApiUrls.PerformedEvents(user)); + return GetAllUserPerformed(user, ApiOptions.None); + } + + /// + /// Gets all the events that have been performed by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-performed-by-a-user + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has performed. + public Task> GetAllUserPerformed(string user, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.PerformedEvents(user),options); } /// @@ -138,7 +259,24 @@ namespace Octokit { Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return ApiConnection.GetAll(ApiUrls.PerformedEvents(user, true)); + return GetAllUserPerformedPublic(user, ApiOptions.None); + } + + /// + /// Gets all the public events that have been performed by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-performed-by-a-user + /// + /// The login of the user + /// Options for changing the API response + /// All the public s that a particular user has performed. + public Task> GetAllUserPerformedPublic(string user, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.PerformedEvents(user, true), options); } /// @@ -155,7 +293,26 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(user, "user"); Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); - return ApiConnection.GetAll(ApiUrls.OrganizationEvents(user, organization)); + return GetAllForAnOrganization(user, organization, ApiOptions.None); + } + + /// + /// Gets all the events that are associated with an organization. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-for-an-organization + /// + /// The login of the user + /// The name of the organization + /// Options for changing the API response + /// All the public s that are associated with an organization. + public Task> GetAllForAnOrganization(string user, string organization, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.OrganizationEvents(user, organization),options); } } } diff --git a/Octokit/Clients/IEventsClient.cs b/Octokit/Clients/IEventsClient.cs index ec148815..06cb5ef6 100644 --- a/Octokit/Clients/IEventsClient.cs +++ b/Octokit/Clients/IEventsClient.cs @@ -21,6 +21,16 @@ namespace Octokit [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] Task> GetAll(); + /// + /// Gets all the public events + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events + /// + /// Options for changing the API response + /// All the public s for the particular user. + Task> GetAll(ApiOptions options); + /// /// Gets all the events for a given repository /// @@ -32,6 +42,20 @@ namespace Octokit /// All the s for the particular repository. Task> GetAllForRepository(string owner, string name); + /// + /// Gets all the events for a given repository + /// + /// + /// http://developer.github.com/v3/activity/events/#list-issue-events-for-a-repository + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the particular repository. + Task> GetAllForRepository(string owner, string name, ApiOptions options); + + + /// /// Gets all the events for a given repository network /// @@ -43,6 +67,18 @@ namespace Octokit /// All the s for the particular repository network. Task> GetAllForRepositoryNetwork(string owner, string name); + /// + /// Gets all the events for a given repository network + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-a-network-of-repositories + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// All the s for the particular repository network. + Task> GetAllForRepositoryNetwork(string owner, string name,ApiOptions options); + /// /// Gets all the events for a given organization /// @@ -53,6 +89,17 @@ namespace Octokit /// All the s for the particular organization. Task> GetAllForOrganization(string organization); + /// + /// Gets all the events for a given organization + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-for-an-organization + /// + /// The name of the organization + /// Options for changing the API response + /// All the s for the particular organization. + Task> GetAllForOrganization(string organization, ApiOptions options); + /// /// Gets all the events that have been received by a given user. /// @@ -63,6 +110,17 @@ namespace Octokit /// All the s that a particular user has received. Task> GetAllUserReceived(string user); + /// + /// Gets all the events that have been received by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-that-a-user-has-received + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has received. + Task> GetAllUserReceived(string user, ApiOptions options); + /// /// Gets all the events that have been received by a given user. /// @@ -73,6 +131,17 @@ namespace Octokit /// All the s that a particular user has received. Task> GetAllUserReceivedPublic(string user); + /// + /// Gets all the events that have been received by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-that-a-user-has-received + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has received. + Task> GetAllUserReceivedPublic(string user, ApiOptions options); + /// /// Gets all the events that have been performed by a given user. /// @@ -83,6 +152,17 @@ namespace Octokit /// All the s that a particular user has performed. Task> GetAllUserPerformed(string user); + /// + /// Gets all the events that have been performed by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-performed-by-a-user + /// + /// The login of the user + /// Options for changing the API response + /// All the s that a particular user has performed. + Task> GetAllUserPerformed(string user, ApiOptions options); + /// /// Gets all the public events that have been performed by a given user. /// @@ -93,6 +173,17 @@ namespace Octokit /// All the public s that a particular user has performed. Task> GetAllUserPerformedPublic(string user); + /// + /// Gets all the public events that have been performed by a given user. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-public-events-performed-by-a-user + /// + /// The login of the user + /// Options for changing the API response + /// All the public s that a particular user has performed. + Task> GetAllUserPerformedPublic(string user, ApiOptions options); + /// /// Gets all the events that are associated with an organization. /// @@ -103,5 +194,17 @@ namespace Octokit /// The name of the organization /// All the public s that are associated with an organization. Task> GetAllForAnOrganization(string user, string organization); + + /// + /// Gets all the events that are associated with an organization. + /// + /// + /// http://developer.github.com/v3/activity/events/#list-events-for-an-organization + /// + /// The login of the user + /// The name of the organization + /// Options for changing the API response + /// All the public s that are associated with an organization. + Task> GetAllForAnOrganization(string user, string organization, ApiOptions options); } } \ No newline at end of file From 43f6cfe28ba4fd67f56e0c127d2ccdf082f787db Mon Sep 17 00:00:00 2001 From: Prayank Mathur Date: Mon, 11 Apr 2016 02:58:01 +0530 Subject: [PATCH 088/123] Added ApiOption overloads to methods on IRepositoryCommitsClient (#1247) * Added ApiOptions overloads for RepositoryCommitClient methods * Added overloads to Reactive clients * Integration tests in progress * Integration test addition in progress * More integration tests added * Added Ensure things * Minor changes * Minor changes * Few changes * Tried to fix errors * Tried to fix errors * Fixed a few things * Fixed integration tests * Tidying up * Added public keyword * Added unit tests for GetAll() in normal and reactive methods * Minor changes * Changed the class name * Fixed the unit test --- .../IObservableRepositoryCommitsClients.cs | 19 +++++ .../Clients/ObservableCommitStatusClient.cs | 2 +- .../ObservableRepositoryCommitsClients.cs | 41 +++++++++- .../Helpers/ConnectionExtensions.cs | 31 ++++---- .../Clients/RepositoryCommitsClientTests.cs | 53 +++++++++++++ .../Octokit.Tests.Integration.csproj | 3 +- .../ObservableRepositoryCommitsClientTests.cs | 75 +++++++++++++++++++ ...servableRepositoryDeployKeysClientTests.cs | 4 +- .../Clients/RepositoriesClientTests.cs | 5 +- .../Clients/RespositoryCommitsClientTests.cs | 50 +++++++++++++ Octokit.Tests/Octokit.Tests.csproj | 1 + .../ObservableRepositoriesClientTests.cs | 4 +- .../ObservableRepositoryCommitsClientTests.cs | 42 +++++++++++ Octokit/Clients/IRepositoryCommitsClient.cs | 18 +++++ Octokit/Clients/RepositoryCommitsClient.cs | 40 +++++++++- 15 files changed, 358 insertions(+), 30 deletions(-) create mode 100644 Octokit.Tests.Integration/Reactive/ObservableRepositoryCommitsClientTests.cs create mode 100644 Octokit.Tests/Clients/RespositoryCommitsClientTests.cs diff --git a/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs b/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs index 29d4d55e..12a4ebf8 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs @@ -35,6 +35,15 @@ namespace Octokit.Reactive /// IObservable GetAll(string owner, string name); + /// + /// Gets all commits for a given repository + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// + IObservable GetAll(string owner, string name, ApiOptions options); + /// /// Gets all commits for a given repository /// @@ -44,6 +53,16 @@ namespace Octokit.Reactive /// IObservable GetAll(string owner, string name, CommitRequest request); + /// + /// Gets all commits for a given repository + /// + /// The owner of the repository + /// The name of the repository + /// Used to filter list of commits returned + /// Options for changing the API response + /// + IObservable GetAll(string owner, string name, CommitRequest request, ApiOptions options); + /// /// Get the SHA-1 of a commit reference /// diff --git a/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs b/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs index cc43773e..e34ed7a9 100644 --- a/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs +++ b/Octokit.Reactive/Clients/ObservableCommitStatusClient.cs @@ -52,7 +52,7 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); Ensure.ArgumentNotNull(options, "options"); - return _connection.GetAndFlattenAllPages(ApiUrls.CommitStatuses(owner, name, reference),options); + return _connection.GetAndFlattenAllPages(ApiUrls.CommitStatuses(owner, name, reference), options); } /// diff --git a/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs b/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs index 629142d7..3304e261 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryCommitsClients.cs @@ -54,7 +54,26 @@ namespace Octokit.Reactive /// public IObservable GetAll(string owner, string name) { - return GetAll(owner, name, new CommitRequest()); + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return GetAll(owner, name, new CommitRequest(), ApiOptions.None); + } + + /// + /// Gets all commits for a given repository + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// + public IObservable GetAll(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return GetAll(owner, name, new CommitRequest(), options); } /// @@ -70,8 +89,24 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(request, "request"); - return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryCommits(owner, name), - request.ToParametersDictionary()); + return GetAll(owner, name, request, ApiOptions.None); + } + + /// + /// Gets all commits for a given repository + /// + /// The owner of the repository + /// The name of the repository + /// Used to filter list of commits returned + /// Options for changing the API response + /// + public IObservable GetAll(string owner, string name, CommitRequest request, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(request, "request"); + + return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryCommits(owner, name), request.ToParametersDictionary(), options); } /// diff --git a/Octokit.Reactive/Helpers/ConnectionExtensions.cs b/Octokit.Reactive/Helpers/ConnectionExtensions.cs index becbf01c..5f2aec15 100644 --- a/Octokit.Reactive/Helpers/ConnectionExtensions.cs +++ b/Octokit.Reactive/Helpers/ConnectionExtensions.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.Linq; using System.Reactive.Linq; using System.Reactive.Threading.Tasks; @@ -16,11 +15,7 @@ namespace Octokit.Reactive.Internal public static IObservable GetAndFlattenAllPages(this IConnection connection, Uri url, ApiOptions options) { - return GetPagesWithOptions(url, options, (pageUrl, o) => - { - var parameters = Pagination.Setup(new Dictionary(), options); - return connection.Get>(pageUrl, parameters, null).ToObservable(); - }); + return connection.GetAndFlattenAllPages(url, null, options); } public static IObservable GetAndFlattenAllPages(this IConnection connection, Uri url, IDictionary parameters) @@ -28,6 +23,15 @@ namespace Octokit.Reactive.Internal return GetPages(url, parameters, (pageUrl, pageParams) => connection.Get>(pageUrl, pageParams, null).ToObservable()); } + public static IObservable GetAndFlattenAllPages(this IConnection connection, Uri url, IDictionary parameters, ApiOptions options) + { + return GetPagesWithOptions(url, parameters, options, (pageUrl, pageParams, o) => + { + var passingParameters = Pagination.Setup(parameters, options); + return connection.Get>(pageUrl, passingParameters, null).ToObservable(); + }); + } + public static IObservable GetAndFlattenAllPages(this IConnection connection, Uri url, IDictionary parameters, string accepts) { return GetPages(url, parameters, (pageUrl, pageParams) => connection.Get>(pageUrl, pageParams, accepts).ToObservable()); @@ -47,19 +51,16 @@ namespace Octokit.Reactive.Internal .SelectMany(resp => resp.Body); } - static IObservable GetPagesWithOptions(Uri uri, ApiOptions options, - Func>>> getPageFunc) + static IObservable GetPagesWithOptions(Uri uri, IDictionary parameters, ApiOptions options, Func, ApiOptions, IObservable>>> getPageFunc) { - return getPageFunc(uri, options).Expand(resp => + return getPageFunc(uri, parameters, options).Expand(resp => { - var nextPageUri = resp.HttpResponse.ApiInfo.GetNextPageUrl(); + var nextPageUrl = resp.HttpResponse.ApiInfo.GetNextPageUrl(); - var shouldContinue = Pagination.ShouldContinue( - nextPageUri, - options); + var shouldContinue = Pagination.ShouldContinue(nextPageUrl, options); - return shouldContinue - ? Observable.Defer(() => getPageFunc(nextPageUri, null)) + return shouldContinue + ? Observable.Defer(() => getPageFunc(nextPageUrl, null, null)) : Observable.Empty>>(); }) .Where(resp => resp != null) diff --git a/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs index 83401a3e..c5a3e3c4 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs @@ -42,6 +42,59 @@ public class RepositoryCommitsClientTests Assert.NotEmpty(list); } + [IntegrationTest] + public async Task CanGetCorrectCountOfCommitsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var commits = await _fixture.GetAll("shiftkey", "ReactiveGit", options); + Assert.Equal(5, commits.Count); + } + + [IntegrationTest] + public async Task CanGetCorrectCountOfCommitsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var commits = await _fixture.GetAll("shiftkey", "ReactiveGit", options); + Assert.Equal(5, commits.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStart() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + }; + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var firstCommit = await _fixture.GetAll("shiftkey", "ReactiveGit", startOptions); + var secondCommit = await _fixture.GetAll("shiftkey", "ReactiveGit", skipStartOptions); + + Assert.NotEqual(firstCommit[0].Sha, secondCommit[0].Sha); + Assert.NotEqual(firstCommit[1].Sha, secondCommit[1].Sha); + Assert.NotEqual(firstCommit[2].Sha, secondCommit[2].Sha); + Assert.NotEqual(firstCommit[3].Sha, secondCommit[3].Sha); + Assert.NotEqual(firstCommit[4].Sha, secondCommit[4].Sha); + } + [IntegrationTest] public async Task CanGetListOfCommitsBySha() { diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 5cd0ff60..3192936c 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -137,6 +137,7 @@ + @@ -151,7 +152,7 @@ - + diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositoryCommitsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryCommitsClientTests.cs new file mode 100644 index 00000000..63995c8c --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryCommitsClientTests.cs @@ -0,0 +1,75 @@ +using System.Linq; +using System.Threading.Tasks; +using Octokit.Reactive; +using System.Reactive.Linq; +using Xunit; + +namespace Octokit.Tests.Integration.Reactive +{ + public class ObservableRepositoryCommitsClientTests + { + public class TheGetAllMethod + { + readonly ObservableRepositoryCommitsClient _repositoryCommitsClient; + + public TheGetAllMethod() + { + var client = Helper.GetAuthenticatedClient(); + _repositoryCommitsClient = new ObservableRepositoryCommitsClient(client); + } + + [IntegrationTest] + public async Task CanGetCorrectCountOfCommitsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var commits = await _repositoryCommitsClient.GetAll("shiftkey", "ReactiveGit", options).ToList(); + Assert.Equal(5, commits.Count); + } + + [IntegrationTest] + public async Task CanGetCorrectCountOfCommitsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var commits = await _repositoryCommitsClient.GetAll("shiftkey", "ReactiveGit", options).ToList(); + Assert.Equal(5, commits.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStart() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + }; + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var firstCommit = await _repositoryCommitsClient.GetAll("shiftkey", "ReactiveGit", startOptions).ToList(); + var secondCommit = await _repositoryCommitsClient.GetAll("shiftkey", "ReactiveGit", skipStartOptions).ToList(); + + Assert.NotEqual(firstCommit[0].Sha, secondCommit[0].Sha); + Assert.NotEqual(firstCommit[1].Sha, secondCommit[1].Sha); + Assert.NotEqual(firstCommit[2].Sha, secondCommit[2].Sha); + Assert.NotEqual(firstCommit[3].Sha, secondCommit[3].Sha); + Assert.NotEqual(firstCommit[4].Sha, secondCommit[4].Sha); + } + } + } +} diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositoryDeployKeysClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryDeployKeysClientTests.cs index 3df43c17..19fe4a83 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableRepositoryDeployKeysClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryDeployKeysClientTests.cs @@ -6,7 +6,7 @@ using Octokit.Reactive; using Octokit.Tests.Integration; using Xunit; -public class ObservableRepositoryDeployKeysClientTests : IDisposable +public class ObservableRespositoryDeployKeysClientTests : IDisposable { const string _key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDB8IE5+RppLpeW+6lqo0fpfvMunKg6W4bhYCfVJIOYbpKoHP95nTUMZPBT++9NLeB4/YsuNTCrrpnpjc4f2IVpGvloRiVXjAzoJk9QIL6uzn1zRFdvaxSJ3Urhe9LcLHcIgccgZgSdWGzaZI3xtMvGC4diwWNsPjvVc/RyDM/MPqAim0X5XVOQwEFsSsUSraezJ+VgYMYzLYBcKWW0B86HVVhL4ZtmcY/RN2544bljnzw2M3aQvXNPTvkuiUoqLOI+5/qzZ8PfkruO55YtweEd0lkY6oZvrBPMD6dLODEqMHb4tD6htx60wSipNqjPwpOMpzp0Bk3G909unVXi6Fw5"; const string _keyTitle = "octokit@github"; @@ -14,7 +14,7 @@ public class ObservableRepositoryDeployKeysClientTests : IDisposable Repository _repository; string _owner; - public ObservableRepositoryDeployKeysClientTests() + public ObservableRespositoryDeployKeysClientTests() { var github = Helper.GetAuthenticatedClient(); diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index cae96871..6789f048 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -740,7 +740,7 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAll("owner", null)); await Assert.ThrowsAsync(() => client.GetAll("owner", "")); - await Assert.ThrowsAsync(() => client.GetAll("owner", "repo", null)); + await Assert.ThrowsAsync(() => client.GetAll("owner", "repo", null, ApiOptions.None)); } [Fact] @@ -752,8 +752,7 @@ namespace Octokit.Tests.Clients client.GetAll("owner", "name"); connection.Received() - .GetAll(Arg.Is(u => u.ToString() == "repos/owner/name/commits"), - Arg.Any>()); + .GetAll(Arg.Is(u => u.ToString() == "repos/owner/name/commits"), Args.EmptyDictionary, Args.ApiOptions); } } diff --git a/Octokit.Tests/Clients/RespositoryCommitsClientTests.cs b/Octokit.Tests/Clients/RespositoryCommitsClientTests.cs new file mode 100644 index 00000000..fe0ba30f --- /dev/null +++ b/Octokit.Tests/Clients/RespositoryCommitsClientTests.cs @@ -0,0 +1,50 @@ +using NSubstitute; +using System; +using System.Collections.Generic; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class RespositoryCommitsClientTests + { + public class TheGetAllMethod + { + [Fact] + public void EnsuresNonEmptyArguments() + { + var connection = Substitute.For(); + var client = new RepositoryCommitsClient(connection); + var options = new ApiOptions(); + var request = new CommitRequest(); + + Assert.ThrowsAsync(() => client.GetAll("", "name", request, options)); + Assert.ThrowsAsync(() => client.GetAll("owner", "", request, options)); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var connection = Substitute.For(); + var client = new RepositoryCommitsClient(connection); + var options = new ApiOptions(); + var request = new CommitRequest(); + + Assert.ThrowsAsync(() => client.GetAll(null, "name", request, options)); + Assert.ThrowsAsync(() => client.GetAll("owner", null, request, options)); + Assert.ThrowsAsync(() => client.GetAll("owner", "name", null, options)); + Assert.ThrowsAsync(() => client.GetAll("owner", "name", request, null)); + + } + + [Fact] + public void GetsCorrectUrl() + { + var connection = Substitute.For(); + var client = new RepositoryCommitsClient(connection); + + client.GetAll("fake", "repo", new CommitRequest(), new ApiOptions()); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/commits"), Args.EmptyDictionary, Args.ApiOptions); + } + } + } +} diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 1ba8aca1..0cc589e2 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -99,6 +99,7 @@ + diff --git a/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs index a2f0e31f..9825cd74 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs @@ -269,13 +269,13 @@ namespace Octokit.Tests.Reactive public class TheGetAllCommitsMethod { [Fact] - public void EnsuresArguments() + public void EnsuresNonNullArguments() { var client = new ObservableRepositoriesClient(Substitute.For()); Assert.Throws(() => client.Commit.GetAll(null, "repo")); Assert.Throws(() => client.Commit.GetAll("owner", null)); - Assert.Throws(() => client.Commit.GetAll("owner", "repo", null)); + Assert.Throws(() => client.Commit.GetAll("owner", "repo", null, ApiOptions.None)); Assert.Throws(() => client.Commit.GetAll("", "repo")); Assert.Throws(() => client.Commit.GetAll("owner", "")); } diff --git a/Octokit.Tests/Reactive/ObservableRepositoryCommitsClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryCommitsClientTests.cs index bcd91f37..07d15de3 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryCommitsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryCommitsClientTests.cs @@ -18,6 +18,48 @@ namespace Octokit.Tests.Reactive } } + public class TheGetAllMethod + { + [Fact] + public void EnsuresNonEmptyArguments() + { + var githubClient = Substitute.For(); + var client = new ObservableRepositoryCommitsClient(githubClient); + var options = new ApiOptions(); + var request = new CommitRequest(); + + Assert.ThrowsAsync(() => client.GetAll("", "name", request, options).ToTask()); + Assert.ThrowsAsync(() => client.GetAll("owner", "", request, options).ToTask()); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var githubClient = Substitute.For(); + var client = new ObservableRepositoryCommitsClient(githubClient); + var options = new ApiOptions(); + var request = new CommitRequest(); + + Assert.ThrowsAsync(() => client.GetAll(null, "name", request, options).ToTask()); + Assert.ThrowsAsync(() => client.GetAll("owner", null, request, options).ToTask()); + Assert.ThrowsAsync(() => client.GetAll("owner", "name", null, options).ToTask()); + Assert.ThrowsAsync(() => client.GetAll("owner", "name", request, null).ToTask()); + + } + + [Fact] + public void GetsCorrectUrl() + { + var githubClient = Substitute.For(); + var client = new ObservableRepositoryCommitsClient(githubClient); + var options = new ApiOptions(); + var request = new CommitRequest(); + + client.GetAll("fake", "repo", request, options); + githubClient.Received().Repository.Commit.GetAll("fake", "repo", request, options); + } + } + public class TheGetSha1Method { [Fact] diff --git a/Octokit/Clients/IRepositoryCommitsClient.cs b/Octokit/Clients/IRepositoryCommitsClient.cs index bd486192..33c7b877 100644 --- a/Octokit/Clients/IRepositoryCommitsClient.cs +++ b/Octokit/Clients/IRepositoryCommitsClient.cs @@ -42,6 +42,15 @@ namespace Octokit /// Task> GetAll(string owner, string name); + /// + /// Gets all commits for a given repository + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// + Task> GetAll(string owner, string name, ApiOptions options); + /// /// Gets all commits for a given repository /// @@ -51,6 +60,15 @@ namespace Octokit /// Task> GetAll(string owner, string name, CommitRequest request); + /// + /// Gets all commits for a given repository + /// + /// The owner of the repository + /// The name of the repository + /// Used to filter list of commits returned + /// Options for changing the API response + /// + Task> GetAll(string owner, string name, CommitRequest request, ApiOptions options); /// /// Get the SHA-1 of a commit reference /// diff --git a/Octokit/Clients/RepositoryCommitsClient.cs b/Octokit/Clients/RepositoryCommitsClient.cs index e5fa9613..f2ea2ccd 100644 --- a/Octokit/Clients/RepositoryCommitsClient.cs +++ b/Octokit/Clients/RepositoryCommitsClient.cs @@ -60,9 +60,27 @@ namespace Octokit /// public Task> GetAll(string owner, string name) { - return GetAll(owner, name, new CommitRequest()); + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return GetAll(owner, name, new CommitRequest(), ApiOptions.None); } + /// + /// Gets all commits for a given repository + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// + public Task> GetAll(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return GetAll(owner, name, new CommitRequest(), options); + } + /// /// Gets all commits for a given repository /// @@ -76,8 +94,24 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(request, "request"); - return _apiConnection.GetAll(ApiUrls.RepositoryCommits(owner, name), - request.ToParametersDictionary()); + return GetAll(owner, name, request, ApiOptions.None); + } + + /// + /// Gets all commits for a given repository + /// + /// The owner of the repository + /// The name of the repository + /// Used to filter list of commits returned + /// Options for changing the API response + /// + public Task> GetAll(string owner, string name, CommitRequest request, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(request, "request"); + + return _apiConnection.GetAll(ApiUrls.RepositoryCommits(owner, name), request.ToParametersDictionary(), options); } /// From 750aed62f8605ce03dcb02792aec45b3908ef13a Mon Sep 17 00:00:00 2001 From: Elhamer Date: Mon, 11 Apr 2016 12:54:33 +0100 Subject: [PATCH 089/123] Add ApiOption overloads to methods on IFollowersClient (#1259) --- .../Clients/IObservableFollowersClient.cs | 43 +++ .../Clients/ObservableFollowersClient.cs | 72 ++++- .../Octokit.Tests.Integration.csproj | 1 + .../ObservableFollowersClientTests.cs | 305 ++++++++++++++++++ Octokit.Tests/Clients/FollowersClientTests.cs | 108 ++++++- .../Reactive/ObservableFollowersTest.cs | 8 +- Octokit/Clients/FollowersClient.cs | 72 ++++- Octokit/Clients/IFollowersClient.cs | 42 +++ 8 files changed, 633 insertions(+), 18 deletions(-) create mode 100644 Octokit.Tests.Integration/Reactive/ObservableFollowersClientTests.cs diff --git a/Octokit.Reactive/Clients/IObservableFollowersClient.cs b/Octokit.Reactive/Clients/IObservableFollowersClient.cs index 46a38fc1..32030bc1 100644 --- a/Octokit.Reactive/Clients/IObservableFollowersClient.cs +++ b/Octokit.Reactive/Clients/IObservableFollowersClient.cs @@ -16,6 +16,17 @@ namespace Octokit.Reactive [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] IObservable GetAllForCurrent(); + /// + /// List the authenticated user’s followers + /// + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that follow the authenticated user. + [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] + IObservable GetAllForCurrent(ApiOptions options); + /// /// List a user’s followers /// @@ -26,6 +37,17 @@ namespace Octokit.Reactive /// A of s that follow the passed user. IObservable GetAll(string login); + /// + /// List a user’s followers + /// + /// Options for changing the API response + /// The login name for the user + /// + /// See the API documentation for more information. + /// + /// A of s that follow the passed user. + IObservable GetAll(string login, ApiOptions options); + /// /// List who the authenticated user is following /// @@ -36,6 +58,16 @@ namespace Octokit.Reactive [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] IObservable GetAllFollowingForCurrent(); + /// + /// List who the authenticated user is following + /// + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that the authenticated user follows. + IObservable GetAllFollowingForCurrent(ApiOptions options); + /// /// List who a user is following /// @@ -46,6 +78,17 @@ namespace Octokit.Reactive /// A of s that the passed user follows. IObservable GetAllFollowing(string login); + /// + /// List who a user is following + /// + /// The login name of the user + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that the passed user follows. + IObservable GetAllFollowing(string login, ApiOptions options); + /// /// Check if the authenticated user follows another user /// diff --git a/Octokit.Reactive/Clients/ObservableFollowersClient.cs b/Octokit.Reactive/Clients/ObservableFollowersClient.cs index c77b4571..955b5309 100644 --- a/Octokit.Reactive/Clients/ObservableFollowersClient.cs +++ b/Octokit.Reactive/Clients/ObservableFollowersClient.cs @@ -31,7 +31,22 @@ namespace Octokit.Reactive /// A of s that follow the authenticated user. public IObservable GetAllForCurrent() { - return _connection.GetAndFlattenAllPages(ApiUrls.Followers()); + return GetAllForCurrent(ApiOptions.None); + } + + /// + /// List the authenticated user’s followers + /// + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that follow the authenticated user. + public IObservable GetAllForCurrent(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.Followers(), options); } /// @@ -46,7 +61,24 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNullOrEmptyString(login, "login"); - return _connection.GetAndFlattenAllPages(ApiUrls.Followers(login)); + return GetAll(login, ApiOptions.None); + } + + /// + /// List a user’s followers + /// + /// The login name for the user + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that follow the passed user. + public IObservable GetAll(string login, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.Followers(login), options); } /// @@ -58,7 +90,22 @@ namespace Octokit.Reactive /// A of s that the authenticated user follows. public IObservable GetAllFollowingForCurrent() { - return _connection.GetAndFlattenAllPages(ApiUrls.Following()); + return GetAllFollowingForCurrent(ApiOptions.None); + } + + /// + /// List who the authenticated user is following + /// + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that the authenticated user follows. + public IObservable GetAllFollowingForCurrent(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.Following(), options); } /// @@ -73,7 +120,24 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNullOrEmptyString(login, "login"); - return _connection.GetAndFlattenAllPages(ApiUrls.Following(login)); + return GetAllFollowing(login, ApiOptions.None); + } + + /// + /// List who a user is following + /// + /// The login name of the user + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that the passed user follows. + public IObservable GetAllFollowing(string login, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.Following(login), options); } /// diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 3192936c..2c972371 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -137,6 +137,7 @@ + diff --git a/Octokit.Tests.Integration/Reactive/ObservableFollowersClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableFollowersClientTests.cs new file mode 100644 index 00000000..6b3e61dc --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableFollowersClientTests.cs @@ -0,0 +1,305 @@ +using System.Reactive.Linq; +using System.Threading.Tasks; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Integration.Reactive +{ + public class ObservableFollowersClientTests + { + public class TheGetAllForCurrentMethod + { + readonly ObservableFollowersClient _followersClient; + + public TheGetAllForCurrentMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _followersClient = new ObservableFollowersClient(github); + } + + [IntegrationTest] + public async Task ReturnsFollowers() + { + var followers = await _followersClient.GetAllForCurrent().ToList(); + + Assert.NotEmpty(followers); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfFollowersWithoutStart() + { + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1 + }; + + var followers = await _followersClient.GetAllForCurrent(options).ToList(); + + Assert.Equal(1, followers.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfFollowersWithStart() + { + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + var followers = await _followersClient.GetAllForCurrent(options).ToList(); + + Assert.Equal(1, followers.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 1, + PageCount = 1 + }; + + var firstFollowersPage = await _followersClient.GetAllForCurrent(startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 2 + }; + + var secondFollowersPage = await _followersClient.GetAllForCurrent(skipStartOptions).ToList(); + + Assert.NotEqual(firstFollowersPage[0].Id, secondFollowersPage[0].Id); + } + } + + public class TheGetAllMethod + { + readonly ObservableFollowersClient _followersClient; + const string login = "samthedev"; + + public TheGetAllMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _followersClient = new ObservableFollowersClient(github); + } + + [IntegrationTest] + public async Task ReturnsFollowers() + { + var followers = await _followersClient.GetAll(login).ToList(); + + Assert.NotEmpty(followers); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfFollowersWithoutStart() + { + var options = new ApiOptions + { + PageSize = 3, + PageCount = 1 + }; + + var followers = await _followersClient.GetAll(login, options).ToList(); + + Assert.Equal(3, followers.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfFollowersWithStart() + { + var options = new ApiOptions + { + PageSize = 2, + PageCount = 1, + StartPage = 1 + }; + + var followers = await _followersClient.GetAll(login, options).ToList(); + + Assert.Equal(2, followers.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 2, + PageCount = 1 + }; + + var firstFollowersPage = await _followersClient.GetAll(login, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 2, + PageCount = 1, + StartPage = 2 + }; + + var secondFollowersPage = await _followersClient.GetAll(login, skipStartOptions).ToList(); + + Assert.NotEqual(firstFollowersPage[0].Id, secondFollowersPage[0].Id); + Assert.NotEqual(firstFollowersPage[1].Id, secondFollowersPage[1].Id); + } + } + + public class TheGetAllFollowingForCurrentMethod + { + readonly ObservableFollowersClient _followersClient; + + public TheGetAllFollowingForCurrentMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _followersClient = new ObservableFollowersClient(github); + } + + [IntegrationTest] + public async Task ReturnsFollowing() + { + var following = await _followersClient.GetAllFollowingForCurrent().ToList(); + + Assert.NotEmpty(following); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfFollowingWithoutStart() + { + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1 + }; + + var following = await _followersClient.GetAllFollowingForCurrent(options).ToList(); + + Assert.Equal(1, following.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfFollowingWithStart() + { + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + var following = await _followersClient.GetAllFollowingForCurrent(options).ToList(); + + Assert.Equal(1, following.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 1, + PageCount = 1 + }; + + var firstFollowingPage = await _followersClient.GetAllFollowingForCurrent(startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 2 + }; + + var secondFollowingPage = await _followersClient.GetAllFollowingForCurrent(skipStartOptions).ToList(); + + Assert.NotEqual(firstFollowingPage[0].Id, secondFollowingPage[0].Id); + } + } + + public class TheGetAllFollowingMethod + { + readonly ObservableFollowersClient _followersClient; + const string login = "samthedev"; + + public TheGetAllFollowingMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _followersClient = new ObservableFollowersClient(github); + } + + [IntegrationTest] + public async Task ReturnsFollowing() + { + var following = await _followersClient.GetAllFollowing(login).ToList(); + + Assert.NotEmpty(following); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfFollowingWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var following = await _followersClient.GetAllFollowing(login, options).ToList(); + + Assert.Equal(5, following.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfFollowingWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 1 + }; + + var following = await _followersClient.GetAllFollowing(login, options).ToList(); + + Assert.Equal(5, following.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstFollowingPage = await _followersClient.GetAllFollowing(login, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondFollowingPage = await _followersClient.GetAllFollowing(login, skipStartOptions).ToList(); + + Assert.NotEqual(firstFollowingPage[0].Id, secondFollowingPage[0].Id); + Assert.NotEqual(firstFollowingPage[1].Id, secondFollowingPage[1].Id); + Assert.NotEqual(firstFollowingPage[2].Id, secondFollowingPage[2].Id); + Assert.NotEqual(firstFollowingPage[3].Id, secondFollowingPage[3].Id); + Assert.NotEqual(firstFollowingPage[4].Id, secondFollowingPage[4].Id); + } + } + } +} diff --git a/Octokit.Tests/Clients/FollowersClientTests.cs b/Octokit.Tests/Clients/FollowersClientTests.cs index f9201f6d..921b1a2f 100644 --- a/Octokit.Tests/Clients/FollowersClientTests.cs +++ b/Octokit.Tests/Clients/FollowersClientTests.cs @@ -37,7 +37,35 @@ namespace Octokit.Tests.Clients client.GetAllForCurrent(); connection.Received().GetAll( - Arg.Is(u => u.ToString() == "user/followers")); + Arg.Is(u => u.ToString() == "user/followers"),Args.ApiOptions); + } + + [Fact] + public void RequestsTheCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new FollowersClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAllForCurrent(options); + + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "user/followers"),options); + } + + [Fact] + public async Task EnsureNonNullArguments() + { + var connection = Substitute.For(); + var client = new FollowersClient(connection); + + await Assert.ThrowsAsync(() => client.GetAllForCurrent(null)); } } @@ -52,7 +80,26 @@ namespace Octokit.Tests.Clients client.GetAll("alfhenrik"); connection.Received().GetAll( - Arg.Is(u => u.ToString() == "users/alfhenrik/followers")); + Arg.Is(u => u.ToString() == "users/alfhenrik/followers"), Args.ApiOptions); + } + + [Fact] + public void RequestsTheCorrectUrlWithOptions() + { + var connection = Substitute.For(); + var client = new FollowersClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAll("alfhenrik",options); + + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "users/alfhenrik/followers"), options); } [Fact] @@ -63,10 +110,12 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAll(null)); await Assert.ThrowsAsync(() => client.GetAll("")); + await Assert.ThrowsAsync(() => client.GetAll("fake",null)); + await Assert.ThrowsAsync(() => client.GetAll("",ApiOptions.None)); } } - public class TheGetFollowingForCurrentMethod + public class TheGetAllFollowingForCurrentMethod { [Fact] public void RequestsTheCorrectUrl() @@ -76,11 +125,38 @@ namespace Octokit.Tests.Clients client.GetAllFollowingForCurrent(); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "user/following")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "user/following"), Args.ApiOptions); + } + + [Fact] + public void RequestsTheCorrectUrlWithOptions() + { + var connection = Substitute.For(); + var client = new FollowersClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAllFollowingForCurrent(options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "user/following"), options); + } + + [Fact] + public async Task EnsureNonNullArguments() + { + var connection = Substitute.For(); + var client = new FollowersClient(connection); + + await Assert.ThrowsAsync(() => client.GetAllFollowingForCurrent(null)); } } - public class TheGetFollowingMethod + public class TheGetAllFollowingMethod { [Fact] public void RequestsTheCorrectUrl() @@ -90,7 +166,25 @@ namespace Octokit.Tests.Clients client.GetAllFollowing("alfhenrik"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/alfhenrik/following")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/alfhenrik/following"), Args.ApiOptions); + } + + [Fact] + public void RequestsTheCorrectUrlWithOptions() + { + var connection = Substitute.For(); + var client = new FollowersClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAllFollowing("alfhenrik", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/alfhenrik/following"), options); } [Fact] @@ -101,6 +195,8 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAllFollowing(null)); await Assert.ThrowsAsync(() => client.GetAllFollowing("")); + await Assert.ThrowsAsync(() => client.GetAllFollowing("fake", null)); + await Assert.ThrowsAsync(() => client.GetAllFollowing("", ApiOptions.None)); } } diff --git a/Octokit.Tests/Reactive/ObservableFollowersTest.cs b/Octokit.Tests/Reactive/ObservableFollowersTest.cs index b7bd269d..b44807e6 100644 --- a/Octokit.Tests/Reactive/ObservableFollowersTest.cs +++ b/Octokit.Tests/Reactive/ObservableFollowersTest.cs @@ -25,7 +25,7 @@ namespace Octokit.Tests.Reactive client.GetAllForCurrent(); githubClient.Connection.Received(1).Get>( - new Uri("user/followers", UriKind.Relative), null, null); + new Uri("user/followers", UriKind.Relative), Args.EmptyDictionary, null); } } @@ -40,7 +40,7 @@ namespace Octokit.Tests.Reactive client.GetAll("alfhenrik"); githubClient.Connection.Received(1).Get>( - new Uri("users/alfhenrik/followers", UriKind.Relative), null, null); + new Uri("users/alfhenrik/followers", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] @@ -64,7 +64,7 @@ namespace Octokit.Tests.Reactive client.GetAllFollowingForCurrent(); githubClient.Connection.Received(1).Get>( - new Uri("user/following", UriKind.Relative), null, null); + new Uri("user/following", UriKind.Relative), Args.EmptyDictionary, null); } } @@ -79,7 +79,7 @@ namespace Octokit.Tests.Reactive client.GetAllFollowing("alfhenrik"); githubClient.Connection.Received(1).Get>( - new Uri("users/alfhenrik/following", UriKind.Relative), null, null); + new Uri("users/alfhenrik/following", UriKind.Relative), Args.EmptyDictionary, null); } [Fact] diff --git a/Octokit/Clients/FollowersClient.cs b/Octokit/Clients/FollowersClient.cs index b2cfe95f..d1295c2b 100644 --- a/Octokit/Clients/FollowersClient.cs +++ b/Octokit/Clients/FollowersClient.cs @@ -29,7 +29,22 @@ namespace Octokit /// A of s that follow the authenticated user. public Task> GetAllForCurrent() { - return ApiConnection.GetAll(ApiUrls.Followers()); + return GetAllForCurrent(ApiOptions.None); + } + + /// + /// List the authenticated user’s followers + /// + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that follow the authenticated user. + public Task> GetAllForCurrent(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.Followers(),options); } /// @@ -44,7 +59,24 @@ namespace Octokit { Ensure.ArgumentNotNullOrEmptyString(login, "login"); - return ApiConnection.GetAll(ApiUrls.Followers(login)); + return GetAll(login, ApiOptions.None); + } + + /// + /// List a user’s followers + /// + /// The login name for the user + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that follow the passed user. + public Task> GetAll(string login, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.Followers(login), options); } /// @@ -56,7 +88,22 @@ namespace Octokit /// A of s that the authenticated user follows. public Task> GetAllFollowingForCurrent() { - return ApiConnection.GetAll(ApiUrls.Following()); + return GetAllFollowingForCurrent(ApiOptions.None); + } + + /// + /// List who the authenticated user is following + /// + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that the authenticated user follows. + public Task> GetAllFollowingForCurrent(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.Following(), options); } /// @@ -71,7 +118,24 @@ namespace Octokit { Ensure.ArgumentNotNullOrEmptyString(login, "login"); - return ApiConnection.GetAll(ApiUrls.Following(login)); + return GetAllFollowing(login, ApiOptions.None); + } + + /// + /// List who a user is following + /// + /// The login name of the user + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that the passed user follows. + public Task> GetAllFollowing(string login, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(login, "login"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.Following(login), options); } /// diff --git a/Octokit/Clients/IFollowersClient.cs b/Octokit/Clients/IFollowersClient.cs index 00f7b7e0..0c7dee8a 100644 --- a/Octokit/Clients/IFollowersClient.cs +++ b/Octokit/Clients/IFollowersClient.cs @@ -22,6 +22,16 @@ namespace Octokit [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] Task> GetAllForCurrent(); + /// + /// List the authenticated user’s followers + /// + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that follow the authenticated user. + Task> GetAllForCurrent(ApiOptions options); + /// /// List a user’s followers /// @@ -32,6 +42,17 @@ namespace Octokit /// A of s that follow the passed user. Task> GetAll(string login); + /// + /// List a user’s followers + /// + /// The login name for the user + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that follow the passed user. + Task> GetAll(string login, ApiOptions options); + /// /// List who the authenticated user is following /// @@ -42,6 +63,16 @@ namespace Octokit [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] Task> GetAllFollowingForCurrent(); + /// + /// List who the authenticated user is following + /// + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that the authenticated user follows. + Task> GetAllFollowingForCurrent(ApiOptions options); + /// /// List who a user is following /// @@ -52,6 +83,17 @@ namespace Octokit /// A of s that the passed user follows. Task> GetAllFollowing(string login); + /// + /// List who a user is following + /// + /// The login name of the user + /// Options for changing the API response + /// + /// See the API documentation for more information. + /// + /// A of s that the passed user follows. + Task> GetAllFollowing(string login, ApiOptions options); + /// /// Check if the authenticated user follows another user /// From 5b72007ed484a52a7f75666455fc21f984313393 Mon Sep 17 00:00:00 2001 From: Kivanc Muslu Date: Mon, 11 Apr 2016 10:29:05 -0700 Subject: [PATCH 090/123] Ensure that Commit.Compare(..) sets MergeBaseCommit correctly. MergeBaseCommit was spelled incorrectly in CompareResult causing Octokit to pass "null" no matter what the comparison is. This commit makes MergedBaseCommit (the previous spelling) obsolete, introduces MergeBaseCommit property and adds a test to ensure that MergeBaseCommit is set properly in CompareResult. In the test, I specifically compared a commit with itself since the test only cares whether the property is filled correctly or not, it is not testing whether the internal computation is correct or not. Closes #1258. --- .../Clients/RepositoryCommitsClientTests.cs | 7 +++++++ Octokit/Models/Response/CompareResult.cs | 9 ++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs index c5a3e3c4..c0bf59bc 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs @@ -20,6 +20,13 @@ public class RepositoryCommitsClientTests _fixture = client.Repository.Commit; } + [IntegrationTest] + public async Task CanGetMergeBaseCommit() + { + var compareResult = await _fixture.Compare("octokit", "octokit.net", "65a22f4d2cff94a286ac3e96440c810c5509196f", "65a22f4d2cff94a286ac3e96440c810c5509196f"); + Assert.NotNull(compareResult.MergeBaseCommit); + } + [IntegrationTest] public async Task CanGetCommit() { diff --git a/Octokit/Models/Response/CompareResult.cs b/Octokit/Models/Response/CompareResult.cs index 38588f38..bd47b7ce 100644 --- a/Octokit/Models/Response/CompareResult.cs +++ b/Octokit/Models/Response/CompareResult.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Diagnostics; using System.Globalization; @@ -9,7 +10,7 @@ namespace Octokit { public CompareResult() { } - public CompareResult(string url, string htmlUrl, string permalinkUrl, string diffUrl, string patchUrl, GitHubCommit baseCommit, GitHubCommit mergedBaseCommit, string status, int aheadBy, int behindBy, int totalCommits, IReadOnlyList commits, IReadOnlyList files) + public CompareResult(string url, string htmlUrl, string permalinkUrl, string diffUrl, string patchUrl, GitHubCommit baseCommit, GitHubCommit mergeBaseCommit, string status, int aheadBy, int behindBy, int totalCommits, IReadOnlyList commits, IReadOnlyList files) { Url = url; HtmlUrl = htmlUrl; @@ -17,7 +18,7 @@ namespace Octokit DiffUrl = diffUrl; PatchUrl = patchUrl; BaseCommit = baseCommit; - MergedBaseCommit = mergedBaseCommit; + MergeBaseCommit = mergeBaseCommit; Status = status; AheadBy = aheadBy; BehindBy = behindBy; @@ -32,7 +33,9 @@ namespace Octokit public string DiffUrl { get; protected set; } public string PatchUrl { get; protected set; } public GitHubCommit BaseCommit { get; protected set; } + [Obsolete("This property is obsolete. Use MergeBaseCommit instead.", false)] public GitHubCommit MergedBaseCommit { get; protected set; } + public GitHubCommit MergeBaseCommit { get; protected set; } public string Status { get; protected set; } public int AheadBy { get; protected set; } public int BehindBy { get; protected set; } From 52a059a3431ed9e2463ba83b9c951e7f1cb18ec1 Mon Sep 17 00:00:00 2001 From: Alexander Efremov Date: Wed, 13 Apr 2016 08:37:00 +0700 Subject: [PATCH 091/123] removed redundant control flow jump statements (#1266) --- Octokit/Clients/UserAdministrationClient.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Octokit/Clients/UserAdministrationClient.cs b/Octokit/Clients/UserAdministrationClient.cs index 7245a8ad..cd7c14cb 100644 --- a/Octokit/Clients/UserAdministrationClient.cs +++ b/Octokit/Clients/UserAdministrationClient.cs @@ -100,8 +100,6 @@ namespace Octokit { throw new ApiException("Invalid Status Code returned. Expected a 204", response); } - - return; } /// @@ -201,8 +199,6 @@ namespace Octokit { throw new ApiException("Invalid Status Code returned. Expected a 204", response); } - - return; } /// @@ -224,8 +220,6 @@ namespace Octokit { throw new ApiException("Invalid Status Code returned. Expected a 204", response); } - - return; } } } From 86db99323215fdea9ce4e5e9e88c7c398972a3d9 Mon Sep 17 00:00:00 2001 From: Mordechai Zuber Date: Sun, 27 Mar 2016 10:40:53 +0300 Subject: [PATCH 092/123] Remove SearchIssuesRequest ctor --- Octokit/Models/Request/SearchIssuesRequest.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Octokit/Models/Request/SearchIssuesRequest.cs b/Octokit/Models/Request/SearchIssuesRequest.cs index 68699d77..1b9a630c 100644 --- a/Octokit/Models/Request/SearchIssuesRequest.cs +++ b/Octokit/Models/Request/SearchIssuesRequest.cs @@ -32,16 +32,6 @@ namespace Octokit Repos = new RepositoryCollection(); } - [Obsolete("this will be deprecated in a future version")] - public SearchIssuesRequest(string term, string owner, string name) - : this(term) - { - Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - - Repos.Add(owner, name); - } - /// /// Optional Sort field. One of comments, created, updated or merged /// If not provided, results are sorted by best match. From 611ba3aab36f776cf47dddc644790128e6f146e8 Mon Sep 17 00:00:00 2001 From: Mordechai Zuber Date: Sun, 27 Mar 2016 11:17:46 +0300 Subject: [PATCH 093/123] Remove IRepositoryContentsClient.GetArchiveLink() --- .../IObservableRepositoryContentsClient.cs | 44 +-------------- .../ObservableRepositoryContentsClient.cs | 55 ------------------- Octokit/Clients/IRepositoryContentsClient.cs | 42 -------------- Octokit/Clients/RepositoryContentsClient.cs | 54 ------------------ 4 files changed, 1 insertion(+), 194 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs index 45d07226..1ab8ab7b 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryContentsClient.cs @@ -23,20 +23,7 @@ namespace Octokit.Reactive /// The name of the repository /// IObservable GetReadmeHtml(string owner, string name); - - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// - [Obsolete("Use GetArchive to download the archive instead")] - IObservable GetArchiveLink(string owner, string name); - + /// /// Get an archive of a given repository's contents /// @@ -46,20 +33,6 @@ namespace Octokit.Reactive /// A promise, containing the binary contents of the archive IObservable GetArchive(string owner, string name); - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// The format of the archive. Can be either tarball or zipball - /// - [Obsolete("Use GetArchive to download the archive instead")] - IObservable GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat); - /// /// Get an archive of a given repository's contents, in a specific format /// @@ -70,21 +43,6 @@ namespace Octokit.Reactive /// A promise, containing the binary contents of the archive IObservable GetArchive(string owner, string name, ArchiveFormat archiveFormat); - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// The format of the archive. Can be either tarball or zipball - /// A valid Git reference. - /// - [Obsolete("Use GetArchive to download the archive instead")] - IObservable GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat, string reference); - /// /// Get an archive of a given repository's contents, using a specific format and reference /// diff --git a/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs index 6d05f60b..456ce31b 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryContentsClient.cs @@ -48,23 +48,6 @@ namespace Octokit.Reactive return _client.Repository.Content.GetReadmeHtml(owner, name).ToObservable(); } - - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// - [Obsolete("Use GetArchive to download the archive instead")] - public IObservable GetArchiveLink(string owner, string name) - { - return GetArchiveLink(owner, name, ArchiveFormat.Tarball, string.Empty); - } - /// /// Get an archive of a given repository's contents /// @@ -77,23 +60,6 @@ namespace Octokit.Reactive return GetArchive(owner, name, ArchiveFormat.Tarball); } - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// The format of the archive. Can be either tarball or zipball - /// - [Obsolete("Use GetArchive to download the archive instead")] - public IObservable GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat) - { - return GetArchiveLink(owner, name, archiveFormat, string.Empty); - } - /// /// Get an archive of a given repository's contents, in a specific format /// @@ -107,27 +73,6 @@ namespace Octokit.Reactive return GetArchive(owner, name, archiveFormat, string.Empty); } - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// The format of the archive. Can be either tarball or zipball - /// A valid Git reference. - /// - [Obsolete("Use GetArchive to download the archive instead")] - public IObservable GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat, string reference) - { - Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - - return _client.Repository.Content.GetArchiveLink(owner, name, archiveFormat, reference).ToObservable(); - } - /// /// Get an archive of a given repository's contents, using a specific format and reference /// diff --git a/Octokit/Clients/IRepositoryContentsClient.cs b/Octokit/Clients/IRepositoryContentsClient.cs index daf12728..272f3c06 100644 --- a/Octokit/Clients/IRepositoryContentsClient.cs +++ b/Octokit/Clients/IRepositoryContentsClient.cs @@ -91,19 +91,6 @@ namespace Octokit /// Task GetReadmeHtml(string owner, string name); - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// - [Obsolete("Use GetArchive to download the archive instead")] - Task GetArchiveLink(string owner, string name); - /// /// Get an archive of a given repository's contents /// @@ -113,20 +100,6 @@ namespace Octokit /// The binary contents of the archive Task GetArchive(string owner, string name); - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// The format of the archive. Can be either tarball or zipball - /// - [Obsolete("Use GetArchive to download the archive instead")] - Task GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat); - /// /// Get an archive of a given repository's contents, in a specific format /// @@ -137,21 +110,6 @@ namespace Octokit /// The binary contents of the archive Task GetArchive(string owner, string name, ArchiveFormat archiveFormat); - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// The format of the archive. Can be either tarball or zipball - /// A valid Git reference. - /// - [Obsolete("Use GetArchive to download the archive instead")] - Task GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat, string reference); - /// /// Get an archive of a given repository's contents, using a specific format and reference /// diff --git a/Octokit/Clients/RepositoryContentsClient.cs b/Octokit/Clients/RepositoryContentsClient.cs index fbd1d850..16c47e35 100644 --- a/Octokit/Clients/RepositoryContentsClient.cs +++ b/Octokit/Clients/RepositoryContentsClient.cs @@ -148,22 +148,6 @@ namespace Octokit return ApiConnection.GetHtml(ApiUrls.RepositoryReadme(owner, name), null); } - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// - [Obsolete("Octokit's HTTP library now follows redirects by default - this API will be removed in a future release")] - public Task GetArchiveLink(string owner, string name) - { - return GetArchiveLink(owner, name, ArchiveFormat.Tarball, string.Empty); - } - /// /// Get an archive of a given repository's contents /// @@ -176,23 +160,6 @@ namespace Octokit return GetArchive(owner, name, ArchiveFormat.Tarball, string.Empty); } - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// The format of the archive. Can be either tarball or zipball - /// - [Obsolete("Octokit's HTTP library now follows redirects by default - this API will be removed in a future release")] - public Task GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat) - { - return GetArchiveLink(owner, name, archiveFormat, string.Empty); - } - /// /// Get an archive of a given repository's contents, in a specific format /// @@ -206,27 +173,6 @@ namespace Octokit return GetArchive(owner, name, archiveFormat, string.Empty); } - /// - /// This method will return a 302 to a URL to download a tarball or zipball archive for a repository. - /// Please make sure your HTTP framework is configured to follow redirects or you will need to use the - /// Location header to make a second GET request. - /// Note: For private repositories, these links are temporary and expire quickly. - /// - /// https://developer.github.com/v3/repos/contents/#get-archive-link - /// The owner of the repository - /// The name of the repository - /// The format of the archive. Can be either tarball or zipball - /// A valid Git reference. - /// - [Obsolete("Octokit's HTTP library now follows redirects by default - this API will be removed in a future release")] - public Task GetArchiveLink(string owner, string name, ArchiveFormat archiveFormat, string reference) - { - Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - - return ApiConnection.GetRedirect(ApiUrls.RepositoryArchiveLink(owner, name, archiveFormat, reference)); - } - /// /// Get an archive of a given repository's contents, using a specific format and reference /// From fe51d42c23460cf86ce10a0bda8a96420f9bfdaf Mon Sep 17 00:00:00 2001 From: Mordechai Zuber Date: Sun, 27 Mar 2016 11:28:33 +0300 Subject: [PATCH 094/123] Remove IConnection.Get(... allowAutoRedirect) --- Octokit/Helpers/ApiExtensions.cs | 2 +- Octokit/Http/Connection.cs | 18 ------------------ Octokit/Http/IConnection.cs | 14 -------------- 3 files changed, 1 insertion(+), 33 deletions(-) diff --git a/Octokit/Helpers/ApiExtensions.cs b/Octokit/Helpers/ApiExtensions.cs index 81b1ab8e..b0afbd42 100644 --- a/Octokit/Helpers/ApiExtensions.cs +++ b/Octokit/Helpers/ApiExtensions.cs @@ -80,7 +80,7 @@ namespace Octokit Ensure.ArgumentNotNull(connection, "connection"); Ensure.ArgumentNotNull(uri, "uri"); - return connection.Get(uri, null, null, false); + return connection.Get(uri, null, null); } /// diff --git a/Octokit/Http/Connection.cs b/Octokit/Http/Connection.cs index ed5dd957..8f7412e1 100644 --- a/Octokit/Http/Connection.cs +++ b/Octokit/Http/Connection.cs @@ -157,24 +157,6 @@ namespace Octokit return SendData(uri.ApplyParameters(parameters), HttpMethod.Get, null, accepts, null, CancellationToken.None); } - /// - /// Performs an asynchronous HTTP GET request. - /// Attempts to map the response to an object of type - /// - /// The type to map the response to - /// URI endpoint to send request to - /// Querystring parameters for the request - /// Specifies accepted response media types. - /// To follow redirect links automatically or not - /// representing the received HTTP response - [Obsolete("allowAutoRedirect is no longer respected and will be deprecated in a future release")] - public Task> Get(Uri uri, IDictionary parameters, string accepts, bool allowAutoRedirect) - { - Ensure.ArgumentNotNull(uri, "uri"); - - return SendData(uri.ApplyParameters(parameters), HttpMethod.Get, null, accepts, null, CancellationToken.None); - } - public Task> Get(Uri uri, IDictionary parameters, string accepts, CancellationToken cancellationToken) { Ensure.ArgumentNotNull(uri, "uri"); diff --git a/Octokit/Http/IConnection.cs b/Octokit/Http/IConnection.cs index 74b0ab0a..39ddac53 100644 --- a/Octokit/Http/IConnection.cs +++ b/Octokit/Http/IConnection.cs @@ -32,20 +32,6 @@ namespace Octokit [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] Task> Get(Uri uri, IDictionary parameters, string accepts); - /// - /// Performs an asynchronous HTTP GET request. - /// Attempts to map the response to an object of type - /// - /// The type to map the response to - /// URI endpoint to send request to - /// Querystring parameters for the request - /// Specifies accepted response media types. - /// To follow redirect links automatically or not - /// representing the received HTTP response - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] - [Obsolete("allowAutoRedirect is no longer respected and will be deprecated in a future release")] - Task> Get(Uri uri, IDictionary parameters, string accepts, bool allowAutoRedirect); - /// /// Performs an asynchronous HTTP GET request. /// Attempts to map the response to an object of type From cacd6020f257f18c63a3317d40206b4de23cafef Mon Sep 17 00:00:00 2001 From: Mordechai Zuber Date: Sun, 27 Mar 2016 11:29:57 +0300 Subject: [PATCH 095/123] :fire: ITeamsClient.IsMember() --- .../Clients/IObservableTeamsClient.cs | 10 -------- .../Clients/ObservableTeamsClient.cs | 15 ----------- Octokit/Clients/ITeamsClient.cs | 10 -------- Octokit/Clients/TeamsClient.cs | 25 ------------------- 4 files changed, 60 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableTeamsClient.cs b/Octokit.Reactive/Clients/IObservableTeamsClient.cs index dc17b6f4..0ca0a385 100644 --- a/Octokit.Reactive/Clients/IObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/IObservableTeamsClient.cs @@ -125,16 +125,6 @@ namespace Octokit.Reactive /// if the user was removed from the team; otherwise. IObservable RemoveMembership(int id, string login); - /// - /// Gets whether the user with the given - /// is a member of the team with the given . - /// - /// The team to check. - /// The user to check. - /// if the user is a member of the team; otherwise. - [Obsolete("Use GetMembership(id, login) to detect pending memberships")] - IObservable IsMember(int id, string login); - /// /// Gets whether the user with the given /// is a member of the team with the given . diff --git a/Octokit.Reactive/Clients/ObservableTeamsClient.cs b/Octokit.Reactive/Clients/ObservableTeamsClient.cs index 1711f78c..31f9b7aa 100644 --- a/Octokit.Reactive/Clients/ObservableTeamsClient.cs +++ b/Octokit.Reactive/Clients/ObservableTeamsClient.cs @@ -189,21 +189,6 @@ namespace Octokit.Reactive return _client.RemoveMembership(id, login).ToObservable(); } - /// - /// Gets whether the user with the given - /// is a member of the team with the given . - /// - /// The team to check. - /// The user to check. - /// if the user is a member of the team; otherwise. - [Obsolete("Use GetMembership(id, login) to detect pending memberships")] - public IObservable IsMember(int id, string login) - { - Ensure.ArgumentNotNullOrEmptyString(login, "login"); - - return _client.IsMember(id, login).ToObservable(); - } - /// /// Gets whether the user with the given /// is a member of the team with the given . diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs index ec832db3..4249acaf 100644 --- a/Octokit/Clients/ITeamsClient.cs +++ b/Octokit/Clients/ITeamsClient.cs @@ -126,16 +126,6 @@ namespace Octokit /// if the user was removed from the team; otherwise. Task RemoveMembership(int id, string login); - /// - /// Gets whether the user with the given - /// is a member of the team with the given . - /// - /// The team to check. - /// The user to check. - /// if the user is a member of the team; otherwise. - [Obsolete("Use GetMembership(id, login) as this will report on pending requests")] - Task IsMember(int id, string login); - /// /// Gets whether the user with the given /// is a member of the team with the given . diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index ae721871..3ec477ac 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -252,31 +252,6 @@ namespace Octokit } } - /// - /// Gets whether the user with the given - /// is a member of the team with the given . - /// - /// The team to check. - /// The user to check. - /// if the user is a member of the team; otherwise. - [Obsolete("Use GetMembership(id, login) as this will report on pending requests")] - public async Task IsMember(int id, string login) - { - Ensure.ArgumentNotNullOrEmptyString(login, "login"); - - var endpoint = ApiUrls.TeamMember(id, login); - - try - { - var response = await ApiConnection.Connection.GetResponse(endpoint).ConfigureAwait(false); - return response.HttpResponse.StatusCode == HttpStatusCode.NoContent; - } - catch (NotFoundException) - { - return false; - } - } - /// /// Returns all team's repositories. /// From ecee94fba6b241d83c6a8ecb2615b43ead345e2e Mon Sep 17 00:00:00 2001 From: Mordechai Zuber Date: Sun, 27 Mar 2016 12:30:31 +0300 Subject: [PATCH 096/123] :fire: Repository.SubscribersCount --- Octokit/Models/Response/Repository.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Octokit/Models/Response/Repository.cs b/Octokit/Models/Response/Repository.cs index 08aafecc..14b21b75 100644 --- a/Octokit/Models/Response/Repository.cs +++ b/Octokit/Models/Response/Repository.cs @@ -14,7 +14,7 @@ namespace Octokit Id = id; } - public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, int id, User owner, string name, string fullName, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, int subscribersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, User organization, Repository parent, Repository source, bool hasIssues, bool hasWiki, bool hasDownloads) + public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, int id, User owner, string name, string fullName, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, User organization, Repository parent, Repository source, bool hasIssues, bool hasWiki, bool hasDownloads) { Url = url; HtmlUrl = htmlUrl; @@ -34,9 +34,6 @@ namespace Octokit Fork = fork; ForksCount = forksCount; StargazersCount = stargazersCount; -#pragma warning disable 612,618 - SubscribersCount = subscribersCount; -#pragma warning restore 612,618 DefaultBranch = defaultBranch; OpenIssuesCount = openIssuesCount; PushedAt = pushedAt; @@ -89,9 +86,6 @@ namespace Octokit public int StargazersCount { get; protected set; } - [Obsolete("This property has been obsoleted. Please use WatchedClient.GetAllWatchers instead.")] - public int SubscribersCount { get; protected set; } - public string DefaultBranch { get; protected set; } public int OpenIssuesCount { get; protected set; } From e51e9fcd383461de6728fbcd9f2f7d4246ffb20c Mon Sep 17 00:00:00 2001 From: Mordechai Zuber Date: Sun, 27 Mar 2016 12:31:47 +0300 Subject: [PATCH 097/123] :fire: Repository.Organization --- Octokit/Models/Response/Repository.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Octokit/Models/Response/Repository.cs b/Octokit/Models/Response/Repository.cs index 14b21b75..84811d85 100644 --- a/Octokit/Models/Response/Repository.cs +++ b/Octokit/Models/Response/Repository.cs @@ -14,7 +14,7 @@ namespace Octokit Id = id; } - public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, int id, User owner, string name, string fullName, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, User organization, Repository parent, Repository source, bool hasIssues, bool hasWiki, bool hasDownloads) + public Repository(string url, string htmlUrl, string cloneUrl, string gitUrl, string sshUrl, string svnUrl, string mirrorUrl, int id, User owner, string name, string fullName, string description, string homepage, string language, bool @private, bool fork, int forksCount, int stargazersCount, string defaultBranch, int openIssuesCount, DateTimeOffset? pushedAt, DateTimeOffset createdAt, DateTimeOffset updatedAt, RepositoryPermissions permissions, Repository parent, Repository source, bool hasIssues, bool hasWiki, bool hasDownloads) { Url = url; HtmlUrl = htmlUrl; @@ -40,9 +40,6 @@ namespace Octokit CreatedAt = createdAt; UpdatedAt = updatedAt; Permissions = permissions; -#pragma warning disable 612, 618 - Organization = organization; -#pragma warning restore 612, 618 Parent = parent; Source = source; HasIssues = hasIssues; @@ -98,9 +95,6 @@ namespace Octokit public RepositoryPermissions Permissions { get; protected set; } - [Obsolete("This property has been obsoleted by Repository.Owner. Please use Repository.Owner.Type instead.")] - public User Organization { get; protected set; } - public Repository Parent { get; protected set; } public Repository Source { get; protected set; } From 0a0829d56852e59264c3d88a03c82b48d383de13 Mon Sep 17 00:00:00 2001 From: Mordechai Zuber Date: Sun, 27 Mar 2016 12:38:30 +0300 Subject: [PATCH 098/123] :fire: IOrganizationMembersClient.GetAll(string org, string filter) --- .../IObservableOrganizationMembersClient.cs | 9 --------- .../ObservableOrganizationMembersClient.cs | 15 --------------- Octokit/Clients/IOrganizationMembersClient.cs | 9 --------- Octokit/Clients/OrganizationMembersClient.cs | 15 --------------- 4 files changed, 48 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs b/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs index f89cef99..5d15d246 100644 --- a/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs +++ b/Octokit.Reactive/Clients/IObservableOrganizationMembersClient.cs @@ -50,15 +50,6 @@ namespace Octokit.Reactive /// IObservable GetAll(string org, OrganizationMembersFilter filter); - /// - /// Obsolete, - /// - /// The login for the organization - /// The user filter - /// The users - [Obsolete("No longer supported, use GetAll(string, OrganizationMembersFilter) instead")] - IObservable GetAll(string org, string filter); - /// /// /// List all users who are members of an organization. A member is a user that diff --git a/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs b/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs index b2b1d900..0bb84d35 100644 --- a/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs +++ b/Octokit.Reactive/Clients/ObservableOrganizationMembersClient.cs @@ -77,21 +77,6 @@ namespace Octokit.Reactive return _connection.GetAndFlattenAllPages(ApiUrls.Members(org, filter)); } - /// - /// Obsolete, - /// - /// The login for the organization - /// The user filter - /// The users - [Obsolete("No longer supported, use GetAll(string, OrganizationMembersFilter) instead")] - public IObservable GetAll(string org, string filter) - { - Ensure.ArgumentNotNullOrEmptyString(org, "org"); - Ensure.ArgumentNotNullOrEmptyString(filter, "filter"); - - return _connection.GetAndFlattenAllPages(ApiUrls.Members(org, filter)); - } - /// /// /// List all users who are members of an organization. A member is a user that diff --git a/Octokit/Clients/IOrganizationMembersClient.cs b/Octokit/Clients/IOrganizationMembersClient.cs index 3cb99a6f..61c7144b 100644 --- a/Octokit/Clients/IOrganizationMembersClient.cs +++ b/Octokit/Clients/IOrganizationMembersClient.cs @@ -57,15 +57,6 @@ namespace Octokit /// The users Task> GetAll(string org, OrganizationMembersFilter filter); - /// - /// Obsolete, - /// - /// The login for the organization - /// The user filter - /// The users - [Obsolete("No longer supported, use GetAll(string, OrganizationMembersFilter) instead")] - Task> GetAll(string org, string filter); - /// /// /// List all users who are members of an organization. A member is a user that diff --git a/Octokit/Clients/OrganizationMembersClient.cs b/Octokit/Clients/OrganizationMembersClient.cs index 3f24c984..ed6cadc5 100644 --- a/Octokit/Clients/OrganizationMembersClient.cs +++ b/Octokit/Clients/OrganizationMembersClient.cs @@ -109,21 +109,6 @@ namespace Octokit return ApiConnection.GetAll(ApiUrls.Members(org, filter)); } - /// - /// Obsolete, - /// - /// The login for the organization - /// The user filter - /// The users - [Obsolete("No longer supported, use GetAll(string, OrganizationMembersFilter) instead")] - public Task> GetAll(string org, string filter) - { - Ensure.ArgumentNotNullOrEmptyString(org, "org"); - Ensure.ArgumentNotNullOrEmptyString(filter, "filter"); - - return ApiConnection.GetAll(ApiUrls.Members(org, filter)); - } - /// /// /// List all users who are members of an organization. A member is a user that From 9ffa68492ea669955110f1dffab5afa413d29ef0 Mon Sep 17 00:00:00 2001 From: Mordechai Zuber Date: Sun, 27 Mar 2016 12:39:45 +0300 Subject: [PATCH 099/123] :fire: ApiUrls.Members(string org, string filter) --- Octokit/Helpers/ApiUrls.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 5b79dbba..9ee3213c 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -421,18 +421,6 @@ namespace Octokit return "orgs/{0}/members?filter={1}".FormatUri(org, filter.ToParameter()); } - /// - /// - /// - /// The organization - /// The member filter - /// The correct uri - [Obsolete("No longer supported, use Members(string, OrganizationMembersFilter)")] - public static Uri Members(string org, string filter) - { - return "orgs/{0}/members?filter={1}".FormatUri(org, filter); - } - /// /// Returns the that returns all of the members of the organization /// From 20d8dd285293488a7b71ac40f6c3f15fe6495160 Mon Sep 17 00:00:00 2001 From: Mordechai Zuber Date: Wed, 13 Apr 2016 12:45:38 -0400 Subject: [PATCH 100/123] Keep obsolete methods matching with interface and concrete --- Octokit/Http/IApiConnection.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Octokit/Http/IApiConnection.cs b/Octokit/Http/IApiConnection.cs index f3fe9f20..2e50e8c4 100644 --- a/Octokit/Http/IApiConnection.cs +++ b/Octokit/Http/IApiConnection.cs @@ -310,6 +310,7 @@ namespace Octokit /// URI of the API resource to get /// The URL returned by the API in the Location header /// Thrown when an API error occurs, or the API does not respond with a 302 Found + [Obsolete("Octokit's HTTP library now follows redirects by default - this API will be removed in a future release")] Task GetRedirect(Uri uri); /// From 9c77ebf00912b2f9fff89c124744d34fe2f4ec4a Mon Sep 17 00:00:00 2001 From: Elhamer Date: Thu, 14 Apr 2016 05:07:19 +0100 Subject: [PATCH 101/123] Add ApiOption overloads to methods on IIssueCommentsClient (#1267) --- .../Clients/IObservableIssueCommentsClient.cs | 21 + .../Clients/ObservableIssueCommentsClient.cs | 39 +- .../Octokit.Tests.Integration.csproj | 1 + .../ObservableIssueCommentsClientTests.cs | 92 ++++ .../Clients/IssueCommentsClientTests.cs | 425 ++++++++++-------- .../ObservableIssueCommentsClientTests.cs | 46 +- Octokit/Clients/IIssueCommentsClient.cs | 21 + Octokit/Clients/IssueCommentsClient.cs | 38 +- 8 files changed, 485 insertions(+), 198 deletions(-) create mode 100644 Octokit.Tests.Integration/Reactive/ObservableIssueCommentsClientTests.cs diff --git a/Octokit.Reactive/Clients/IObservableIssueCommentsClient.cs b/Octokit.Reactive/Clients/IObservableIssueCommentsClient.cs index bc93a4e1..906a8814 100644 --- a/Octokit.Reactive/Clients/IObservableIssueCommentsClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssueCommentsClient.cs @@ -27,6 +27,16 @@ namespace Octokit.Reactive /// The list of s for the specified Repository. IObservable GetAllForRepository(string owner, string name); + /// + /// Gets Issue Comments for a repository. + /// + /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// The list of s for the specified Repository. + IObservable GetAllForRepository(string owner, string name, ApiOptions options); + /// /// Gets Issue Comments for a specified Issue. /// @@ -37,6 +47,17 @@ namespace Octokit.Reactive /// The list of s for the specified Issue. IObservable GetAllForIssue(string owner, string name, int number); + /// + /// Gets Issue Comments for a specified Issue. + /// + /// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// Options for changing the API response + /// The list of s for the specified Issue. + IObservable GetAllForIssue(string owner, string name, int number, ApiOptions options); + /// /// Creates a new Issue Comment for a specified Issue. /// diff --git a/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs b/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs index 2a8494a4..37b4bccd 100644 --- a/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs @@ -46,7 +46,24 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return _connection.GetAndFlattenAllPages(ApiUrls.IssueComments(owner, name)); + return GetAllForRepository(owner, name, ApiOptions.None); + } + + /// + /// Gets Issue Comments for a repository. + /// + /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// The list of s for the specified Repository. + public IObservable GetAllForRepository(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.IssueComments(owner, name), options); } /// @@ -62,7 +79,25 @@ namespace Octokit.Reactive Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return _connection.GetAndFlattenAllPages(ApiUrls.IssueComments(owner, name, number)); + return GetAllForIssue(owner, name, number, ApiOptions.None); + } + + /// + /// Gets Issue Comments for a specified Issue. + /// + /// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// Options for changing the API response + /// The list of s for the specified Issue. + public IObservable GetAllForIssue(string owner, string name, int number, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.IssueComments(owner, name, number), options); } /// diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 2c972371..ef172d00 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -138,6 +138,7 @@ + diff --git a/Octokit.Tests.Integration/Reactive/ObservableIssueCommentsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableIssueCommentsClientTests.cs new file mode 100644 index 00000000..d838866d --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableIssueCommentsClientTests.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reactive.Linq; +using System.Text; +using System.Threading.Tasks; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Integration.Reactive +{ + public class ObservableIssueCommentsClientTests + { + public class TheGetAllForRepositoryMethod + { + readonly ObservableIssueCommentsClient _issueCommentsClient; + const string owner = "octokit"; + const string name = "octokit.net"; + + public TheGetAllForRepositoryMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _issueCommentsClient = new ObservableIssueCommentsClient(github); + } + + [IntegrationTest] + public async Task ReturnsIssueComments() + { + var issueComments = await _issueCommentsClient.GetAllForRepository(owner, name).ToList(); + + Assert.NotEmpty(issueComments); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfIssueCommentsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var issueComments = await _issueCommentsClient.GetAllForRepository(owner, name, options).ToList(); + + Assert.Equal(5, issueComments.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfIssueCommentsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var issueComments = await _issueCommentsClient.GetAllForRepository(owner, name, options).ToList(); + + Assert.Equal(5, issueComments.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstPageIssueComments = await _issueCommentsClient.GetAllForRepository(owner, name, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondPageIssueComments = await _issueCommentsClient.GetAllForRepository(owner, name, skipStartOptions).ToList(); + + Assert.NotEqual(firstPageIssueComments[0].Id, secondPageIssueComments[0].Id); + Assert.NotEqual(firstPageIssueComments[1].Id, secondPageIssueComments[1].Id); + Assert.NotEqual(firstPageIssueComments[2].Id, secondPageIssueComments[2].Id); + Assert.NotEqual(firstPageIssueComments[3].Id, secondPageIssueComments[3].Id); + Assert.NotEqual(firstPageIssueComments[4].Id, secondPageIssueComments[4].Id); + } + } + } +} diff --git a/Octokit.Tests/Clients/IssueCommentsClientTests.cs b/Octokit.Tests/Clients/IssueCommentsClientTests.cs index 4b0eb139..a3788f07 100644 --- a/Octokit.Tests/Clients/IssueCommentsClientTests.cs +++ b/Octokit.Tests/Clients/IssueCommentsClientTests.cs @@ -3,211 +3,252 @@ using System.Collections.Generic; using System.Net; using System.Threading.Tasks; using NSubstitute; -using Octokit; using Octokit.Internal; -using Octokit.Tests.Helpers; using Xunit; -public class IssueCommentsClientTests +namespace Octokit.Tests.Clients { - public class TheGetMethod + public class IssueCommentsClientTests { - [Fact] - public void RequestsCorrectUrl() + public class TheGetMethod { - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); - client.Get("fake", "repo", 42); + client.Get("fake", "repo", 42); - connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/42")); + connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/42")); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new IssueCommentsClient(Substitute.For()); + + await Assert.ThrowsAsync(() => client.Get(null, "name", 1)); + await Assert.ThrowsAsync(() => client.Get("", "name", 1)); + await Assert.ThrowsAsync(() => client.Get("owner", null, 1)); + await Assert.ThrowsAsync(() => client.Get("owner", "", 1)); + } + } + + public class TheGetForRepositoryMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); + + client.GetAllForRepository("fake", "repo"); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); + + var options = new ApiOptions() + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + client.GetAllForRepository("fake", "repo", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments"), options); + } + + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); + + await Assert.ThrowsAsync(() => client.GetAllForRepository(null, "name")); + await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name")); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null)); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "")); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name", null)); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "", ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name", ApiOptions.None)); + } + } + + public class TheGetForIssueMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); + + client.GetAllForIssue("fake", "repo", 3); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/3/comments"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); + + var options = new ApiOptions() + { + StartPage = 1, + PageSize = 1, + PageCount = 1 + }; + client.GetAllForIssue("fake", "repo", 3, options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/3/comments"), options); + } + + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); + + await Assert.ThrowsAsync(() => client.GetAllForIssue(null, "name", 1)); + await Assert.ThrowsAsync(() => client.GetAllForIssue("", "name", 1)); + await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", null, 1)); + await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "", 1)); + await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "name", 1, null)); + await Assert.ThrowsAsync(() => client.GetAllForIssue("", "name", 1, ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "", 1, ApiOptions.None)); + } + } + + public class TheCreateMethod + { + [Fact] + public void PostsToCorrectUrl() + { + const string newComment = "some title"; + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); + + client.Create("fake", "repo", 1, newComment); + + connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/1/comments"), Arg.Any()); + } + + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); + + await Assert.ThrowsAsync(() => client.Create(null, "name", 1, "title")); + await Assert.ThrowsAsync(() => client.Create("", "name", 1, "x")); + await Assert.ThrowsAsync(() => client.Create("owner", null, 1, "x")); + await Assert.ThrowsAsync(() => client.Create("owner", "", 1, "x")); + await Assert.ThrowsAsync(() => client.Create("owner", "name", 1, null)); + } + } + + public class TheUpdateMethod + { + [Fact] + public void PostsToCorrectUrl() + { + const string issueCommentUpdate = "Worthwhile update"; + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); + + client.Update("fake", "repo", 42, issueCommentUpdate); + + connection.Received().Patch(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/42"), Arg.Any()); + } + + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); + + await Assert.ThrowsAsync(() => client.Update(null, "name", 42, "title")); + await Assert.ThrowsAsync(() => client.Update("", "name", 42, "x")); + await Assert.ThrowsAsync(() => client.Update("owner", null, 42, "x")); + await Assert.ThrowsAsync(() => client.Update("owner", "", 42, "x")); + await Assert.ThrowsAsync(() => client.Update("owner", "name", 42, null)); + } + } + + public class TheDeleteMethod + { + [Fact] + public void DeletesCorrectUrl() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); + + client.Delete("fake", "repo", 42); + + connection.Received().Delete(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/42")); + } + + [Fact] + public async Task EnsuresArgumentsNotNullOrEmpty() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); + + await Assert.ThrowsAsync(() => client.Delete(null, "name", 42)); + await Assert.ThrowsAsync(() => client.Delete("", "name", 42)); + await Assert.ThrowsAsync(() => client.Delete("owner", null, 42)); + await Assert.ThrowsAsync(() => client.Delete("owner", "", 42)); + } + } + + public class TheCtor + { + [Fact] + public void EnsuresArgument() + { + Assert.Throws(() => new IssueCommentsClient(null)); + } } [Fact] - public async Task EnsuresNonNullArguments() + public void CanDeserializeIssueComment() { - var client = new IssueCommentsClient(Substitute.For()); + const string issueResponseJson = + "{\"id\": 1," + + "\"url\": \"https://api.github.com/repos/octocat/Hello-World/issues/comments/1\"," + + "\"html_url\": \"https://github.com/octocat/Hello-World/issues/1347#issuecomment-1\"," + + "\"body\": \"Me too\"," + + "\"user\": {" + + "\"login\": \"octocat\"," + + "\"id\": 1," + + "\"avatar_url\": \"https://github.com/images/error/octocat_happy.gif\"," + + "\"gravatar_id\": \"somehexcode\"," + + "\"url\": \"https://api.github.com/users/octocat\"" + + "}," + + "\"created_at\": \"2011-04-14T16:00:49Z\"," + + "\"updated_at\": \"2011-04-14T16:00:49Z\"" + + "}"; + var httpResponse = new Response( + HttpStatusCode.OK, + issueResponseJson, + new Dictionary(), + "application/json"); - await Assert.ThrowsAsync(() => client.Get(null, "name", 1)); - await Assert.ThrowsAsync(() => client.Get("", "name", 1)); - await Assert.ThrowsAsync(() => client.Get("owner", null, 1)); - await Assert.ThrowsAsync(() => client.Get("owner", "", 1)); + var jsonPipeline = new JsonHttpPipeline(); + + var response = jsonPipeline.DeserializeResponse(httpResponse); + + Assert.NotNull(response.Body); + Assert.Equal(issueResponseJson, response.HttpResponse.Body); + Assert.Equal(1, response.Body.Id); } } - - public class TheGetForRepositoryMethod - { - [Fact] - public void RequestsCorrectUrl() - { - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); - - client.GetAllForRepository("fake", "repo"); - - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments")); - } - - [Fact] - public async Task EnsuresArgumentsNotNull() - { - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); - - await Assert.ThrowsAsync(() => client.GetAllForRepository(null, "name")); - await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name")); - await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null)); - await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "")); - } - } - - public class TheGetForIssueMethod - { - [Fact] - public void RequestsCorrectUrl() - { - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); - - client.GetAllForIssue("fake", "repo", 3); - - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/3/comments")); - } - - [Fact] - public async Task EnsuresArgumentsNotNull() - { - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); - - await Assert.ThrowsAsync(() => client.GetAllForIssue(null, "name", 1)); - await Assert.ThrowsAsync(() => client.GetAllForIssue("", "name", 1)); - await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", null, 1)); - await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "", 1)); - } - } - - public class TheCreateMethod - { - [Fact] - public void PostsToCorrectUrl() - { - const string newComment = "some title"; - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); - - client.Create("fake", "repo", 1, newComment); - - connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/1/comments"), Arg.Any()); - } - - [Fact] - public async Task EnsuresArgumentsNotNull() - { - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); - - await Assert.ThrowsAsync(() => client.Create(null, "name", 1, "title")); - await Assert.ThrowsAsync(() => client.Create("", "name", 1, "x")); - await Assert.ThrowsAsync(() => client.Create("owner", null, 1, "x")); - await Assert.ThrowsAsync(() => client.Create("owner", "", 1, "x")); - await Assert.ThrowsAsync(() => client.Create("owner", "name", 1, null)); - } - } - - public class TheUpdateMethod - { - [Fact] - public void PostsToCorrectUrl() - { - const string issueCommentUpdate = "Worthwhile update"; - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); - - client.Update("fake", "repo", 42, issueCommentUpdate); - - connection.Received().Patch(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/42"), Arg.Any()); - } - - [Fact] - public async Task EnsuresArgumentsNotNull() - { - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); - - await Assert.ThrowsAsync(() => client.Update(null, "name", 42, "title")); - await Assert.ThrowsAsync(() => client.Update("", "name", 42, "x")); - await Assert.ThrowsAsync(() => client.Update("owner", null, 42, "x")); - await Assert.ThrowsAsync(() => client.Update("owner", "", 42, "x")); - await Assert.ThrowsAsync(() => client.Update("owner", "name", 42, null)); - } - } - - public class TheDeleteMethod - { - [Fact] - public void DeletesCorrectUrl() - { - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); - - client.Delete("fake", "repo", 42); - - connection.Received().Delete(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/42")); - } - - [Fact] - public async Task EnsuresArgumentsNotNullOrEmpty() - { - var connection = Substitute.For(); - var client = new IssueCommentsClient(connection); - - await Assert.ThrowsAsync(() => client.Delete(null, "name", 42)); - await Assert.ThrowsAsync(() => client.Delete("", "name", 42)); - await Assert.ThrowsAsync(() => client.Delete("owner", null, 42)); - await Assert.ThrowsAsync(() => client.Delete("owner", "", 42)); - } - } - - public class TheCtor - { - [Fact] - public void EnsuresArgument() - { - Assert.Throws(() => new IssueCommentsClient(null)); - } - } - - [Fact] - public void CanDeserializeIssueComment() - { - const string issueResponseJson = - "{\"id\": 1," + - "\"url\": \"https://api.github.com/repos/octocat/Hello-World/issues/comments/1\"," + - "\"html_url\": \"https://github.com/octocat/Hello-World/issues/1347#issuecomment-1\"," + - "\"body\": \"Me too\"," + - "\"user\": {" + - "\"login\": \"octocat\"," + - "\"id\": 1," + - "\"avatar_url\": \"https://github.com/images/error/octocat_happy.gif\"," + - "\"gravatar_id\": \"somehexcode\"," + - "\"url\": \"https://api.github.com/users/octocat\"" + - "}," + - "\"created_at\": \"2011-04-14T16:00:49Z\"," + - "\"updated_at\": \"2011-04-14T16:00:49Z\"" + - "}"; - var httpResponse = new Response( - HttpStatusCode.OK, - issueResponseJson, - new Dictionary(), - "application/json"); - - var jsonPipeline = new JsonHttpPipeline(); - - var response = jsonPipeline.DeserializeResponse(httpResponse); - - Assert.NotNull(response.Body); - Assert.Equal(issueResponseJson, response.HttpResponse.Body); - Assert.Equal(1, response.Body.Id); - } } diff --git a/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs b/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs index 96552397..958ff020 100644 --- a/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs @@ -48,7 +48,25 @@ namespace Octokit.Tests.Reactive client.GetAllForRepository("fake", "repo"); gitHubClient.Connection.Received(1).Get>( - new Uri("repos/fake/repo/issues/comments", UriKind.Relative), null, null); + new Uri("repos/fake/repo/issues/comments", UriKind.Relative), Args.EmptyDictionary, null); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableIssueCommentsClient(gitHubClient); + + var options=new ApiOptions() + { + StartPage = 1, + PageSize = 1, + PageCount = 1 + }; + client.GetAllForRepository("fake", "repo", options); + + gitHubClient.Connection.Received(1).Get>( + new Uri("repos/fake/repo/issues/comments", UriKind.Relative), Arg.Any>(), null); } [Fact] @@ -61,6 +79,9 @@ namespace Octokit.Tests.Reactive await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name").ToTask()); await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null).ToTask()); await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "").ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name", null).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name", ApiOptions.None).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "", ApiOptions.None).ToTask()); } } @@ -75,7 +96,25 @@ namespace Octokit.Tests.Reactive client.GetAllForIssue("fake", "repo", 3); gitHubClient.Connection.Received(1).Get>( - new Uri("repos/fake/repo/issues/3/comments", UriKind.Relative), null, null); + new Uri("repos/fake/repo/issues/3/comments", UriKind.Relative), Args.EmptyDictionary, null); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableIssueCommentsClient(gitHubClient); + + var options=new ApiOptions() + { + StartPage = 1, + PageSize = 1, + PageCount = 1 + }; + client.GetAllForIssue("fake", "repo", 3, options); + + gitHubClient.Connection.Received(1).Get>( + new Uri("repos/fake/repo/issues/3/comments", UriKind.Relative), Arg.Any>(), null); } [Fact] @@ -88,6 +127,9 @@ namespace Octokit.Tests.Reactive await Assert.ThrowsAsync(() => client.GetAllForIssue("", "name", 1).ToTask()); await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", null, 1).ToTask()); await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "", 1).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "name", 1, null).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForIssue("", "name", 1, ApiOptions.None).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "", 1, ApiOptions.None).ToTask()); } } diff --git a/Octokit/Clients/IIssueCommentsClient.cs b/Octokit/Clients/IIssueCommentsClient.cs index 1e091d28..147c3b84 100644 --- a/Octokit/Clients/IIssueCommentsClient.cs +++ b/Octokit/Clients/IIssueCommentsClient.cs @@ -33,6 +33,16 @@ namespace Octokit /// Task> GetAllForRepository(string owner, string name); + /// + /// Gets Issue Comments for a repository. + /// + /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// + Task> GetAllForRepository(string owner, string name, ApiOptions options); + /// /// Gets Issue Comments for a specified Issue. /// @@ -43,6 +53,17 @@ namespace Octokit /// Task> GetAllForIssue(string owner, string name, int number); + /// + /// Gets Issue Comments for a specified Issue. + /// + /// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// Options for changing the API response + /// + Task> GetAllForIssue(string owner, string name, int number, ApiOptions options); + /// /// Creates a new Issue Comment for a specified Issue. /// diff --git a/Octokit/Clients/IssueCommentsClient.cs b/Octokit/Clients/IssueCommentsClient.cs index 05b00e12..54748f77 100644 --- a/Octokit/Clients/IssueCommentsClient.cs +++ b/Octokit/Clients/IssueCommentsClient.cs @@ -47,7 +47,24 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return ApiConnection.GetAll(ApiUrls.IssueComments(owner, name)); + return GetAllForRepository(owner, name, ApiOptions.None); + } + + /// + /// Gets Issue Comments for a repository. + /// + /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// + public Task> GetAllForRepository(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.IssueComments(owner, name), options); } /// @@ -63,7 +80,24 @@ namespace Octokit Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return ApiConnection.GetAll(ApiUrls.IssueComments(owner, name, number)); + return GetAllForIssue(owner, name, number, ApiOptions.None); + } + /// + /// Gets Issue Comments for a specified Issue. + /// + /// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// Options for changing the API response + /// + public Task> GetAllForIssue(string owner, string name, int number, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.IssueComments(owner, name, number), options); } /// From 3f8f7822738872c29fbc8af8a605433d7883f345 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Wed, 6 Apr 2016 13:48:13 +0700 Subject: [PATCH 102/123] Additional convention test were added. --- .../MissingConstructorTestClassException.cs | 16 +++++++++ .../Octokit.Tests.Conventions.csproj | 2 ++ .../TestConstructorTests.cs | 34 +++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 Octokit.Tests.Conventions/Exception/MissingConstructorTestClassException.cs create mode 100644 Octokit.Tests.Conventions/TestConstructorTests.cs diff --git a/Octokit.Tests.Conventions/Exception/MissingConstructorTestClassException.cs b/Octokit.Tests.Conventions/Exception/MissingConstructorTestClassException.cs new file mode 100644 index 00000000..6932b4ec --- /dev/null +++ b/Octokit.Tests.Conventions/Exception/MissingConstructorTestClassException.cs @@ -0,0 +1,16 @@ +using System; + +namespace Octokit.Tests.Conventions +{ + public class MissingConstructorTestClassException : Exception + { + public MissingConstructorTestClassException(Type modelType) + : base(CreateMessage(modelType)) + { } + + static string CreateMessage(Type ctorTest) + { + return string.Format("Constructor test method is missing {0}.", ctorTest.FullName); + } + } +} \ No newline at end of file diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index c6012156..8f3c5695 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -64,6 +64,7 @@ + @@ -81,6 +82,7 @@ + diff --git a/Octokit.Tests.Conventions/TestConstructorTests.cs b/Octokit.Tests.Conventions/TestConstructorTests.cs new file mode 100644 index 00000000..c3ef0f2f --- /dev/null +++ b/Octokit.Tests.Conventions/TestConstructorTests.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Octokit.Tests.Clients; +using Xunit; + +namespace Octokit.Tests.Conventions +{ + public class TestConstructorTests + { + [Theory] + [MemberData("GetTestConstructorsClasses")] + public void CheckTestConstructorsNames(Type type) + { + const string constructorClassName = "TheCtor"; + var classes = new HashSet(type.GetNestedTypes().Select(t => t.Name)); + + if (!classes.Contains(constructorClassName)) + { + throw new MissingConstructorTestClassException(type); + } + } + + public static IEnumerable GetTestConstructorsClasses() + { + var tests = typeof(EventsClientTests) + .Assembly + .ExportedTypes + .Where(type => type.IsClass && type.IsPublic && type.Name.EndsWith("ClientTests")) + .Select(type => new[] { type }).ToList(); + return tests; + } + } +} \ No newline at end of file From d0c8e8245322b79f92fd5d12c6fd3cd9fbf886aa Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Wed, 6 Apr 2016 14:39:41 +0700 Subject: [PATCH 103/123] Red Tests were fixed Unused 'using' directive were removed. --- .../Clients/ReleasesClientTests.cs | 10 ++++++++++ .../Clients/AuthorizationsClientTests.cs | 2 +- Octokit.Tests/Clients/BlobClientTests.cs | 10 +++++++++- .../Clients/CommitStatusClientTests.cs | 2 +- .../EnterpriseAdminStatsClientTests.cs | 10 ++++++++++ .../Enterprise/EnterpriseLdapClientTests.cs | 10 ++++++++++ .../Enterprise/EnterpriseLicenseClientTests.cs | 10 ++++++++++ .../EnterpriseOrganizationClientTests.cs | 10 ++++++++++ .../EnterpriseSearchIndexingClientTests.cs | 10 ++++++++++ Octokit.Tests/Clients/EventsClientTests.cs | 12 ++++++++++-- Octokit.Tests/Clients/FeedsClientTests.cs | 4 +--- Octokit.Tests/Clients/FollowersClientTests.cs | 5 +---- .../Clients/IssuesEventsClientTests.cs | 11 ++++++++++- .../Clients/IssuesLabelsClientTests.cs | 11 ++++++++++- .../Clients/NotificationsClientTests.cs | 10 ++++++++++ Octokit.Tests/Clients/OauthClientTests.cs | 10 ++++++++++ .../Clients/OrganizationMembersClientTests.cs | 2 +- .../Clients/OrganizationsClientTests.cs | 3 +-- .../PullRequestReviewCommentsClientTests.cs | 3 +-- Octokit.Tests/Clients/ReleasesClientTests.cs | 10 ++++++++++ .../Clients/RepoCollaboratorsClientTests.cs | 3 +-- .../Clients/RepositoriesClientTests.cs | 2 +- .../Clients/RepositoryContentsClientTests.cs | 10 ++++++++++ .../Clients/RepositoryDeployKeysClientTests.cs | 2 +- .../Clients/RepositoryForksClientTests.cs | 10 ++++++++++ .../Clients/RepositoryHooksClientTest.cs | 10 ++++++++++ .../Clients/RepositoryPagesClientTests.cs | 10 ++++++++++ Octokit.Tests/Clients/SearchClientTests.cs | 2 +- Octokit.Tests/Clients/SshKeysClientTests.cs | 3 +-- Octokit.Tests/Clients/StarredClientTests.cs | 10 ++++++++++ Octokit.Tests/Clients/StatisticsClientTests.cs | 2 +- Octokit.Tests/Clients/TeamsClientTests.cs | 2 +- .../Clients/UserAdministrationClientTests.cs | 10 ++++++++++ Octokit.Tests/Clients/UsersClientTests.cs | 4 +--- Octokit.Tests/Clients/WatchedClientTests.cs | 10 ++++++++++ .../TwoFactorRequiredExceptionTests.cs | 8 ++------ Octokit.Tests/GitHubClientTests.cs | 4 +--- .../ObservableEnterpriseLdapClientTests.cs | 10 ++++++++++ .../ObservableEnterpriseLicenseClientTests.cs | 10 ++++++++++ ...ervableEnterpriseOrganizationClientTests.cs | 10 ++++++++++ ...vableEnterpriseSearchIndexingClientTests.cs | 13 ++++++++++++- .../Reactive/ObservableCommitsClientTests.cs | 2 +- .../Reactive/ObservableEventsClientTests.cs | 12 ++++++++++-- .../Reactive/ObservableFeedsClientTests.cs | 18 ++++++++++++------ ...ObservableOrganizationMembersClientTests.cs | 14 ++++++++++---- ...ablePullRequestReviewCommentsClientTests.cs | 11 ++++++++++- .../Reactive/ObservableReleasesClientTests.cs | 2 +- .../ObservableRepositoriesClientTests.cs | 10 ++++++++++ ...bservableRepositoryDeployKeysClientTests.cs | 6 +----- .../Reactive/ObservableStarredClientTests.cs | 15 +++++++++------ .../ObservableStatisticsClientTests.cs | 11 +++++++++-- .../Reactive/ObservableTreesClientTests.cs | 11 +++++++++-- 52 files changed, 341 insertions(+), 71 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs b/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs index a60b1d26..fcd28c0c 100644 --- a/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/ReleasesClientTests.cs @@ -12,6 +12,16 @@ using Xunit; public class ReleasesClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ReleasesClient(null)); + } + } + public class TheGetReleasesMethod : IDisposable { private readonly IReleasesClient _releaseClient; diff --git a/Octokit.Tests/Clients/AuthorizationsClientTests.cs b/Octokit.Tests/Clients/AuthorizationsClientTests.cs index 882d5cd9..4e11ecd1 100644 --- a/Octokit.Tests/Clients/AuthorizationsClientTests.cs +++ b/Octokit.Tests/Clients/AuthorizationsClientTests.cs @@ -14,7 +14,7 @@ namespace Octokit.Tests.Clients /// public class AuthorizationsClientTests { - public class TheConstructor + public class TheCtor { [Fact] public void ThrowsForBadArgs() diff --git a/Octokit.Tests/Clients/BlobClientTests.cs b/Octokit.Tests/Clients/BlobClientTests.cs index d480473e..c40a380f 100644 --- a/Octokit.Tests/Clients/BlobClientTests.cs +++ b/Octokit.Tests/Clients/BlobClientTests.cs @@ -4,13 +4,21 @@ using System.Net; using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients { public class BlobClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new BlobsClient(null)); + } + } + public class TheGetMethod { [Fact] diff --git a/Octokit.Tests/Clients/CommitStatusClientTests.cs b/Octokit.Tests/Clients/CommitStatusClientTests.cs index 6dd5689f..94c2a907 100644 --- a/Octokit.Tests/Clients/CommitStatusClientTests.cs +++ b/Octokit.Tests/Clients/CommitStatusClientTests.cs @@ -133,7 +133,7 @@ namespace Octokit.Tests.Clients } } - public class TheConstructor + public class TheCtor { [Fact] public void EnsuresNonNullArguments() diff --git a/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs index 1fe3bfa9..2fd61426 100644 --- a/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs +++ b/Octokit.Tests/Clients/Enterprise/EnterpriseAdminStatsClientTests.cs @@ -159,5 +159,15 @@ namespace Octokit.Tests.Clients connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); } } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new EnterpriseAdminStatsClient(null)); + } + } } } \ No newline at end of file diff --git a/Octokit.Tests/Clients/Enterprise/EnterpriseLdapClientTests.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseLdapClientTests.cs index d5ea1c4d..ace67720 100644 --- a/Octokit.Tests/Clients/Enterprise/EnterpriseLdapClientTests.cs +++ b/Octokit.Tests/Clients/Enterprise/EnterpriseLdapClientTests.cs @@ -130,5 +130,15 @@ namespace Octokit.Tests.Clients Arg.Is(u => u.ToString() == expectedUri)); } } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new EnterpriseLdapClient(null)); + } + } } } diff --git a/Octokit.Tests/Clients/Enterprise/EnterpriseLicenseClientTests.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseLicenseClientTests.cs index 947fa4a2..2a9e0042 100644 --- a/Octokit.Tests/Clients/Enterprise/EnterpriseLicenseClientTests.cs +++ b/Octokit.Tests/Clients/Enterprise/EnterpriseLicenseClientTests.cs @@ -19,5 +19,15 @@ namespace Octokit.Tests.Clients connection.Received().Get(Arg.Is(u => u.ToString() == expectedUri)); } } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new EnterpriseLicenseClient(null)); + } + } } } diff --git a/Octokit.Tests/Clients/Enterprise/EnterpriseOrganizationClientTests.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseOrganizationClientTests.cs index b3c815b5..0d34f6c2 100644 --- a/Octokit.Tests/Clients/Enterprise/EnterpriseOrganizationClientTests.cs +++ b/Octokit.Tests/Clients/Enterprise/EnterpriseOrganizationClientTests.cs @@ -46,5 +46,15 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.Create(null)); } } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new EnterpriseOrganizationClient(null)); + } + } } } diff --git a/Octokit.Tests/Clients/Enterprise/EnterpriseSearchIndexingClientTests.cs b/Octokit.Tests/Clients/Enterprise/EnterpriseSearchIndexingClientTests.cs index e347c005..c4b247d8 100644 --- a/Octokit.Tests/Clients/Enterprise/EnterpriseSearchIndexingClientTests.cs +++ b/Octokit.Tests/Clients/Enterprise/EnterpriseSearchIndexingClientTests.cs @@ -7,6 +7,16 @@ namespace Octokit.Tests.Clients { public class EnterpriseSearchIndexingClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new EnterpriseSearchIndexingClient(null)); + } + } + public class TheQueueMethod { [Fact] diff --git a/Octokit.Tests/Clients/EventsClientTests.cs b/Octokit.Tests/Clients/EventsClientTests.cs index 3defac5b..124533e9 100644 --- a/Octokit.Tests/Clients/EventsClientTests.cs +++ b/Octokit.Tests/Clients/EventsClientTests.cs @@ -6,14 +6,22 @@ using System.Threading; using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; -using Octokit; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients { public class EventsClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new EventsClient(null)); + } + } + public class TheGetAllMethod { [Fact] diff --git a/Octokit.Tests/Clients/FeedsClientTests.cs b/Octokit.Tests/Clients/FeedsClientTests.cs index 603e96a7..e532d134 100644 --- a/Octokit.Tests/Clients/FeedsClientTests.cs +++ b/Octokit.Tests/Clients/FeedsClientTests.cs @@ -1,7 +1,5 @@ using System; -using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -12,7 +10,7 @@ namespace Octokit.Tests.Clients /// public class FeedsClientTests { - public class TheConstructor + public class TheCtor { [Fact] public void EnsuresNonNullArguments() diff --git a/Octokit.Tests/Clients/FollowersClientTests.cs b/Octokit.Tests/Clients/FollowersClientTests.cs index 921b1a2f..29314bbd 100644 --- a/Octokit.Tests/Clients/FollowersClientTests.cs +++ b/Octokit.Tests/Clients/FollowersClientTests.cs @@ -4,10 +4,7 @@ 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 { @@ -17,7 +14,7 @@ namespace Octokit.Tests.Clients /// public class FollowersClientTests { - public class TheConstructor + public class TheCtor { [Fact] public void EnsuresNonNullArguments() diff --git a/Octokit.Tests/Clients/IssuesEventsClientTests.cs b/Octokit.Tests/Clients/IssuesEventsClientTests.cs index 4249ea52..98f20170 100644 --- a/Octokit.Tests/Clients/IssuesEventsClientTests.cs +++ b/Octokit.Tests/Clients/IssuesEventsClientTests.cs @@ -1,13 +1,22 @@ using System; using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients { public class IssuesEventsClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new IssuesEventsClient(null)); + } + } + public class TheGetForIssueMethod { [Fact] diff --git a/Octokit.Tests/Clients/IssuesLabelsClientTests.cs b/Octokit.Tests/Clients/IssuesLabelsClientTests.cs index 737296b3..d614af4c 100644 --- a/Octokit.Tests/Clients/IssuesLabelsClientTests.cs +++ b/Octokit.Tests/Clients/IssuesLabelsClientTests.cs @@ -1,7 +1,6 @@ using System; using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; using System.Collections.Generic; @@ -9,6 +8,16 @@ namespace Octokit.Tests.Clients { public class IssuesLabelsClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new IssuesLabelsClient(null)); + } + } + public class TheGetForIssueMethod { [Fact] diff --git a/Octokit.Tests/Clients/NotificationsClientTests.cs b/Octokit.Tests/Clients/NotificationsClientTests.cs index f75eff4d..97a8dd13 100644 --- a/Octokit.Tests/Clients/NotificationsClientTests.cs +++ b/Octokit.Tests/Clients/NotificationsClientTests.cs @@ -6,6 +6,16 @@ namespace Octokit.Tests.Clients { public class NotificationsClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new NotificationsClient(null)); + } + } + public class TheGetAllForCurrentMethod { [Fact] diff --git a/Octokit.Tests/Clients/OauthClientTests.cs b/Octokit.Tests/Clients/OauthClientTests.cs index 8b43e065..9bbbff77 100644 --- a/Octokit.Tests/Clients/OauthClientTests.cs +++ b/Octokit.Tests/Clients/OauthClientTests.cs @@ -9,6 +9,16 @@ using Xunit; public class OauthClientTests { + public class TheCtor + { + [Fact] + public void EnsuresArgumentIsNotNull() + { + Assert.Throws(() => + new OauthClient(null)); + } + } + public class TheGetGitHubLoginUrlMethod { [Theory] diff --git a/Octokit.Tests/Clients/OrganizationMembersClientTests.cs b/Octokit.Tests/Clients/OrganizationMembersClientTests.cs index b35b60f7..9992ab7b 100644 --- a/Octokit.Tests/Clients/OrganizationMembersClientTests.cs +++ b/Octokit.Tests/Clients/OrganizationMembersClientTests.cs @@ -15,7 +15,7 @@ namespace Octokit.Tests.Clients /// public class OrganizationMembersClientTests { - public class TheConstructor + public class TheCtor { [Fact] public void EnsureNonNullArguments() diff --git a/Octokit.Tests/Clients/OrganizationsClientTests.cs b/Octokit.Tests/Clients/OrganizationsClientTests.cs index 94bb63e5..518de8cc 100644 --- a/Octokit.Tests/Clients/OrganizationsClientTests.cs +++ b/Octokit.Tests/Clients/OrganizationsClientTests.cs @@ -1,7 +1,6 @@ using System; using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -12,7 +11,7 @@ namespace Octokit.Tests.Clients /// public class OrganizationsClientTests { - public class TheConstructor + public class TheCtor { [Fact] public void EnsuresNonNullArguments() diff --git a/Octokit.Tests/Clients/PullRequestReviewCommentsClientTests.cs b/Octokit.Tests/Clients/PullRequestReviewCommentsClientTests.cs index 83e1e3e1..8ab043ed 100644 --- a/Octokit.Tests/Clients/PullRequestReviewCommentsClientTests.cs +++ b/Octokit.Tests/Clients/PullRequestReviewCommentsClientTests.cs @@ -3,12 +3,11 @@ using System.Collections.Generic; using System.Threading.Tasks; using NSubstitute; using Octokit; -using Octokit.Tests.Helpers; using Xunit; public class PullRequestReviewCommentsClientTests { - public class TheModelConstructors + public class TheCtor { [Fact] public void PullRequestReviewCommentCreateEnsuresArgumentsValue() diff --git a/Octokit.Tests/Clients/ReleasesClientTests.cs b/Octokit.Tests/Clients/ReleasesClientTests.cs index 645ce6c2..bb436d0f 100644 --- a/Octokit.Tests/Clients/ReleasesClientTests.cs +++ b/Octokit.Tests/Clients/ReleasesClientTests.cs @@ -8,6 +8,16 @@ namespace Octokit.Tests.Clients { public class ReleasesClientTests { + public class TheCtor + { + [Fact] + public void EnsuresArgumentIsNotNull() + { + Assert.Throws(() => + new ReleasesClient(null)); + } + } + public class TheGetAllMethod { [Fact] diff --git a/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs b/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs index 7c7ddfbc..efeef7aa 100644 --- a/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs +++ b/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; using System.Net; using Octokit.Internal; @@ -15,7 +14,7 @@ namespace Octokit.Tests.Clients /// public class RepoCollaboratorsClientTests { - public class TheConstructor + public class TheCtor { [Fact] public void ThrowsForBadArgs() diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index 6789f048..833045aa 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -13,7 +13,7 @@ namespace Octokit.Tests.Clients /// public class RepositoriesClientTests { - public class TheConstructor + public class TheCtor { [Fact] public void EnsuresNonNullArguments() diff --git a/Octokit.Tests/Clients/RepositoryContentsClientTests.cs b/Octokit.Tests/Clients/RepositoryContentsClientTests.cs index 2f700c3b..11648733 100644 --- a/Octokit.Tests/Clients/RepositoryContentsClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryContentsClientTests.cs @@ -9,6 +9,16 @@ namespace Octokit.Tests.Clients { public class RepositoryContentsClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new RepositoryContentsClient(null)); + } + } + public class TheGetReadmeMethod { [Fact] diff --git a/Octokit.Tests/Clients/RepositoryDeployKeysClientTests.cs b/Octokit.Tests/Clients/RepositoryDeployKeysClientTests.cs index 96943c96..40037fdb 100644 --- a/Octokit.Tests/Clients/RepositoryDeployKeysClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryDeployKeysClientTests.cs @@ -11,7 +11,7 @@ namespace Octokit.Tests.Clients /// public class RepositoryDeployKeysClientTests { - public class TheConstructor + public class TheCtor { [Fact] public void ThrowsForBadArgs() diff --git a/Octokit.Tests/Clients/RepositoryForksClientTests.cs b/Octokit.Tests/Clients/RepositoryForksClientTests.cs index c5a5bfb2..acc0f47a 100644 --- a/Octokit.Tests/Clients/RepositoryForksClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryForksClientTests.cs @@ -8,6 +8,16 @@ namespace Octokit.Tests.Clients { public class RepositoryForksClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new RepositoryForksClient(null)); + } + } + public class TheGetAllMethod { [Fact] diff --git a/Octokit.Tests/Clients/RepositoryHooksClientTest.cs b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs index 908e0648..9175e2aa 100644 --- a/Octokit.Tests/Clients/RepositoryHooksClientTest.cs +++ b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs @@ -8,6 +8,16 @@ namespace Octokit.Tests.Clients { public class RepositoryHooksClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new RepositoryHooksClient(null)); + } + } + public class TheGetAllMethod { [Fact] diff --git a/Octokit.Tests/Clients/RepositoryPagesClientTests.cs b/Octokit.Tests/Clients/RepositoryPagesClientTests.cs index dbafeb1a..1bc0578b 100644 --- a/Octokit.Tests/Clients/RepositoryPagesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryPagesClientTests.cs @@ -7,6 +7,16 @@ namespace Octokit.Tests.Clients { public class RepositoryPagesClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new RepositoryPagesClient(null)); + } + } + public class TheGetMethod { [Fact] diff --git a/Octokit.Tests/Clients/SearchClientTests.cs b/Octokit.Tests/Clients/SearchClientTests.cs index b26c4191..ef3e7afa 100644 --- a/Octokit.Tests/Clients/SearchClientTests.cs +++ b/Octokit.Tests/Clients/SearchClientTests.cs @@ -12,7 +12,7 @@ namespace Octokit.Tests.Clients /// public class SearchClientTests { - public class TheConstructor + public class TheCtor { [Fact] public void EnsuresNonNullArguments() diff --git a/Octokit.Tests/Clients/SshKeysClientTests.cs b/Octokit.Tests/Clients/SshKeysClientTests.cs index a9b833be..cdbf93a0 100644 --- a/Octokit.Tests/Clients/SshKeysClientTests.cs +++ b/Octokit.Tests/Clients/SshKeysClientTests.cs @@ -1,7 +1,6 @@ using System; using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -12,7 +11,7 @@ namespace Octokit.Tests.Clients /// public class SshKeysClientTests { - public class TheConstructor + public class TheCtor { [Fact] public void ThrowsForBadArgs() diff --git a/Octokit.Tests/Clients/StarredClientTests.cs b/Octokit.Tests/Clients/StarredClientTests.cs index 97add0e4..e0543bad 100644 --- a/Octokit.Tests/Clients/StarredClientTests.cs +++ b/Octokit.Tests/Clients/StarredClientTests.cs @@ -10,6 +10,16 @@ namespace Octokit.Tests.Clients { public class StarredClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new StarredClient(null)); + } + } + public class TheGetAllForCurrentMethod { [Fact] diff --git a/Octokit.Tests/Clients/StatisticsClientTests.cs b/Octokit.Tests/Clients/StatisticsClientTests.cs index f9142936..92273c78 100644 --- a/Octokit.Tests/Clients/StatisticsClientTests.cs +++ b/Octokit.Tests/Clients/StatisticsClientTests.cs @@ -10,7 +10,7 @@ namespace Octokit.Tests.Clients { public class StatisticsClientTests { - public class TheConstructor + public class TheCtor { [Fact] public void DoesThrowOnBadArguments() diff --git a/Octokit.Tests/Clients/TeamsClientTests.cs b/Octokit.Tests/Clients/TeamsClientTests.cs index 6305dd0d..f41c3abe 100644 --- a/Octokit.Tests/Clients/TeamsClientTests.cs +++ b/Octokit.Tests/Clients/TeamsClientTests.cs @@ -12,7 +12,7 @@ namespace Octokit.Tests.Clients /// public class TeamsClientTests { - public class TheConstructor + public class TheCtor { [Fact] public void EnsuresNonNullArguments() diff --git a/Octokit.Tests/Clients/UserAdministrationClientTests.cs b/Octokit.Tests/Clients/UserAdministrationClientTests.cs index 5e700df3..11934ea5 100644 --- a/Octokit.Tests/Clients/UserAdministrationClientTests.cs +++ b/Octokit.Tests/Clients/UserAdministrationClientTests.cs @@ -8,6 +8,16 @@ namespace Octokit.Tests.Clients { public class UserAdministrationClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new UserAdministrationClient(null)); + } + } + public class TheCreateMethod { [Fact] diff --git a/Octokit.Tests/Clients/UsersClientTests.cs b/Octokit.Tests/Clients/UsersClientTests.cs index 2b83453e..80c5f110 100644 --- a/Octokit.Tests/Clients/UsersClientTests.cs +++ b/Octokit.Tests/Clients/UsersClientTests.cs @@ -1,12 +1,10 @@ using System; -using System.Collections.Generic; #if NET_45 using System.Collections.ObjectModel; #endif using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -17,7 +15,7 @@ namespace Octokit.Tests.Clients /// public class UsersClientTests { - public class TheConstructor + public class TheCtor { [Fact] public void ThrowsForBadArgs() diff --git a/Octokit.Tests/Clients/WatchedClientTests.cs b/Octokit.Tests/Clients/WatchedClientTests.cs index 0f5f7e80..804b6901 100644 --- a/Octokit.Tests/Clients/WatchedClientTests.cs +++ b/Octokit.Tests/Clients/WatchedClientTests.cs @@ -10,6 +10,16 @@ namespace Octokit.Tests.Clients { public class WatchedClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new WatchedClient(null)); + } + } + public class TheGetAllForCurrentMethod { [Fact] diff --git a/Octokit.Tests/Exceptions/TwoFactorRequiredExceptionTests.cs b/Octokit.Tests/Exceptions/TwoFactorRequiredExceptionTests.cs index 82ee949d..8920c0c9 100644 --- a/Octokit.Tests/Exceptions/TwoFactorRequiredExceptionTests.cs +++ b/Octokit.Tests/Exceptions/TwoFactorRequiredExceptionTests.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Collections.Generic; using System.Net; -using System.Text; -using System.Threading.Tasks; using Octokit.Internal; using Xunit; @@ -11,7 +7,7 @@ namespace Octokit.Tests.Exceptions { public class TwoFactorRequiredExceptionTests { - public class TheConstructor + public class TheCtor { [Fact] public void SetsDefaultMessage() diff --git a/Octokit.Tests/GitHubClientTests.cs b/Octokit.Tests/GitHubClientTests.cs index e8e0827b..41d60c74 100644 --- a/Octokit.Tests/GitHubClientTests.cs +++ b/Octokit.Tests/GitHubClientTests.cs @@ -1,17 +1,15 @@ using System; -using System.Net.Http.Headers; using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; using Xunit; -using Xunit.Extensions; using System.Collections.Generic; namespace Octokit.Tests { public class GitHubClientTests { - public class TheConstructor + public class TheCtor { [Fact] public void CreatesAnonymousClientByDefault() diff --git a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs index ec8de495..d11aa682 100644 --- a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs +++ b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLdapClientTests.cs @@ -7,6 +7,16 @@ namespace Octokit.Tests { public class ObservableEnterpriseLDAPClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ObservableEnterpriseLdapClient(null)); + } + } + public class TheUpdateUserMappingMethod { readonly string _distinguishedName = "uid=test-user,ou=users,dc=company,dc=com"; diff --git a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLicenseClientTests.cs b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLicenseClientTests.cs index b3f89bb5..49c3fc2d 100644 --- a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLicenseClientTests.cs +++ b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseLicenseClientTests.cs @@ -7,6 +7,16 @@ namespace Octokit.Tests { public class ObservableEnterpriseLicenseClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ObservableEnterpriseLicenseClient(null)); + } + } + public class TheGetMethod { [Fact] diff --git a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseOrganizationClientTests.cs b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseOrganizationClientTests.cs index 5e849d84..05dbe7b7 100644 --- a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseOrganizationClientTests.cs +++ b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseOrganizationClientTests.cs @@ -7,6 +7,16 @@ namespace Octokit.Tests { public class ObservableEnterpriseOrganizationClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ObservableEnterpriseOrganizationClient(null)); + } + } + public class TheCreateMethod { [Fact] diff --git a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseSearchIndexingClientTests.cs b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseSearchIndexingClientTests.cs index 02f29b0c..eb1de683 100644 --- a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseSearchIndexingClientTests.cs +++ b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseSearchIndexingClientTests.cs @@ -1,4 +1,5 @@ -using NSubstitute; +using System; +using NSubstitute; using Octokit.Reactive; using Xunit; @@ -6,6 +7,16 @@ namespace Octokit.Tests { public class ObservableEnterpriseSearchIndexingClientTests { + public class TheCtor + { + [Fact] + public void EnsuresArgumentIsNotNull() + { + Assert.Throws(() => + new ObservableEnterpriseSearchIndexingClient(null)); + } + } + public class TheQueueMethod { [Fact] diff --git a/Octokit.Tests/Reactive/ObservableCommitsClientTests.cs b/Octokit.Tests/Reactive/ObservableCommitsClientTests.cs index a662a70a..5b379cc7 100644 --- a/Octokit.Tests/Reactive/ObservableCommitsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableCommitsClientTests.cs @@ -9,7 +9,7 @@ namespace Octokit.Tests.Reactive { public class ObservableCommitsClientTests { - public class TheCtorMethod + public class TheCtor { [Fact] public void EnsuresArgumentIsNotNull() diff --git a/Octokit.Tests/Reactive/ObservableEventsClientTests.cs b/Octokit.Tests/Reactive/ObservableEventsClientTests.cs index bc44a1fd..78c721d7 100644 --- a/Octokit.Tests/Reactive/ObservableEventsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableEventsClientTests.cs @@ -1,17 +1,25 @@ using System; using System.Collections.Generic; -using System.Reactive.Linq; using System.Reactive.Threading.Tasks; using System.Threading.Tasks; using NSubstitute; using Octokit.Reactive; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Reactive { public class ObservableEventsClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ObservableEventsClient(null)); + } + } + public class TheGetAllMethod { [Fact] diff --git a/Octokit.Tests/Reactive/ObservableFeedsClientTests.cs b/Octokit.Tests/Reactive/ObservableFeedsClientTests.cs index 6ec7d0e1..0b3e30e6 100644 --- a/Octokit.Tests/Reactive/ObservableFeedsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableFeedsClientTests.cs @@ -1,16 +1,22 @@ -using NSubstitute; +using System; +using NSubstitute; using Octokit.Reactive; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Xunit; namespace Octokit.Tests.Reactive { public class ObservableFeedsClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ObservableFeedsClient(null)); + } + } + public class TheGetFeedsMethod { [Fact] diff --git a/Octokit.Tests/Reactive/ObservableOrganizationMembersClientTests.cs b/Octokit.Tests/Reactive/ObservableOrganizationMembersClientTests.cs index 76244f74..92941de0 100644 --- a/Octokit.Tests/Reactive/ObservableOrganizationMembersClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableOrganizationMembersClientTests.cs @@ -1,11 +1,7 @@ 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.Reactive.Threading.Tasks; using System.Threading.Tasks; using Xunit; @@ -14,6 +10,16 @@ namespace Octokit.Tests.Reactive { public class ObservableOrganizationMembersClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ObservableOrganizationMembersClient(null)); + } + } + public class TheGetAllMethod { [Fact] diff --git a/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentsClientTests.cs b/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentsClientTests.cs index 5312fcb4..06522564 100644 --- a/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentsClientTests.cs @@ -6,13 +6,22 @@ using NSubstitute; using Octokit.Internal; using Octokit.Reactive; using System.Reactive.Threading.Tasks; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Reactive { public class ObservablePullRequestReviewCommentsClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ObservablePullRequestReviewCommentsClient(null)); + } + } + static IResponse CreateResponseWithApiInfo(IDictionary links) { var response = Substitute.For(); diff --git a/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs b/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs index 77e09103..0282829f 100644 --- a/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs @@ -9,7 +9,7 @@ namespace Octokit.Tests.Reactive { public class ObservableReleasesClientTests { - public class TheCtorMethod + public class TheCtor { [Fact] public void EnsuresArgumentIsNotNull() diff --git a/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs index 9825cd74..fa359b0d 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs @@ -11,6 +11,16 @@ namespace Octokit.Tests.Reactive { public class ObservableRepositoriesClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ObservableRepositoriesClient(null)); + } + } + public class TheGetMethod { // This isn't really a test specific to this method. This is just as good a place as any to test diff --git a/Octokit.Tests/Reactive/ObservableRepositoryDeployKeysClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryDeployKeysClientTests.cs index 171e7761..83946659 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryDeployKeysClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryDeployKeysClientTests.cs @@ -1,10 +1,6 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using NSubstitute; -using NSubstitute.Core; using Octokit.Reactive; using Xunit; @@ -12,7 +8,7 @@ namespace Octokit.Tests.Reactive { public class ObservableRepositoryDeployKeysClientTests { - public class TheConstructor + public class TheCtor { [Fact] public void ThrowsForBadArgs() diff --git a/Octokit.Tests/Reactive/ObservableStarredClientTests.cs b/Octokit.Tests/Reactive/ObservableStarredClientTests.cs index bad0644f..684ba48a 100644 --- a/Octokit.Tests/Reactive/ObservableStarredClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableStarredClientTests.cs @@ -1,21 +1,24 @@ using System; using System.Collections.Generic; -using System.Reactive.Linq; using System.Reactive.Threading.Tasks; using System.Threading.Tasks; using NSubstitute; -using Octokit; -using Octokit.Internal; using Octokit.Reactive; -using Octokit.Reactive.Internal; -using Octokit.Tests.Helpers; using Xunit; -using Xunit.Extensions; namespace Octokit.Tests.Reactive { public class ObservableStarredClientTests { + public class TheCtor + { + [Fact] + public void EnsuresArgumentIsNotNull() + { + Assert.Throws(() => new ObservableStarredClient(null)); + } + } + public class TheGetAllStargazersMethod { [Fact] diff --git a/Octokit.Tests/Reactive/ObservableStatisticsClientTests.cs b/Octokit.Tests/Reactive/ObservableStatisticsClientTests.cs index 94d94791..25141dab 100644 --- a/Octokit.Tests/Reactive/ObservableStatisticsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableStatisticsClientTests.cs @@ -1,16 +1,23 @@ using System; -using System.Reactive.Linq; using System.Reactive.Threading.Tasks; using System.Threading.Tasks; using NSubstitute; using Octokit.Reactive; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Reactive { public class ObservableStatisticsClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new ObservableStatisticsClient(null)); + } + } + public class TheGetMethod { [Fact] diff --git a/Octokit.Tests/Reactive/ObservableTreesClientTests.cs b/Octokit.Tests/Reactive/ObservableTreesClientTests.cs index 68156e42..30af7c91 100644 --- a/Octokit.Tests/Reactive/ObservableTreesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableTreesClientTests.cs @@ -1,16 +1,23 @@ using System; -using System.Reactive.Linq; using System.Reactive.Threading.Tasks; using System.Threading.Tasks; using NSubstitute; using Octokit.Reactive; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests { public class ObservableTreesClientTests { + public class TheCtor + { + [Fact] + public void EnsuresArgumentIsNotNull() + { + Assert.Throws(() => new ObservableTreesClient(null)); + } + } + public class TheGetMethod { [Fact] From dfb636c393910666a2c2cf73324af85725e4c24f Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Wed, 6 Apr 2016 14:40:59 +0700 Subject: [PATCH 104/123] Convention test was renamed --- .../{TestConstructorTests.cs => ClientConstructorTests.cs} | 2 +- Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename Octokit.Tests.Conventions/{TestConstructorTests.cs => ClientConstructorTests.cs} (96%) diff --git a/Octokit.Tests.Conventions/TestConstructorTests.cs b/Octokit.Tests.Conventions/ClientConstructorTests.cs similarity index 96% rename from Octokit.Tests.Conventions/TestConstructorTests.cs rename to Octokit.Tests.Conventions/ClientConstructorTests.cs index c3ef0f2f..346cdf66 100644 --- a/Octokit.Tests.Conventions/TestConstructorTests.cs +++ b/Octokit.Tests.Conventions/ClientConstructorTests.cs @@ -6,7 +6,7 @@ using Xunit; namespace Octokit.Tests.Conventions { - public class TestConstructorTests + public class ClientConstructorTests { [Theory] [MemberData("GetTestConstructorsClasses")] diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index 8f3c5695..c3682123 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -82,7 +82,7 @@ - + From 6140bc678ba0e493e0ef3c6da256d87aebd0f0ef Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Wed, 6 Apr 2016 14:42:20 +0700 Subject: [PATCH 105/123] Some renaming --- Octokit.Tests.Conventions/ClientConstructorTests.cs | 2 +- ...ption.cs => MissingClientConstructorTestClassException.cs} | 4 ++-- Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename Octokit.Tests.Conventions/Exception/{MissingConstructorTestClassException.cs => MissingClientConstructorTestClassException.cs} (66%) diff --git a/Octokit.Tests.Conventions/ClientConstructorTests.cs b/Octokit.Tests.Conventions/ClientConstructorTests.cs index 346cdf66..c0555692 100644 --- a/Octokit.Tests.Conventions/ClientConstructorTests.cs +++ b/Octokit.Tests.Conventions/ClientConstructorTests.cs @@ -17,7 +17,7 @@ namespace Octokit.Tests.Conventions if (!classes.Contains(constructorClassName)) { - throw new MissingConstructorTestClassException(type); + throw new MissingClientConstructorTestClassException(type); } } diff --git a/Octokit.Tests.Conventions/Exception/MissingConstructorTestClassException.cs b/Octokit.Tests.Conventions/Exception/MissingClientConstructorTestClassException.cs similarity index 66% rename from Octokit.Tests.Conventions/Exception/MissingConstructorTestClassException.cs rename to Octokit.Tests.Conventions/Exception/MissingClientConstructorTestClassException.cs index 6932b4ec..e620972e 100644 --- a/Octokit.Tests.Conventions/Exception/MissingConstructorTestClassException.cs +++ b/Octokit.Tests.Conventions/Exception/MissingClientConstructorTestClassException.cs @@ -2,9 +2,9 @@ namespace Octokit.Tests.Conventions { - public class MissingConstructorTestClassException : Exception + public class MissingClientConstructorTestClassException : Exception { - public MissingConstructorTestClassException(Type modelType) + public MissingClientConstructorTestClassException(Type modelType) : base(CreateMessage(modelType)) { } diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index c3682123..780930f7 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -64,7 +64,7 @@ - + From 259a91c2a66a9bac64f585fe03dd8b4783457dd5 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Wed, 6 Apr 2016 15:11:10 +0700 Subject: [PATCH 106/123] Some little fixes in ClientConstructorTests. --- Octokit.Tests.Conventions/ClientConstructorTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.Tests.Conventions/ClientConstructorTests.cs b/Octokit.Tests.Conventions/ClientConstructorTests.cs index c0555692..cbbddee6 100644 --- a/Octokit.Tests.Conventions/ClientConstructorTests.cs +++ b/Octokit.Tests.Conventions/ClientConstructorTests.cs @@ -27,7 +27,7 @@ namespace Octokit.Tests.Conventions .Assembly .ExportedTypes .Where(type => type.IsClass && type.IsPublic && type.Name.EndsWith("ClientTests")) - .Select(type => new[] { type }).ToList(); + .Select(type => new[] { type }); return tests; } } From a783d05abbdd92c90e7b9c27b6ac81dfedc4215b Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Wed, 6 Apr 2016 22:28:47 +0700 Subject: [PATCH 107/123] Type in GetTestConstructorsClasses was replaced. --- Octokit.Tests.Conventions/ClientConstructorTests.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Octokit.Tests.Conventions/ClientConstructorTests.cs b/Octokit.Tests.Conventions/ClientConstructorTests.cs index cbbddee6..2fae7a8d 100644 --- a/Octokit.Tests.Conventions/ClientConstructorTests.cs +++ b/Octokit.Tests.Conventions/ClientConstructorTests.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Octokit.Tests.Clients; using Xunit; namespace Octokit.Tests.Conventions @@ -23,7 +22,7 @@ namespace Octokit.Tests.Conventions public static IEnumerable GetTestConstructorsClasses() { - var tests = typeof(EventsClientTests) + var tests = typeof(GitHubClientTests) .Assembly .ExportedTypes .Where(type => type.IsClass && type.IsPublic && type.Name.EndsWith("ClientTests")) From 36c08248fa53c50200ff03c929a379b08bf9a3eb Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Sun, 10 Apr 2016 22:28:18 +0700 Subject: [PATCH 108/123] New convention test was added. Now each "TheCtor" class must have "EnsuresNonNullArguments" method were throwing of ArgumentNullException from client constructor class should be tested. All unused "using" directives were removed. --- .../ClientConstructorTests.cs | 23 ++++++++++++++---- ...singClientConstructorTestClassException.cs | 2 +- ...ingClientConstructorTestMethodException.cs | 16 +++++++++++++ .../Octokit.Tests.Conventions.csproj | 1 + Octokit.Tests/Clients/AssigneesClientTests.cs | 2 +- .../Clients/AuthorizationsClientTests.cs | 2 +- Octokit.Tests/Clients/CommitsClientTests.cs | 3 +-- .../Clients/DeploymentStatusClientTests.cs | 2 +- .../Clients/DeploymentsClientTests.cs | 2 +- .../Clients/GistCommentsClientTests.cs | 4 ++-- Octokit.Tests/Clients/GistsClientTests.cs | 2 +- .../Clients/GitDatabaseClientTests.cs | 2 +- .../Clients/IssueCommentsClientTests.cs | 12 +++++----- Octokit.Tests/Clients/IssuesClientTests.cs | 3 +-- Octokit.Tests/Clients/MergingClientTests.cs | 3 +-- .../Clients/MilestonesClientTests.cs | 3 +-- .../Clients/MiscellaneousClientTests.cs | 2 +- Octokit.Tests/Clients/OauthClientTests.cs | 2 +- .../Clients/OrganizationMembersClientTests.cs | 3 +-- .../PullRequestReviewCommentsClientTests.cs | 6 +++++ .../Clients/PullRequestsClientTests.cs | 2 +- .../Clients/ReferencesClientTests.cs | 3 +-- Octokit.Tests/Clients/ReleasesClientTests.cs | 2 +- .../Clients/RepoCollaboratorsClientTests.cs | 2 +- .../Clients/RepositoryCommentsClientTests.cs | 3 +-- .../RepositoryDeployKeysClientTests.cs | 2 +- Octokit.Tests/Clients/SshKeysClientTests.cs | 2 +- .../Clients/StatisticsClientTests.cs | 2 +- Octokit.Tests/Clients/TagsClientTests.cs | 2 +- Octokit.Tests/Clients/TreesClientTests.cs | 3 +-- .../Clients/UserEmailsClientTests.cs | 2 +- Octokit.Tests/Clients/UserKeysClientTests.cs | 3 +-- Octokit.Tests/Clients/UsersClientTests.cs | 2 +- Octokit.Tests/GitHubClientTests.cs | 24 +++++++++++++++++++ ...ableEnterpriseSearchIndexingClientTests.cs | 2 +- .../Reactive/ObservableBlobClientTests.cs | 4 +--- .../Reactive/ObservableCommitsClientTests.cs | 2 +- .../ObservableDeploymentStatusClientTests.cs | 2 +- .../ObservableDeploymentsClientTests.cs | 2 +- .../ObservableIssueCommentsClientTests.cs | 4 +--- .../Reactive/ObservableIssuesClientTests.cs | 3 +-- .../ObservableMilestonesClientTests.cs | 3 +-- .../ObservableMiscellaneousClientTests.cs | 2 +- .../ObservablePullRequestsClientTests.cs | 4 ++-- .../Reactive/ObservableReleasesClientTests.cs | 2 +- .../ObservableRepositoryCommitsClientTests.cs | 2 +- ...servableRepositoryDeployKeysClientTests.cs | 2 +- .../Reactive/ObservableStarredClientTests.cs | 2 +- .../Reactive/ObservableTeamsClientTests.cs | 3 +-- .../Reactive/ObservableTreesClientTests.cs | 2 +- ...ObservableUserAdministrationClientTests.cs | 2 +- .../Reactive/ObservableUserKeysClientTests.cs | 3 +-- 52 files changed, 119 insertions(+), 76 deletions(-) create mode 100644 Octokit.Tests.Conventions/Exception/MissingClientConstructorTestMethodException.cs diff --git a/Octokit.Tests.Conventions/ClientConstructorTests.cs b/Octokit.Tests.Conventions/ClientConstructorTests.cs index 2fae7a8d..b5d0e7a5 100644 --- a/Octokit.Tests.Conventions/ClientConstructorTests.cs +++ b/Octokit.Tests.Conventions/ClientConstructorTests.cs @@ -8,19 +8,32 @@ namespace Octokit.Tests.Conventions public class ClientConstructorTests { [Theory] - [MemberData("GetTestConstructorsClasses")] - public void CheckTestConstructorsNames(Type type) + [MemberData("GetTestConstructorClasses")] + public void CheckTestConstructorNames(Type type) { - const string constructorClassName = "TheCtor"; + const string constructorTestClassName = "TheCtor"; + const string constructorTestMethodName = "EnsuresNonNullArguments"; + var classes = new HashSet(type.GetNestedTypes().Select(t => t.Name)); - if (!classes.Contains(constructorClassName)) + if (!classes.Contains(constructorTestClassName)) { throw new MissingClientConstructorTestClassException(type); } + + var ctors = type.GetNestedTypes().Where(t => t.Name == constructorTestClassName) + .SelectMany(t => t.GetMethods()) + .Where(info => info.ReturnType == typeof(void) && info.IsPublic) + .Select(info => info.Name); + + var methods = new HashSet(ctors); + if (!methods.Contains(constructorTestMethodName)) + { + throw new MissingClientConstructorTestMethodException(type); + } } - public static IEnumerable GetTestConstructorsClasses() + public static IEnumerable GetTestConstructorClasses() { var tests = typeof(GitHubClientTests) .Assembly diff --git a/Octokit.Tests.Conventions/Exception/MissingClientConstructorTestClassException.cs b/Octokit.Tests.Conventions/Exception/MissingClientConstructorTestClassException.cs index e620972e..231929db 100644 --- a/Octokit.Tests.Conventions/Exception/MissingClientConstructorTestClassException.cs +++ b/Octokit.Tests.Conventions/Exception/MissingClientConstructorTestClassException.cs @@ -10,7 +10,7 @@ namespace Octokit.Tests.Conventions static string CreateMessage(Type ctorTest) { - return string.Format("Constructor test method is missing {0}.", ctorTest.FullName); + return string.Format("Constructor test class is missing {0}.", ctorTest.FullName); } } } \ No newline at end of file diff --git a/Octokit.Tests.Conventions/Exception/MissingClientConstructorTestMethodException.cs b/Octokit.Tests.Conventions/Exception/MissingClientConstructorTestMethodException.cs new file mode 100644 index 00000000..a5908f13 --- /dev/null +++ b/Octokit.Tests.Conventions/Exception/MissingClientConstructorTestMethodException.cs @@ -0,0 +1,16 @@ +using System; + +namespace Octokit.Tests.Conventions +{ + public class MissingClientConstructorTestMethodException : Exception + { + public MissingClientConstructorTestMethodException(Type modelType) + : base(CreateMessage(modelType)) + { } + + static string CreateMessage(Type ctorTest) + { + return string.Format("Constructor test method is missing {0}.", ctorTest.FullName); + } + } +} \ No newline at end of file diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj index 780930f7..e06a67b8 100644 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj @@ -65,6 +65,7 @@ + diff --git a/Octokit.Tests/Clients/AssigneesClientTests.cs b/Octokit.Tests/Clients/AssigneesClientTests.cs index e5c56018..cf03eedc 100644 --- a/Octokit.Tests/Clients/AssigneesClientTests.cs +++ b/Octokit.Tests/Clients/AssigneesClientTests.cs @@ -115,7 +115,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new AssigneesClient(null)); } diff --git a/Octokit.Tests/Clients/AuthorizationsClientTests.cs b/Octokit.Tests/Clients/AuthorizationsClientTests.cs index 4e11ecd1..91887a6e 100644 --- a/Octokit.Tests/Clients/AuthorizationsClientTests.cs +++ b/Octokit.Tests/Clients/AuthorizationsClientTests.cs @@ -17,7 +17,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void ThrowsForBadArgs() + public void EnsuresNonNullArguments() { Assert.Throws(() => new AuthorizationsClient(null)); } diff --git a/Octokit.Tests/Clients/CommitsClientTests.cs b/Octokit.Tests/Clients/CommitsClientTests.cs index 66bebed9..6c1c4201 100644 --- a/Octokit.Tests/Clients/CommitsClientTests.cs +++ b/Octokit.Tests/Clients/CommitsClientTests.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Threading.Tasks; using NSubstitute; using Octokit; -using Octokit.Tests.Helpers; using Xunit; public class CommitsClientTests @@ -71,7 +70,7 @@ public class CommitsClientTests public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new CommitsClient(null)); } diff --git a/Octokit.Tests/Clients/DeploymentStatusClientTests.cs b/Octokit.Tests/Clients/DeploymentStatusClientTests.cs index bbf306d4..e88080c0 100644 --- a/Octokit.Tests/Clients/DeploymentStatusClientTests.cs +++ b/Octokit.Tests/Clients/DeploymentStatusClientTests.cs @@ -105,7 +105,7 @@ public class DeploymentStatusClientTests public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new DeploymentStatusClient(null)); } diff --git a/Octokit.Tests/Clients/DeploymentsClientTests.cs b/Octokit.Tests/Clients/DeploymentsClientTests.cs index 804835cc..a29e555a 100644 --- a/Octokit.Tests/Clients/DeploymentsClientTests.cs +++ b/Octokit.Tests/Clients/DeploymentsClientTests.cs @@ -143,7 +143,7 @@ public class DeploymentsClientTests public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new DeploymentsClient(null)); } diff --git a/Octokit.Tests/Clients/GistCommentsClientTests.cs b/Octokit.Tests/Clients/GistCommentsClientTests.cs index 66b33d38..6b9cf86e 100644 --- a/Octokit.Tests/Clients/GistCommentsClientTests.cs +++ b/Octokit.Tests/Clients/GistCommentsClientTests.cs @@ -10,7 +10,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new GistCommentsClient(null)); } @@ -71,7 +71,7 @@ namespace Octokit.Tests.Clients await Assert.ThrowsAsync(() => client.GetAllForGist("")); await Assert.ThrowsAsync(() => client.GetAllForGist("24", null)); await Assert.ThrowsAsync(() => client.GetAllForGist("", ApiOptions.None)); - + } } diff --git a/Octokit.Tests/Clients/GistsClientTests.cs b/Octokit.Tests/Clients/GistsClientTests.cs index 56c31186..a0519246 100644 --- a/Octokit.Tests/Clients/GistsClientTests.cs +++ b/Octokit.Tests/Clients/GistsClientTests.cs @@ -305,7 +305,7 @@ public class GistsClientTests public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new GistsClient(null)); } diff --git a/Octokit.Tests/Clients/GitDatabaseClientTests.cs b/Octokit.Tests/Clients/GitDatabaseClientTests.cs index d66c5ffe..159b44a9 100644 --- a/Octokit.Tests/Clients/GitDatabaseClientTests.cs +++ b/Octokit.Tests/Clients/GitDatabaseClientTests.cs @@ -8,7 +8,7 @@ public class GitDatabaseClientTests public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new GitDatabaseClient(null)); } diff --git a/Octokit.Tests/Clients/IssueCommentsClientTests.cs b/Octokit.Tests/Clients/IssueCommentsClientTests.cs index a3788f07..dcae0577 100644 --- a/Octokit.Tests/Clients/IssueCommentsClientTests.cs +++ b/Octokit.Tests/Clients/IssueCommentsClientTests.cs @@ -209,14 +209,14 @@ namespace Octokit.Tests.Clients } } - public class TheCtor + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() { - [Fact] - public void EnsuresArgument() - { - Assert.Throws(() => new IssueCommentsClient(null)); - } + Assert.Throws(() => new IssueCommentsClient(null)); } + } [Fact] public void CanDeserializeIssueComment() diff --git a/Octokit.Tests/Clients/IssuesClientTests.cs b/Octokit.Tests/Clients/IssuesClientTests.cs index bcb14395..9dbe0436 100644 --- a/Octokit.Tests/Clients/IssuesClientTests.cs +++ b/Octokit.Tests/Clients/IssuesClientTests.cs @@ -4,7 +4,6 @@ using System.Net; using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -240,7 +239,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new IssuesClient(null)); } diff --git a/Octokit.Tests/Clients/MergingClientTests.cs b/Octokit.Tests/Clients/MergingClientTests.cs index 7d5751ec..fa384c94 100644 --- a/Octokit.Tests/Clients/MergingClientTests.cs +++ b/Octokit.Tests/Clients/MergingClientTests.cs @@ -1,7 +1,6 @@ using System; using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -46,7 +45,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new CommitsClient(null)); } diff --git a/Octokit.Tests/Clients/MilestonesClientTests.cs b/Octokit.Tests/Clients/MilestonesClientTests.cs index 22931232..e5807a7c 100644 --- a/Octokit.Tests/Clients/MilestonesClientTests.cs +++ b/Octokit.Tests/Clients/MilestonesClientTests.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -151,7 +150,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new MilestonesClient(null)); } diff --git a/Octokit.Tests/Clients/MiscellaneousClientTests.cs b/Octokit.Tests/Clients/MiscellaneousClientTests.cs index e8e245bf..07e50660 100644 --- a/Octokit.Tests/Clients/MiscellaneousClientTests.cs +++ b/Octokit.Tests/Clients/MiscellaneousClientTests.cs @@ -175,7 +175,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void EnsuresArgumentsNotNull() + public void EnsuresNonNullArguments() { Assert.Throws(() => new MiscellaneousClient(null)); } diff --git a/Octokit.Tests/Clients/OauthClientTests.cs b/Octokit.Tests/Clients/OauthClientTests.cs index 9bbbff77..7f723b26 100644 --- a/Octokit.Tests/Clients/OauthClientTests.cs +++ b/Octokit.Tests/Clients/OauthClientTests.cs @@ -12,7 +12,7 @@ public class OauthClientTests public class TheCtor { [Fact] - public void EnsuresArgumentIsNotNull() + public void EnsuresNonNullArguments() { Assert.Throws(() => new OauthClient(null)); diff --git a/Octokit.Tests/Clients/OrganizationMembersClientTests.cs b/Octokit.Tests/Clients/OrganizationMembersClientTests.cs index 9992ab7b..4bf1b353 100644 --- a/Octokit.Tests/Clients/OrganizationMembersClientTests.cs +++ b/Octokit.Tests/Clients/OrganizationMembersClientTests.cs @@ -4,7 +4,6 @@ using System.Net; using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -18,7 +17,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void EnsureNonNullArguments() + public void EnsuresNonNullArguments() { Assert.Throws(() => new OrganizationMembersClient(null)); } diff --git a/Octokit.Tests/Clients/PullRequestReviewCommentsClientTests.cs b/Octokit.Tests/Clients/PullRequestReviewCommentsClientTests.cs index 8ab043ed..99ebd227 100644 --- a/Octokit.Tests/Clients/PullRequestReviewCommentsClientTests.cs +++ b/Octokit.Tests/Clients/PullRequestReviewCommentsClientTests.cs @@ -9,6 +9,12 @@ public class PullRequestReviewCommentsClientTests { public class TheCtor { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new PullRequestReviewCommentsClient(null)); + } + [Fact] public void PullRequestReviewCommentCreateEnsuresArgumentsValue() { diff --git a/Octokit.Tests/Clients/PullRequestsClientTests.cs b/Octokit.Tests/Clients/PullRequestsClientTests.cs index c1067e66..0c02a124 100644 --- a/Octokit.Tests/Clients/PullRequestsClientTests.cs +++ b/Octokit.Tests/Clients/PullRequestsClientTests.cs @@ -249,7 +249,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new PullRequestsClient(null)); } diff --git a/Octokit.Tests/Clients/ReferencesClientTests.cs b/Octokit.Tests/Clients/ReferencesClientTests.cs index ce8bdd53..5d75b1b3 100644 --- a/Octokit.Tests/Clients/ReferencesClientTests.cs +++ b/Octokit.Tests/Clients/ReferencesClientTests.cs @@ -1,7 +1,6 @@ using System; using System.Threading.Tasks; using NSubstitute; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Clients @@ -11,7 +10,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ReferencesClient(null)); } diff --git a/Octokit.Tests/Clients/ReleasesClientTests.cs b/Octokit.Tests/Clients/ReleasesClientTests.cs index bb436d0f..9e79d47e 100644 --- a/Octokit.Tests/Clients/ReleasesClientTests.cs +++ b/Octokit.Tests/Clients/ReleasesClientTests.cs @@ -11,7 +11,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void EnsuresArgumentIsNotNull() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ReleasesClient(null)); diff --git a/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs b/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs index efeef7aa..5fb84fc9 100644 --- a/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs +++ b/Octokit.Tests/Clients/RepoCollaboratorsClientTests.cs @@ -17,7 +17,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void ThrowsForBadArgs() + public void EnsuresNonNullArguments() { Assert.Throws(() => new RepoCollaboratorsClient(null)); } diff --git a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs index 09177c95..a4083ed4 100644 --- a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using NSubstitute; using Octokit; using Octokit.Internal; -using Octokit.Tests.Helpers; using Xunit; public class RepositoryCommentsClientTests @@ -177,7 +176,7 @@ public class RepositoryCommentsClientTests public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new RepositoryCommentsClient(null)); } diff --git a/Octokit.Tests/Clients/RepositoryDeployKeysClientTests.cs b/Octokit.Tests/Clients/RepositoryDeployKeysClientTests.cs index 40037fdb..2362fef4 100644 --- a/Octokit.Tests/Clients/RepositoryDeployKeysClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryDeployKeysClientTests.cs @@ -14,7 +14,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void ThrowsForBadArgs() + public void EnsuresNonNullArguments() { Assert.Throws(() => new RepositoryDeployKeysClient(null)); } diff --git a/Octokit.Tests/Clients/SshKeysClientTests.cs b/Octokit.Tests/Clients/SshKeysClientTests.cs index cdbf93a0..0d48820d 100644 --- a/Octokit.Tests/Clients/SshKeysClientTests.cs +++ b/Octokit.Tests/Clients/SshKeysClientTests.cs @@ -14,7 +14,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void ThrowsForBadArgs() + public void EnsuresNonNullArguments() { Assert.Throws(() => new SshKeysClient(null)); } diff --git a/Octokit.Tests/Clients/StatisticsClientTests.cs b/Octokit.Tests/Clients/StatisticsClientTests.cs index 92273c78..6b2b6ece 100644 --- a/Octokit.Tests/Clients/StatisticsClientTests.cs +++ b/Octokit.Tests/Clients/StatisticsClientTests.cs @@ -13,7 +13,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void DoesThrowOnBadArguments() + public void EnsuresNonNullArguments() { Assert.Throws(() => new StatisticsClient(null)); } diff --git a/Octokit.Tests/Clients/TagsClientTests.cs b/Octokit.Tests/Clients/TagsClientTests.cs index 6d5c1a46..384594c9 100644 --- a/Octokit.Tests/Clients/TagsClientTests.cs +++ b/Octokit.Tests/Clients/TagsClientTests.cs @@ -64,7 +64,7 @@ public class TagsClientTests public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new TagsClient(null)); } diff --git a/Octokit.Tests/Clients/TreesClientTests.cs b/Octokit.Tests/Clients/TreesClientTests.cs index 687fe9c4..458f9a14 100644 --- a/Octokit.Tests/Clients/TreesClientTests.cs +++ b/Octokit.Tests/Clients/TreesClientTests.cs @@ -4,7 +4,6 @@ using System.Net; using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests @@ -108,7 +107,7 @@ namespace Octokit.Tests public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new TreesClient(null)); } diff --git a/Octokit.Tests/Clients/UserEmailsClientTests.cs b/Octokit.Tests/Clients/UserEmailsClientTests.cs index 9ea83029..0ccbb8c7 100644 --- a/Octokit.Tests/Clients/UserEmailsClientTests.cs +++ b/Octokit.Tests/Clients/UserEmailsClientTests.cs @@ -113,7 +113,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void EnsuresArguments() + public void EnsuresNonNullArguments() { Assert.Throws( () => new UserEmailsClient(null)); diff --git a/Octokit.Tests/Clients/UserKeysClientTests.cs b/Octokit.Tests/Clients/UserKeysClientTests.cs index e36369f0..d1a044d8 100644 --- a/Octokit.Tests/Clients/UserKeysClientTests.cs +++ b/Octokit.Tests/Clients/UserKeysClientTests.cs @@ -1,6 +1,5 @@ using NSubstitute; using System; -using System.Collections.Generic; using System.Threading.Tasks; using Xunit; @@ -129,7 +128,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void EnsuresArguments() + public void EnsuresNonNullArguments() { Assert.Throws( () => new UserEmailsClient(null)); diff --git a/Octokit.Tests/Clients/UsersClientTests.cs b/Octokit.Tests/Clients/UsersClientTests.cs index 80c5f110..92b288b8 100644 --- a/Octokit.Tests/Clients/UsersClientTests.cs +++ b/Octokit.Tests/Clients/UsersClientTests.cs @@ -18,7 +18,7 @@ namespace Octokit.Tests.Clients public class TheCtor { [Fact] - public void ThrowsForBadArgs() + public void EnsuresNonNullArguments() { Assert.Throws(() => new UsersClient(null)); } diff --git a/Octokit.Tests/GitHubClientTests.cs b/Octokit.Tests/GitHubClientTests.cs index 41d60c74..1c7d3dad 100644 --- a/Octokit.Tests/GitHubClientTests.cs +++ b/Octokit.Tests/GitHubClientTests.cs @@ -11,6 +11,30 @@ namespace Octokit.Tests { public class TheCtor { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new GitHubClient((IConnection)null)); + Assert.Throws(() => new GitHubClient((ProductHeaderValue)null)); + + Assert.Throws(() => new GitHubClient(new ProductHeaderValue("UnitTest"), (ICredentialStore)null)); + Assert.Throws(() => new GitHubClient(null, Substitute.For())); + + Assert.Throws(() => new GitHubClient(new ProductHeaderValue("UnitTest"), (Uri)null)); + Assert.Throws(() => new GitHubClient(null, new Uri("http://github.com"))); + + Assert.Throws(() => new GitHubClient(null, (ICredentialStore)null)); + Assert.Throws(() => new GitHubClient(null, (Uri)null)); + + Assert.Throws(() => new GitHubClient(new ProductHeaderValue("UnitTest"), null, null)); + Assert.Throws(() => new GitHubClient(null, Substitute.For(), null)); + Assert.Throws(() => new GitHubClient(null, null, new Uri("http://github.com"))); + + Assert.Throws(() => new GitHubClient(null, Substitute.For(), new Uri("http://github.com"))); + Assert.Throws(() => new GitHubClient(new ProductHeaderValue("UnitTest"), null, new Uri("http://github.com"))); + Assert.Throws(() => new GitHubClient(new ProductHeaderValue("UnitTest"), Substitute.For(), null)); + } + [Fact] public void CreatesAnonymousClientByDefault() { diff --git a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseSearchIndexingClientTests.cs b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseSearchIndexingClientTests.cs index eb1de683..d6e5607f 100644 --- a/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseSearchIndexingClientTests.cs +++ b/Octokit.Tests/Reactive/Enterprise/ObservableEnterpriseSearchIndexingClientTests.cs @@ -10,7 +10,7 @@ namespace Octokit.Tests public class TheCtor { [Fact] - public void EnsuresArgumentIsNotNull() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableEnterpriseSearchIndexingClient(null)); diff --git a/Octokit.Tests/Reactive/ObservableBlobClientTests.cs b/Octokit.Tests/Reactive/ObservableBlobClientTests.cs index b182a818..6db6e1e9 100644 --- a/Octokit.Tests/Reactive/ObservableBlobClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableBlobClientTests.cs @@ -1,10 +1,8 @@ using System; -using System.Reactive.Linq; using System.Reactive.Threading.Tasks; using System.Threading.Tasks; using NSubstitute; using Octokit.Reactive; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Reactive @@ -69,7 +67,7 @@ namespace Octokit.Tests.Reactive public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableBlobClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableCommitsClientTests.cs b/Octokit.Tests/Reactive/ObservableCommitsClientTests.cs index 5b379cc7..da6bda02 100644 --- a/Octokit.Tests/Reactive/ObservableCommitsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableCommitsClientTests.cs @@ -12,7 +12,7 @@ namespace Octokit.Tests.Reactive public class TheCtor { [Fact] - public void EnsuresArgumentIsNotNull() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableCommitsClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableDeploymentStatusClientTests.cs b/Octokit.Tests/Reactive/ObservableDeploymentStatusClientTests.cs index 8e0dd99f..0360d467 100644 --- a/Octokit.Tests/Reactive/ObservableDeploymentStatusClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableDeploymentStatusClientTests.cs @@ -121,7 +121,7 @@ namespace Octokit.Tests.Reactive public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws( () => new ObservableDeploymentStatusClient(null)); diff --git a/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs b/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs index 477d1d78..38328dfc 100644 --- a/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableDeploymentsClientTests.cs @@ -174,7 +174,7 @@ namespace Octokit.Tests.Reactive public class TheCtor { [Fact] - public void EnsuresArguments() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableDeploymentsClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs b/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs index 958ff020..2992c74a 100644 --- a/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs @@ -1,11 +1,9 @@ using System; using System.Collections.Generic; -using System.Reactive.Linq; using System.Reactive.Threading.Tasks; using System.Threading.Tasks; using NSubstitute; using Octokit.Reactive; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Reactive @@ -192,7 +190,7 @@ namespace Octokit.Tests.Reactive public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableIssueCommentsClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs index c511b901..c063e5d4 100644 --- a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs @@ -2,7 +2,6 @@ using Octokit; using Octokit.Internal; using Octokit.Reactive; -using Octokit.Tests.Helpers; using System; using System.Collections.Generic; using System.Reactive.Linq; @@ -390,7 +389,7 @@ public class ObservableIssuesClientTests public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new IssuesClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableMilestonesClientTests.cs b/Octokit.Tests/Reactive/ObservableMilestonesClientTests.cs index 1c9b2690..beade987 100644 --- a/Octokit.Tests/Reactive/ObservableMilestonesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableMilestonesClientTests.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; using Octokit.Reactive; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Reactive @@ -236,7 +235,7 @@ namespace Octokit.Tests.Reactive public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new MilestonesClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableMiscellaneousClientTests.cs b/Octokit.Tests/Reactive/ObservableMiscellaneousClientTests.cs index b5a47719..b069c08b 100644 --- a/Octokit.Tests/Reactive/ObservableMiscellaneousClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableMiscellaneousClientTests.cs @@ -136,7 +136,7 @@ namespace Octokit.Tests.Reactive public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableMiscellaneousClient((IGitHubClient)null)); } diff --git a/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs b/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs index f9d7eec1..3d8ad7b9 100644 --- a/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs @@ -7,7 +7,6 @@ using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; using Octokit.Reactive; -using Octokit.Tests.Helpers; using Xunit; namespace Octokit.Tests.Reactive @@ -352,10 +351,11 @@ namespace Octokit.Tests.Reactive await Assert.ThrowsAsync(() => client.Files("owner", "", 1)); } } + public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new PullRequestsClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs b/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs index 0282829f..ca163f6d 100644 --- a/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableReleasesClientTests.cs @@ -12,7 +12,7 @@ namespace Octokit.Tests.Reactive public class TheCtor { [Fact] - public void EnsuresArgumentIsNotNull() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableReleasesClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableRepositoryCommitsClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryCommitsClientTests.cs index 07d15de3..9891b046 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryCommitsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryCommitsClientTests.cs @@ -12,7 +12,7 @@ namespace Octokit.Tests.Reactive public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableRepositoryCommitsClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableRepositoryDeployKeysClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryDeployKeysClientTests.cs index 83946659..81a4f439 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryDeployKeysClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryDeployKeysClientTests.cs @@ -11,7 +11,7 @@ namespace Octokit.Tests.Reactive public class TheCtor { [Fact] - public void ThrowsForBadArgs() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableRepositoryDeployKeysClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableStarredClientTests.cs b/Octokit.Tests/Reactive/ObservableStarredClientTests.cs index 684ba48a..c6924dd6 100644 --- a/Octokit.Tests/Reactive/ObservableStarredClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableStarredClientTests.cs @@ -13,7 +13,7 @@ namespace Octokit.Tests.Reactive public class TheCtor { [Fact] - public void EnsuresArgumentIsNotNull() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableStarredClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableTeamsClientTests.cs b/Octokit.Tests/Reactive/ObservableTeamsClientTests.cs index eebd3491..5fc8bd39 100644 --- a/Octokit.Tests/Reactive/ObservableTeamsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableTeamsClientTests.cs @@ -1,6 +1,5 @@ using System; using System.Reactive.Threading.Tasks; -using System.Threading.Tasks; using NSubstitute; using Octokit.Reactive; using Xunit; @@ -38,7 +37,7 @@ namespace Octokit.Tests.Reactive public class TheCtor { [Fact] - public void EnsuresNotNullGitHubClient() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableTeamsClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableTreesClientTests.cs b/Octokit.Tests/Reactive/ObservableTreesClientTests.cs index 30af7c91..d2e0920c 100644 --- a/Octokit.Tests/Reactive/ObservableTreesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableTreesClientTests.cs @@ -12,7 +12,7 @@ namespace Octokit.Tests public class TheCtor { [Fact] - public void EnsuresArgumentIsNotNull() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableTreesClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableUserAdministrationClientTests.cs b/Octokit.Tests/Reactive/ObservableUserAdministrationClientTests.cs index d6a1fab9..5290511a 100644 --- a/Octokit.Tests/Reactive/ObservableUserAdministrationClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableUserAdministrationClientTests.cs @@ -180,7 +180,7 @@ namespace Octokit.Tests.Reactive public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableUserAdministrationClient(null)); } diff --git a/Octokit.Tests/Reactive/ObservableUserKeysClientTests.cs b/Octokit.Tests/Reactive/ObservableUserKeysClientTests.cs index 3a569e27..385a5a1f 100644 --- a/Octokit.Tests/Reactive/ObservableUserKeysClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableUserKeysClientTests.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using NSubstitute; using Octokit.Reactive; using Xunit; @@ -84,7 +83,7 @@ namespace Octokit.Tests.Reactive public class TheCtor { [Fact] - public void EnsuresArgument() + public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableUserKeysClient(null)); } From 251e61ae435fb2d9f7527286a90bf6fe83cdebb4 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Mon, 18 Apr 2016 13:26:01 +0700 Subject: [PATCH 109/123] New contructor was added. --- .../Clients/RespositoryCommitsClientTests.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Octokit.Tests/Clients/RespositoryCommitsClientTests.cs b/Octokit.Tests/Clients/RespositoryCommitsClientTests.cs index fe0ba30f..a54d8434 100644 --- a/Octokit.Tests/Clients/RespositoryCommitsClientTests.cs +++ b/Octokit.Tests/Clients/RespositoryCommitsClientTests.cs @@ -1,12 +1,21 @@ using NSubstitute; using System; -using System.Collections.Generic; using Xunit; namespace Octokit.Tests.Clients { public class RespositoryCommitsClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new RepositoryCommitsClient(null)); + } + } + public class TheGetAllMethod { [Fact] From 5765bf57df88443679fbdcd412f54a229959cea4 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Mon, 18 Apr 2016 13:44:04 +0700 Subject: [PATCH 110/123] Fix broken tests. --- Octokit/Clients/RepositoryCommitsClient.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Octokit/Clients/RepositoryCommitsClient.cs b/Octokit/Clients/RepositoryCommitsClient.cs index f2ea2ccd..ccbaa6d4 100644 --- a/Octokit/Clients/RepositoryCommitsClient.cs +++ b/Octokit/Clients/RepositoryCommitsClient.cs @@ -9,11 +9,12 @@ namespace Octokit /// /// See the Repository Commits API documentation for more information. /// - public class RepositoryCommitsClient : IRepositoryCommitsClient + public class RepositoryCommitsClient : ApiClient, IRepositoryCommitsClient { readonly IApiConnection _apiConnection; - public RepositoryCommitsClient(IApiConnection apiConnection) + public RepositoryCommitsClient(IApiConnection apiConnection) + : base(apiConnection) { _apiConnection = apiConnection; } From e2b0a18e0444976d4a97e40dfcd8b863da866a14 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Mon, 18 Apr 2016 16:45:48 +0700 Subject: [PATCH 111/123] Additional variables were added. --- Octokit.Tests/GitHubClientTests.cs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Octokit.Tests/GitHubClientTests.cs b/Octokit.Tests/GitHubClientTests.cs index 1c7d3dad..1df1ef17 100644 --- a/Octokit.Tests/GitHubClientTests.cs +++ b/Octokit.Tests/GitHubClientTests.cs @@ -17,22 +17,26 @@ namespace Octokit.Tests Assert.Throws(() => new GitHubClient((IConnection)null)); Assert.Throws(() => new GitHubClient((ProductHeaderValue)null)); - Assert.Throws(() => new GitHubClient(new ProductHeaderValue("UnitTest"), (ICredentialStore)null)); - Assert.Throws(() => new GitHubClient(null, Substitute.For())); + var productHeaderValue = new ProductHeaderValue("UnitTest"); + var baseAddress = new Uri("http://github.com"); + var credentialStore = Substitute.For(); + + Assert.Throws(() => new GitHubClient(productHeaderValue, (ICredentialStore)null)); + Assert.Throws(() => new GitHubClient(null, credentialStore)); - Assert.Throws(() => new GitHubClient(new ProductHeaderValue("UnitTest"), (Uri)null)); - Assert.Throws(() => new GitHubClient(null, new Uri("http://github.com"))); + Assert.Throws(() => new GitHubClient(productHeaderValue, (Uri)null)); + Assert.Throws(() => new GitHubClient(null, baseAddress)); Assert.Throws(() => new GitHubClient(null, (ICredentialStore)null)); Assert.Throws(() => new GitHubClient(null, (Uri)null)); - Assert.Throws(() => new GitHubClient(new ProductHeaderValue("UnitTest"), null, null)); - Assert.Throws(() => new GitHubClient(null, Substitute.For(), null)); - Assert.Throws(() => new GitHubClient(null, null, new Uri("http://github.com"))); + Assert.Throws(() => new GitHubClient(productHeaderValue, null, null)); + Assert.Throws(() => new GitHubClient(null, credentialStore, null)); + Assert.Throws(() => new GitHubClient(null, null, baseAddress)); - Assert.Throws(() => new GitHubClient(null, Substitute.For(), new Uri("http://github.com"))); - Assert.Throws(() => new GitHubClient(new ProductHeaderValue("UnitTest"), null, new Uri("http://github.com"))); - Assert.Throws(() => new GitHubClient(new ProductHeaderValue("UnitTest"), Substitute.For(), null)); + Assert.Throws(() => new GitHubClient(null, credentialStore, baseAddress)); + Assert.Throws(() => new GitHubClient(productHeaderValue, null, baseAddress)); + Assert.Throws(() => new GitHubClient(productHeaderValue, credentialStore, null)); } [Fact] From ac28fd4030cc7e217256b713e63d20204fce6348 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Mon, 18 Apr 2016 16:47:58 +0700 Subject: [PATCH 112/123] One small rename. --- Octokit.Tests/GitHubClientTests.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Octokit.Tests/GitHubClientTests.cs b/Octokit.Tests/GitHubClientTests.cs index 1df1ef17..82ea3423 100644 --- a/Octokit.Tests/GitHubClientTests.cs +++ b/Octokit.Tests/GitHubClientTests.cs @@ -17,26 +17,26 @@ namespace Octokit.Tests Assert.Throws(() => new GitHubClient((IConnection)null)); Assert.Throws(() => new GitHubClient((ProductHeaderValue)null)); - var productHeaderValue = new ProductHeaderValue("UnitTest"); + var productInformation = new ProductHeaderValue("UnitTest"); var baseAddress = new Uri("http://github.com"); var credentialStore = Substitute.For(); - Assert.Throws(() => new GitHubClient(productHeaderValue, (ICredentialStore)null)); + Assert.Throws(() => new GitHubClient(productInformation, (ICredentialStore)null)); Assert.Throws(() => new GitHubClient(null, credentialStore)); - Assert.Throws(() => new GitHubClient(productHeaderValue, (Uri)null)); + Assert.Throws(() => new GitHubClient(productInformation, (Uri)null)); Assert.Throws(() => new GitHubClient(null, baseAddress)); Assert.Throws(() => new GitHubClient(null, (ICredentialStore)null)); Assert.Throws(() => new GitHubClient(null, (Uri)null)); - Assert.Throws(() => new GitHubClient(productHeaderValue, null, null)); + Assert.Throws(() => new GitHubClient(productInformation, null, null)); Assert.Throws(() => new GitHubClient(null, credentialStore, null)); Assert.Throws(() => new GitHubClient(null, null, baseAddress)); Assert.Throws(() => new GitHubClient(null, credentialStore, baseAddress)); - Assert.Throws(() => new GitHubClient(productHeaderValue, null, baseAddress)); - Assert.Throws(() => new GitHubClient(productHeaderValue, credentialStore, null)); + Assert.Throws(() => new GitHubClient(productInformation, null, baseAddress)); + Assert.Throws(() => new GitHubClient(productInformation, credentialStore, null)); } [Fact] From a44feaa7c33d5215919215caac1c475450432f64 Mon Sep 17 00:00:00 2001 From: Elhamer Date: Mon, 18 Apr 2016 23:16:42 +0100 Subject: [PATCH 113/123] Add ApiOption overloads to methods on IGistsClient (#1261) --- .../Clients/IObservableGistsClient.cs | 100 +++ .../Clients/ObservableGistsClient.cs | 178 ++++- .../Octokit.Tests.Integration.csproj | 1 + .../Reactive/ObservableGistClientTests.cs | 720 ++++++++++++++++++ Octokit.Tests/Clients/GistsClientTests.cs | 340 ++++++++- Octokit.Tests/Helpers/Arg.cs | 2 +- .../Reactive/ObservableGistsTests.cs | 415 +++++++++- Octokit/Clients/GistsClient.cs | 190 ++++- Octokit/Clients/IGistsClient.cs | 102 +++ 9 files changed, 1955 insertions(+), 93 deletions(-) create mode 100644 Octokit.Tests.Integration/Reactive/ObservableGistClientTests.cs diff --git a/Octokit.Reactive/Clients/IObservableGistsClient.cs b/Octokit.Reactive/Clients/IObservableGistsClient.cs index efdc6ac2..a0493845 100644 --- a/Octokit.Reactive/Clients/IObservableGistsClient.cs +++ b/Octokit.Reactive/Clients/IObservableGistsClient.cs @@ -28,6 +28,16 @@ namespace Octokit.Reactive /// IObservable GetAll(); + /// + /// List the authenticated user’s gists or if called anonymously, + /// this will return all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + IObservable GetAll(ApiOptions options); + /// /// List the authenticated user’s gists or if called anonymously, /// this will return all public gists @@ -38,6 +48,17 @@ namespace Octokit.Reactive /// Only gists updated at or after this time are returned IObservable GetAll(DateTimeOffset since); + /// + /// List the authenticated user’s gists or if called anonymously, + /// this will return all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + IObservable GetAll(DateTimeOffset since, ApiOptions options); + /// /// Lists all public gists /// @@ -46,6 +67,15 @@ namespace Octokit.Reactive /// IObservable GetAllPublic(); + /// + /// Lists all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + IObservable GetAllPublic(ApiOptions options); + /// /// Lists all public gists /// @@ -55,6 +85,16 @@ namespace Octokit.Reactive /// Only gists updated at or after this time are returned IObservable GetAllPublic(DateTimeOffset since); + /// + /// Lists all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + IObservable GetAllPublic(DateTimeOffset since, ApiOptions options); + /// /// List the authenticated user’s starred gists /// @@ -63,6 +103,15 @@ namespace Octokit.Reactive /// IObservable GetAllStarred(); + /// + /// List the authenticated user’s starred gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + IObservable GetAllStarred(ApiOptions options); + /// /// List the authenticated user’s starred gists /// @@ -72,6 +121,16 @@ namespace Octokit.Reactive /// Only gists updated at or after this time are returned IObservable GetAllStarred(DateTimeOffset since); + /// + /// List the authenticated user’s starred gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + IObservable GetAllStarred(DateTimeOffset since, ApiOptions options); + /// /// List a user's gists /// @@ -81,6 +140,16 @@ namespace Octokit.Reactive /// The user IObservable GetAllForUser(string user); + /// + /// List a user's gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// The user + /// Options for changing the API response + IObservable GetAllForUser(string user, ApiOptions options); + /// /// List a user's gists /// @@ -91,6 +160,17 @@ namespace Octokit.Reactive /// Only gists updated at or after this time are returned IObservable GetAllForUser(string user, DateTimeOffset since); + /// + /// List a user's gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// The user + /// Only gists updated at or after this time are returned + /// Options for changing the API response + IObservable GetAllForUser(string user, DateTimeOffset since, ApiOptions options); + /// /// List gist commits /// @@ -100,6 +180,16 @@ namespace Octokit.Reactive /// The id of the gist IObservable GetAllCommits(string id); + /// + /// List gist commits + /// + /// + /// http://developer.github.com/v3/gists/#list-gists-commits + /// + /// The id of the gist + /// Options for changing the API response + IObservable GetAllCommits(string id, ApiOptions options); + /// /// List gist forks /// @@ -109,6 +199,16 @@ namespace Octokit.Reactive /// The id of the gist IObservable GetAllForks(string id); + /// + /// List gist forks + /// + /// + /// http://developer.github.com/v3/gists/#list-gists-forks + /// + /// The id of the gist + /// Options for changing the API response + IObservable GetAllForks(string id, ApiOptions options); + /// /// Creates a new gist /// diff --git a/Octokit.Reactive/Clients/ObservableGistsClient.cs b/Octokit.Reactive/Clients/ObservableGistsClient.cs index 9d63c775..1dbd817a 100644 --- a/Octokit.Reactive/Clients/ObservableGistsClient.cs +++ b/Octokit.Reactive/Clients/ObservableGistsClient.cs @@ -84,7 +84,22 @@ namespace Octokit.Reactive /// public IObservable GetAll() { - return _connection.GetAndFlattenAllPages(ApiUrls.Gist()); + return GetAll(ApiOptions.None); + } + + /// + /// List the authenticated user’s gists or if called anonymously, + /// this will return all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + public IObservable GetAll(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.Gist(), options); } /// @@ -96,9 +111,25 @@ namespace Octokit.Reactive /// /// Only gists updated at or after this time are returned public IObservable GetAll(DateTimeOffset since) + { + return GetAll(since, ApiOptions.None); + } + + /// + /// List the authenticated user’s gists or if called anonymously, + /// this will return all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + public IObservable GetAll(DateTimeOffset since, ApiOptions options) { + Ensure.ArgumentNotNull(options, "options"); + var request = new GistRequest(since); - return _connection.GetAndFlattenAllPages(ApiUrls.Gist(), request.ToParametersDictionary()); + return _connection.GetAndFlattenAllPages(ApiUrls.Gist(), request.ToParametersDictionary(), options); } /// @@ -109,7 +140,21 @@ namespace Octokit.Reactive /// public IObservable GetAllPublic() { - return _connection.GetAndFlattenAllPages(ApiUrls.PublicGists()); + return GetAllPublic(ApiOptions.None); + } + + /// + /// Lists all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + public IObservable GetAllPublic(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.PublicGists(), options); } /// @@ -121,8 +166,23 @@ namespace Octokit.Reactive /// Only gists updated at or after this time are returned public IObservable GetAllPublic(DateTimeOffset since) { + return GetAllPublic(since, ApiOptions.None); + } + + /// + /// Lists all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + public IObservable GetAllPublic(DateTimeOffset since, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + var request = new GistRequest(since); - return _connection.GetAndFlattenAllPages(ApiUrls.PublicGists(), request.ToParametersDictionary()); + return _connection.GetAndFlattenAllPages(ApiUrls.PublicGists(), request.ToParametersDictionary(), options); } /// @@ -133,7 +193,21 @@ namespace Octokit.Reactive /// public IObservable GetAllStarred() { - return _connection.GetAndFlattenAllPages(ApiUrls.StarredGists()); + return GetAllStarred(ApiOptions.None); + } + + /// + /// List the authenticated user’s starred gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + public IObservable GetAllStarred(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.StarredGists(), options); } /// @@ -145,8 +219,23 @@ namespace Octokit.Reactive /// Only gists updated at or after this time are returned public IObservable GetAllStarred(DateTimeOffset since) { + return GetAllStarred(since, ApiOptions.None); + } + + /// + /// List the authenticated user’s starred gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + public IObservable GetAllStarred(DateTimeOffset since, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + var request = new GistRequest(since); - return _connection.GetAndFlattenAllPages(ApiUrls.StarredGists(), request.ToParametersDictionary()); + return _connection.GetAndFlattenAllPages(ApiUrls.StarredGists(), request.ToParametersDictionary(), options); } /// @@ -158,9 +247,25 @@ namespace Octokit.Reactive /// The user public IObservable GetAllForUser(string user) { - Ensure.ArgumentNotNull(user, "user"); + Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return _connection.GetAndFlattenAllPages(ApiUrls.UsersGists(user)); + return GetAllForUser(user, ApiOptions.None); + } + + /// + /// List a user's gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// The user + /// Options for changing the API response + public IObservable GetAllForUser(string user, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.UsersGists(user), options); } /// @@ -173,10 +278,27 @@ namespace Octokit.Reactive /// Only gists updated at or after this time are returned public IObservable GetAllForUser(string user, DateTimeOffset since) { - Ensure.ArgumentNotNull(user, "user"); + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + + return GetAllForUser(user, since, ApiOptions.None); + } + + /// + /// List a user's gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// The user + /// Only gists updated at or after this time are returned + /// Options for changing the API response + public IObservable GetAllForUser(string user, DateTimeOffset since, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); var request = new GistRequest(since); - return _connection.GetAndFlattenAllPages(ApiUrls.UsersGists(user), request.ToParametersDictionary()); + return _connection.GetAndFlattenAllPages(ApiUrls.UsersGists(user), request.ToParametersDictionary(), options); } /// @@ -190,7 +312,23 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNullOrEmptyString(id, "id"); - return _connection.GetAndFlattenAllPages(ApiUrls.GistCommits(id)); + return GetAllCommits(id, ApiOptions.None); + } + + /// + /// List gist commits + /// + /// + /// http://developer.github.com/v3/gists/#list-gists-commits + /// + /// The id of the gist + /// Options for changing the API response + public IObservable GetAllCommits(string id, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(id, "id"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.GistCommits(id), options); } /// @@ -204,7 +342,23 @@ namespace Octokit.Reactive { Ensure.ArgumentNotNullOrEmptyString(id, "id"); - return _connection.GetAndFlattenAllPages(ApiUrls.ForkGist(id)); + return GetAllForks(id, ApiOptions.None); + } + + /// + /// List gist forks + /// + /// + /// http://developer.github.com/v3/gists/#list-gists-forks + /// + /// The id of the gist + /// Options for changing the API response + public IObservable GetAllForks(string id, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(id, "id"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.ForkGist(id), options); } /// diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index ef172d00..2155cd1e 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -138,6 +138,7 @@ + diff --git a/Octokit.Tests.Integration/Reactive/ObservableGistClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableGistClientTests.cs new file mode 100644 index 00000000..0dbd1975 --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableGistClientTests.cs @@ -0,0 +1,720 @@ +using System; +using System.Reactive.Linq; +using System.Threading.Tasks; +using Octokit; +using Octokit.Reactive; +using Octokit.Tests.Integration; +using Xunit; + +public class ObservableGistClientTests +{ + public class TheGetAllMethod + { + readonly ObservableGistsClient _gistsClient; + + public TheGetAllMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _gistsClient = new ObservableGistsClient(github); + } + + [IntegrationTest] + public async Task ReturnsGists() + { + var gists = await _gistsClient.GetAll().ToList(); + + Assert.NotEmpty(gists); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfGistsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var gists = await _gistsClient.GetAll(options).ToList(); + + Assert.Equal(5, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfGistsWithStart() + { + var options = new ApiOptions + { + PageSize = 4, + PageCount = 1, + StartPage = 2 + }; + + var gists = await _gistsClient.GetAll(options).ToList(); + + Assert.Equal(4, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 4, + PageCount = 1 + }; + + var firstGistsPage = await _gistsClient.GetAll(startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 4, + PageCount = 1, + StartPage = 2 + }; + + var secondGistsPage = await _gistsClient.GetAll(skipStartOptions).ToList(); + + Assert.NotEqual(firstGistsPage[0].Id, secondGistsPage[0].Id); + Assert.NotEqual(firstGistsPage[1].Id, secondGistsPage[1].Id); + Assert.NotEqual(firstGistsPage[2].Id, secondGistsPage[2].Id); + Assert.NotEqual(firstGistsPage[3].Id, secondGistsPage[3].Id); + } + + [IntegrationTest] + public async Task ReturnsGistsSince() + { + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAll(since).ToList(); + + Assert.NotEmpty(gists); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfGistsSinceWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAll(since, options).ToList(); + + Assert.Equal(5, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfGistsSinceWithStart() + { + var options = new ApiOptions + { + PageSize = 4, + PageCount = 1, + StartPage = 2 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAll(since, options).ToList(); + + Assert.Equal(4, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctGistsSinceBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 4, + PageCount = 1 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var firstGistsPage = await _gistsClient.GetAll(since, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 4, + PageCount = 1, + StartPage = 2 + }; + + var secondGistsPage = await _gistsClient.GetAll(since, skipStartOptions).ToList(); + + Assert.NotEqual(firstGistsPage[0].Id, secondGistsPage[0].Id); + Assert.NotEqual(firstGistsPage[1].Id, secondGistsPage[1].Id); + Assert.NotEqual(firstGistsPage[2].Id, secondGistsPage[2].Id); + Assert.NotEqual(firstGistsPage[3].Id, secondGistsPage[3].Id); + } + } + + public class TheGetAllPublicMethod + { + readonly ObservableGistsClient _gistsClient; + + public TheGetAllPublicMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _gistsClient = new ObservableGistsClient(github); + } + + [IntegrationTest] + public async Task ReturnsPublicGists() + { + var gists = await _gistsClient.GetAllPublic().ToList(); + + Assert.NotEmpty(gists); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfPublicGistsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var gists = await _gistsClient.GetAllPublic(options).ToList(); + + Assert.Equal(5, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfPublicGistsWithStart() + { + var options = new ApiOptions + { + PageSize = 4, + PageCount = 1, + StartPage = 2 + }; + + var gists = await _gistsClient.GetAllPublic(options).ToList(); + + Assert.Equal(4, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 4, + PageCount = 1 + }; + + var firstPublicGistsPage = await _gistsClient.GetAllPublic(startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 4, + PageCount = 1, + StartPage = 2 + }; + + var secondPublicGistsPage = await _gistsClient.GetAllPublic(skipStartOptions).ToList(); + + Assert.NotEqual(firstPublicGistsPage[0].Id, secondPublicGistsPage[0].Id); + Assert.NotEqual(firstPublicGistsPage[1].Id, secondPublicGistsPage[1].Id); + Assert.NotEqual(firstPublicGistsPage[2].Id, secondPublicGistsPage[2].Id); + Assert.NotEqual(firstPublicGistsPage[3].Id, secondPublicGistsPage[3].Id); + } + + [IntegrationTest] + public async Task ReturnsPublicGistsSince() + { + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAllPublic(since).ToList(); + + Assert.NotEmpty(gists); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfPublicGistsSinceWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAllPublic(since, options).ToList(); + + Assert.Equal(5, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfPublicGistsSinceWithStart() + { + var options = new ApiOptions + { + PageSize = 4, + PageCount = 1, + StartPage = 2 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAllPublic(since, options).ToList(); + + Assert.Equal(4, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctPublicGistsSinceBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 4, + PageCount = 1 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var firstPublicGistsPage = await _gistsClient.GetAllPublic(since, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 4, + PageCount = 1, + StartPage = 2 + }; + + var secondPublicGistsPage = await _gistsClient.GetAllPublic(since, skipStartOptions).ToList(); + + Assert.NotEqual(firstPublicGistsPage[0].Id, secondPublicGistsPage[0].Id); + Assert.NotEqual(firstPublicGistsPage[1].Id, secondPublicGistsPage[1].Id); + Assert.NotEqual(firstPublicGistsPage[2].Id, secondPublicGistsPage[2].Id); + Assert.NotEqual(firstPublicGistsPage[3].Id, secondPublicGistsPage[3].Id); + } + } + + public class TheGetAllStarredMethod + { + readonly ObservableGistsClient _gistsClient; + + public TheGetAllStarredMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _gistsClient = new ObservableGistsClient(github); + } + + [IntegrationTest] + public async Task ReturnsStartedGists() + { + var gists = await _gistsClient.GetAllStarred().ToList(); + + Assert.NotEmpty(gists); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfStartedGistsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var gists = await _gistsClient.GetAllStarred(options).ToList(); + + Assert.Equal(5, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfStartedGistsWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var gists = await _gistsClient.GetAllStarred(options).ToList(); + + Assert.Equal(5, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstStartedGistsPage = await _gistsClient.GetAllStarred(startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondStartedGistsPage = await _gistsClient.GetAllStarred(skipStartOptions).ToList(); + + Assert.NotEqual(firstStartedGistsPage[0].Id, secondStartedGistsPage[0].Id); + Assert.NotEqual(firstStartedGistsPage[1].Id, secondStartedGistsPage[1].Id); + Assert.NotEqual(firstStartedGistsPage[2].Id, secondStartedGistsPage[2].Id); + Assert.NotEqual(firstStartedGistsPage[3].Id, secondStartedGistsPage[3].Id); + Assert.NotEqual(firstStartedGistsPage[4].Id, secondStartedGistsPage[4].Id); + } + + [IntegrationTest] + public async Task ReturnsStartedGistsSince() + { + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAllStarred(since).ToList(); + + Assert.NotEmpty(gists); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfStartedGistsSinceWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAllStarred(since, options).ToList(); + + Assert.Equal(5, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfStartedGistsSinceWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAllStarred(since, options).ToList(); + + Assert.Equal(5, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctStartedGistsSinceBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var firstStartedGistsPage = await _gistsClient.GetAllStarred(since, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondStartedGistsPage = await _gistsClient.GetAllStarred(since, skipStartOptions).ToList(); + + Assert.NotEqual(firstStartedGistsPage[0].Id, secondStartedGistsPage[0].Id); + Assert.NotEqual(firstStartedGistsPage[1].Id, secondStartedGistsPage[1].Id); + Assert.NotEqual(firstStartedGistsPage[2].Id, secondStartedGistsPage[2].Id); + Assert.NotEqual(firstStartedGistsPage[3].Id, secondStartedGistsPage[3].Id); + Assert.NotEqual(firstStartedGistsPage[4].Id, secondStartedGistsPage[4].Id); + } + } + + public class TheGetAllForUserMethod + { + readonly ObservableGistsClient _gistsClient; + const string user = "shiftkey"; + + public TheGetAllForUserMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _gistsClient = new ObservableGistsClient(github); + } + + [IntegrationTest] + public async Task ReturnsUserGists() + { + var gists = await _gistsClient.GetAllForUser(user).ToList(); + + Assert.NotEmpty(gists); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserGistsWithoutStart() + { + var options = new ApiOptions + { + PageSize = 3, + PageCount = 1 + }; + + var gists = await _gistsClient.GetAllForUser(user, options).ToList(); + + Assert.Equal(3, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserGistsWithStart() + { + var options = new ApiOptions + { + PageSize = 3, + PageCount = 1, + StartPage = 2 + }; + + var gists = await _gistsClient.GetAllForUser(user, options).ToList(); + + Assert.Equal(3, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 3, + PageCount = 1 + }; + + var firstUsersGistsPage = await _gistsClient.GetAllForUser(user, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 3, + PageCount = 1, + StartPage = 2 + }; + + var secondUsersGistsPage = await _gistsClient.GetAllForUser(user, skipStartOptions).ToList(); + + Assert.NotEqual(firstUsersGistsPage[0].Id, secondUsersGistsPage[0].Id); + Assert.NotEqual(firstUsersGistsPage[1].Id, secondUsersGistsPage[1].Id); + Assert.NotEqual(firstUsersGistsPage[2].Id, secondUsersGistsPage[2].Id); + } + + [IntegrationTest] + public async Task ReturnsUserGistsSince() + { + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAllForUser(user, since).ToList(); + + Assert.NotEmpty(gists); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserGistsSinceWithoutStart() + { + var options = new ApiOptions + { + PageSize = 3, + PageCount = 1 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAllForUser(user, since, options).ToList(); + + Assert.Equal(3, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfUserGistsSinceWithStart() + { + var options = new ApiOptions + { + PageSize = 3, + PageCount = 1, + StartPage = 2 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var gists = await _gistsClient.GetAllForUser(user, since, options).ToList(); + + Assert.Equal(3, gists.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctUserGistsSinceBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 3, + PageCount = 1 + }; + var since = new DateTimeOffset(new DateTime(2016, 1, 1)); + var firstUserGistsPage = await _gistsClient.GetAllForUser(user, since, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 3, + PageCount = 1, + StartPage = 2 + }; + + var secondUserGistsPage = await _gistsClient.GetAllForUser(user, since, skipStartOptions).ToList(); + + Assert.NotEqual(firstUserGistsPage[0].Id, secondUserGistsPage[0].Id); + Assert.NotEqual(firstUserGistsPage[1].Id, secondUserGistsPage[1].Id); + Assert.NotEqual(firstUserGistsPage[2].Id, secondUserGistsPage[2].Id); + } + } + + public class TheGetAllCommitsMethod + { + readonly ObservableGistsClient _gistsClient; + const string gistId = "670c22f3966e662d2f83"; + + public TheGetAllCommitsMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _gistsClient = new ObservableGistsClient(github); + } + + [IntegrationTest] + public async Task ReturnsGistCommits() + { + var gistCommits = await _gistsClient.GetAllCommits(gistId).ToList(); + + Assert.NotEmpty(gistCommits); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfGistCommisWithoutStart() + { + var options = new ApiOptions + { + PageSize = 3, + PageCount = 1 + }; + + var gistCommits = await _gistsClient.GetAllCommits(gistId, options).ToList(); + + Assert.Equal(3, gistCommits.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountGistCommitsWithStart() + { + var options = new ApiOptions + { + PageSize = 3, + PageCount = 1, + StartPage = 2 + }; + + var gistCommits = await _gistsClient.GetAllCommits(gistId, options).ToList(); + + Assert.Equal(3, gistCommits.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 3, + PageCount = 1 + }; + + var firstGistCommitsPage = await _gistsClient.GetAllCommits(gistId, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 3, + PageCount = 1, + StartPage = 2 + }; + + var secondGistCommitsPage = await _gistsClient.GetAllCommits(gistId, skipStartOptions).ToList(); + + Assert.NotEqual(firstGistCommitsPage[0].Url, secondGistCommitsPage[0].Url); + Assert.NotEqual(firstGistCommitsPage[1].Url, secondGistCommitsPage[1].Url); + Assert.NotEqual(firstGistCommitsPage[2].Url, secondGistCommitsPage[2].Url); + } + } + + public class TheGetAllForksMethod + { + readonly ObservableGistsClient _gistsClient; + const string gistId = "670c22f3966e662d2f83"; + + public TheGetAllForksMethod() + { + var github = Helper.GetAuthenticatedClient(); + + _gistsClient = new ObservableGistsClient(github); + } + + [IntegrationTest] + public async Task ReturnsGistCommits() + { + var gistForks = await _gistsClient.GetAllForks(gistId).ToList(); + + Assert.NotEmpty(gistForks); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfGistForksWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var gistForks = await _gistsClient.GetAllForks(gistId, options).ToList(); + + Assert.Equal(5, gistForks.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountGistForksWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var gistForks = await _gistsClient.GetAllForks(gistId, options).ToList(); + + Assert.Equal(5, gistForks.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstGistForksPage = await _gistsClient.GetAllForks(gistId, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondGistForksPage = await _gistsClient.GetAllForks(gistId, skipStartOptions).ToList(); + + Assert.NotEqual(firstGistForksPage[0].Url, secondGistForksPage[0].Url); + Assert.NotEqual(firstGistForksPage[1].Url, secondGistForksPage[1].Url); + Assert.NotEqual(firstGistForksPage[2].Url, secondGistForksPage[2].Url); + Assert.NotEqual(firstGistForksPage[3].Url, secondGistForksPage[3].Url); + Assert.NotEqual(firstGistForksPage[4].Url, secondGistForksPage[4].Url); + } + } +} + diff --git a/Octokit.Tests/Clients/GistsClientTests.cs b/Octokit.Tests/Clients/GistsClientTests.cs index a0519246..8934f52e 100644 --- a/Octokit.Tests/Clients/GistsClientTests.cs +++ b/Octokit.Tests/Clients/GistsClientTests.cs @@ -1,14 +1,37 @@ using NSubstitute; -using Octokit; using Octokit.Internal; using System; using System.Collections.Generic; using System.Net; using System.Threading.Tasks; +using Octokit; +using Octokit.Tests; using Xunit; public class GistsClientTests { + public static Dictionary DictionaryWithSince + { + get { return Arg.Is>(d => d.ContainsKey("since")); } + } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new GistsClient(null)); + } + + [Fact] + public void SetCommentsClient() + { + var apiConnection = Substitute.For(); + var client = new GistsClient(apiConnection); + Assert.NotNull(client.Comment); + } + } + public class TheGetMethod { [Fact] @@ -32,8 +55,26 @@ public class GistsClientTests var client = new GistsClient(connection); client.GetAll(); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectGetAllUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + + client.GetAll(options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists"), options); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists")); } [Fact] @@ -46,9 +87,42 @@ public class GistsClientTests client.GetAll(since); connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists"), - Arg.Is>(x => x.ContainsKey("since"))); + DictionaryWithSince, Args.ApiOptions); } + [Fact] + public void RequestsCorrectGetAllWithSinceUrlAndApiOptions() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + DateTimeOffset since = DateTimeOffset.Now; + client.GetAll(since, options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists"), + DictionaryWithSince, options); + + } + + [Fact] + public async Task EnsureNonNullArguments() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + await Assert.ThrowsAsync(() => client.GetAll(null)); + await Assert.ThrowsAsync(() => client.GetAll(DateTimeOffset.Now, null)); + } + } + + public class TheGetAllPublicMethod + { [Fact] public void RequestsCorrectGetAllPublicUrl() { @@ -57,7 +131,25 @@ public class GistsClientTests client.GetAllPublic(); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/public")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/public"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectGetAllPublicUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAllPublic(options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/public"), options); + } [Fact] @@ -70,9 +162,43 @@ public class GistsClientTests client.GetAllPublic(since); connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/public"), - Arg.Is>(x => x.ContainsKey("since"))); + DictionaryWithSince, Args.ApiOptions); } + [Fact] + public void RequestsCorrectGetAllPublicWithSinceUrlAndApiOptions() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + DateTimeOffset since = DateTimeOffset.Now; + client.GetAllPublic(since, options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/public"), + DictionaryWithSince, options); + } + + [Fact] + public async Task EnsureNonNullArguments() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + await Assert.ThrowsAsync(() => client.GetAllPublic(null)); + await Assert.ThrowsAsync(() => client.GetAllPublic(DateTimeOffset.Now, null)); + + } + + } + + public class TheGetAllStarredMethod + { [Fact] public void RequestsCorrectGetAllStarredUrl() { @@ -81,7 +207,25 @@ public class GistsClientTests client.GetAllStarred(); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/starred")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/starred"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectGetAllStarredUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAllStarred(options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/starred"), options); + } [Fact] @@ -94,9 +238,41 @@ public class GistsClientTests client.GetAllStarred(since); connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/starred"), - Arg.Is>(x => x.ContainsKey("since"))); + DictionaryWithSince, Args.ApiOptions); } + [Fact] + public void RequestsCorrectGetAllStarredWithSinceUrlAndApiOptions() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + DateTimeOffset since = DateTimeOffset.Now; + client.GetAllStarred(since, options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/starred"), + DictionaryWithSince, options); + } + [Fact] + public async Task EnsureNonNullArguments() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + await Assert.ThrowsAsync(() => client.GetAllStarred(null)); + await Assert.ThrowsAsync(() => client.GetAllStarred(DateTimeOffset.Now, null)); + + } + } + + public class TheGetAllForUserMethod + { [Fact] public void RequestsCorrectGetGistsForAUserUrl() { @@ -105,7 +281,25 @@ public class GistsClientTests client.GetAllForUser("octokit"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/octokit/gists")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/octokit/gists"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectGetGistsForAUserUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAllForUser("octokit", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/octokit/gists"), options); + } [Fact] @@ -118,25 +312,47 @@ public class GistsClientTests client.GetAllForUser("octokit", since); connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/octokit/gists"), - Arg.Is>(x => x.ContainsKey("since"))); - } - } + DictionaryWithSince, Args.ApiOptions); + + } + + [Fact] + public void RequestsCorrectGetGistsForAUserWithSinceUrlAndApiOptions() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + DateTimeOffset since = DateTimeOffset.Now; + client.GetAllForUser("octokit", since, options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "users/octokit/gists"), + DictionaryWithSince, options); + } + - public class TheGetChildrenMethods - { [Fact] public async Task EnsureNonNullArguments() { var connection = Substitute.For(); var client = new GistsClient(connection); - await Assert.ThrowsAsync(() => client.GetAllCommits(null)); - await Assert.ThrowsAsync(() => client.GetAllCommits("")); - - await Assert.ThrowsAsync(() => client.GetAllForks(null)); - await Assert.ThrowsAsync(() => client.GetAllForks("")); + await Assert.ThrowsAsync(() => client.GetAllForUser(null)); + await Assert.ThrowsAsync(() => client.GetAllForUser("")); + await Assert.ThrowsAsync(() => client.GetAllForUser("", DateTimeOffset.Now)); + await Assert.ThrowsAsync(() => client.GetAllForUser("", DateTimeOffset.Now, ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAllForUser("user", DateTimeOffset.Now, null)); } + } + + public class TheGetAllCommitsMethod + { [Fact] public void RequestsCorrectGetCommitsUrl() { @@ -145,9 +361,42 @@ public class GistsClientTests client.GetAllCommits("9257657"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/9257657/commits")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/9257657/commits"), Args.ApiOptions); } + [Fact] + public void RequestsCorrectGetCommitsUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + var options = new ApiOptions() + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAllCommits("9257657", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/9257657/commits"), options); + } + + [Fact] + public async Task EnsureNonNullArguments() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + await Assert.ThrowsAsync(() => client.GetAllCommits(null)); + await Assert.ThrowsAsync(() => client.GetAllCommits("")); + await Assert.ThrowsAsync(() => client.GetAllCommits("id", null)); + await Assert.ThrowsAsync(() => client.GetAllCommits("", ApiOptions.None)); + } + + } + + public class TheGetAllForksMethod + { [Fact] public void RequestsCorrectGetForksUrl() { @@ -156,7 +405,36 @@ public class GistsClientTests client.GetAllForks("9257657"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/9257657/forks")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/9257657/forks"), Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectGetForksUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + var options = new ApiOptions() + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAllForks("9257657", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "gists/9257657/forks"), options); + } + + [Fact] + public async Task EnsureNonNullArguments() + { + var connection = Substitute.For(); + var client = new GistsClient(connection); + + await Assert.ThrowsAsync(() => client.GetAllForks(null)); + await Assert.ThrowsAsync(() => client.GetAllForks("")); + await Assert.ThrowsAsync(() => client.GetAllForks("id", null)); + await Assert.ThrowsAsync(() => client.GetAllForks("", ApiOptions.None)); } } @@ -274,7 +552,8 @@ public class GistsClientTests client.Fork("1"); connection.Received().Post(Arg.Is(u => u.ToString() == "gists/1/forks"), - Arg.Any()); + Arg.Any()); + } } @@ -301,21 +580,4 @@ public class GistsClientTests connection.Received().Patch(Arg.Is(u => u.ToString() == "gists/1"), Arg.Any()); } } - - public class TheCtor - { - [Fact] - public void EnsuresNonNullArguments() - { - Assert.Throws(() => new GistsClient(null)); - } - - [Fact] - public void SetCommentsClient() - { - var apiConnection = Substitute.For(); - var client = new GistsClient(apiConnection); - Assert.NotNull(client.Comment); - } - } -} +} \ No newline at end of file diff --git a/Octokit.Tests/Helpers/Arg.cs b/Octokit.Tests/Helpers/Arg.cs index 5408f72d..bee4238b 100644 --- a/Octokit.Tests/Helpers/Arg.cs +++ b/Octokit.Tests/Helpers/Arg.cs @@ -51,7 +51,7 @@ namespace Octokit.Tests public static Dictionary EmptyDictionary { get { return Arg.Is>(d => d.Count == 0); } - } + } public static OrganizationUpdate OrganizationUpdate { diff --git a/Octokit.Tests/Reactive/ObservableGistsTests.cs b/Octokit.Tests/Reactive/ObservableGistsTests.cs index 0f6b7bab..7a8280d8 100644 --- a/Octokit.Tests/Reactive/ObservableGistsTests.cs +++ b/Octokit.Tests/Reactive/ObservableGistsTests.cs @@ -1,57 +1,418 @@ using System; using System.Collections.Generic; -using System.Reactive.Linq; -using System.Reactive.Threading.Tasks; -using System.Threading.Tasks; using NSubstitute; -using Octokit; -using Octokit.Internal; using Octokit.Reactive; -using Octokit.Reactive.Internal; -using Octokit.Tests.Helpers; using Xunit; -using Xunit.Extensions; + namespace Octokit.Tests.Reactive { public class ObservableGistsTests { - public class TheGetChildrenMethods + public static Dictionary DictionaryWithSince + { + get { return Arg.Is>(d => d.ContainsKey("since")); } + } + public static Dictionary DictionaryWithApiOptions + { + get { return Arg.Is>(d => d.ContainsKey("per_page") && d.ContainsKey("page")); } + } + + public static Dictionary DictionaryWithApiOptionsAndSince + { + get { return Arg.Is>(d => d.ContainsKey("per_page") && d.ContainsKey("page") && d.ContainsKey("since")); } + } + + public class TheCtorMethod { [Fact] - public async Task EnsureNonNullArguments() + public void EnsuresNonNullArguments() { - var client = new ObservableGistsClient(Substitute.For()); + Assert.Throws(() => new ObservableGistsClient(null)); + } + } - await Assert.ThrowsAsync(() => client.GetAllCommits(null).ToTask()); - await Assert.ThrowsAsync(() => client.GetAllCommits("").ToTask()); + public class TheGetAllMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); - await Assert.ThrowsAsync(() => client.GetAllForks(null).ToTask()); - await Assert.ThrowsAsync(() => client.GetAllForks("").ToTask()); + client.GetAll(); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists"), Args.EmptyDictionary, null); } [Fact] - public void RequestsCorrectGetCommitsUrl() + public void RequestsTheCorrectUrlWithApiOptions() { - var github = Substitute.For(); - var client = new ObservableGistsClient(github); - var expected = new Uri("gists/9257657/commits", UriKind.Relative); + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); - client.GetAllCommits("9257657"); + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAll(options); - github.Connection.Received(1).Get>(expected, Arg.Any>(), null); + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists"), + DictionaryWithApiOptions, null); } [Fact] - public void RequestsCorrectGetForksUrl() + public void RequestsTheCorrectUrlWithSince() { - var github = Substitute.For(); - var client = new ObservableGistsClient(github); - var expected = new Uri("gists/9257657/forks", UriKind.Relative); + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); - client.GetAllForks("9257657"); + var since = DateTimeOffset.Now; + client.GetAll(since); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists"), DictionaryWithSince, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithSinceAndApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var options = new ApiOptions() + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + var since = DateTimeOffset.Now; + client.GetAll(since, options); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists"), + DictionaryWithApiOptionsAndSince, null); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var gitsClient = new ObservableGistsClient(Substitute.For()); + + Assert.Throws(() => gitsClient.GetAll(null)); + Assert.Throws(() => gitsClient.GetAll(DateTimeOffset.Now, null)); + } + } + + public class TheGetAllPublicMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + client.GetAllPublic(); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists/public"), Args.EmptyDictionary, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAllPublic(options); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists/public"), + DictionaryWithApiOptions, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithSince() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var since = DateTimeOffset.Now; + client.GetAllPublic(since); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists/public"), DictionaryWithSince, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithSinceAndApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var options = new ApiOptions() + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + var since = DateTimeOffset.Now; + client.GetAllPublic(since, options); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists/public"), + DictionaryWithApiOptionsAndSince, null); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var gitsClient = new ObservableGistsClient(Substitute.For()); + + Assert.Throws(() => gitsClient.GetAllPublic(null)); + Assert.Throws(() => gitsClient.GetAllPublic(DateTimeOffset.Now, null)); + } + } + + public class TheGetAllStarredMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + client.GetAllStarred(); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists/starred"), Args.EmptyDictionary, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAllStarred(options); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists/starred"), + DictionaryWithApiOptions, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithSince() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var since = DateTimeOffset.Now; + client.GetAllStarred(since); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists/starred"), DictionaryWithSince, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithSinceAndApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var options = new ApiOptions() + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + var since = DateTimeOffset.Now; + client.GetAllStarred(since, options); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists/starred"), + DictionaryWithApiOptionsAndSince, null); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var gitsClient = new ObservableGistsClient(Substitute.For()); + + Assert.Throws(() => gitsClient.GetAllStarred(null)); + Assert.Throws(() => gitsClient.GetAllStarred(DateTimeOffset.Now, null)); + } + } + + public class TheGetAllForUserMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + client.GetAllForUser("samthedev"); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "users/samthedev/gists"), Args.EmptyDictionary, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAllForUser("samthedev", options); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "users/samthedev/gists"), + DictionaryWithApiOptions, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithSince() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var since = DateTimeOffset.Now; + var user = "samthedev"; + client.GetAllForUser(user, since); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "users/samthedev/gists"), DictionaryWithSince, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithSinceAndApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var options = new ApiOptions() + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + var since = DateTimeOffset.Now; + var user = "samthedev"; + client.GetAllForUser(user, since, options); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "users/samthedev/gists"), + DictionaryWithApiOptionsAndSince, null); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var gitsClient = new ObservableGistsClient(Substitute.For()); + + Assert.Throws(() => gitsClient.GetAllForUser(null)); + Assert.Throws(() => gitsClient.GetAllForUser("")); + Assert.Throws(() => gitsClient.GetAllForUser(null, DateTimeOffset.Now)); + Assert.Throws(() => gitsClient.GetAllForUser("", DateTimeOffset.Now)); + Assert.Throws(() => gitsClient.GetAllForUser("samthedev",DateTimeOffset.Now, null)); + Assert.Throws(() => gitsClient.GetAllForUser("",DateTimeOffset.Now, ApiOptions.None)); + } + } + + public class TheGetAllCommitsMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + client.GetAllCommits("id"); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists/id/commits"), Args.EmptyDictionary, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAllCommits("id", options); + + gitHubClient.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == "gists/id/commits"), + DictionaryWithApiOptions, null); + } + + + [Fact] + public void EnsuresNonNullArguments() + { + var gitsClient = new ObservableGistsClient(Substitute.For()); + + Assert.Throws(() => gitsClient.GetAllCommits(null)); + Assert.Throws(() => gitsClient.GetAllCommits("")); + Assert.Throws(() => gitsClient.GetAllCommits("id", null)); + Assert.Throws(() => gitsClient.GetAllCommits("", ApiOptions.None)); + + } + } + + public class TheGetAllForksMethod + { + [Fact] + public void RequestsTheCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + client.GetAllForks("id"); + + gitHubClient.Connection.Received(1).Get>(new Uri("gists/id/forks", UriKind.Relative), Args.EmptyDictionary, null); + } + + [Fact] + public void RequestsTheCorrectUrlWithApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableGistsClient(gitHubClient); + + var options = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 1 + }; + client.GetAllForks("id", options); + + gitHubClient.Connection.Received(1).Get>(new Uri("gists/id/forks", UriKind.Relative), + DictionaryWithApiOptions, null); + } + + + [Fact] + public void EnsuresNonNullArguments() + { + var gitsClient = new ObservableGistsClient(Substitute.For()); + + Assert.Throws(() => gitsClient.GetAllForks(null)); + Assert.Throws(() => gitsClient.GetAllForks("")); + Assert.Throws(() => gitsClient.GetAllForks("id", null)); + Assert.Throws(() => gitsClient.GetAllForks("", ApiOptions.None)); - github.Connection.Received(1).Get>(expected, Arg.Any>(), null); } } } diff --git a/Octokit/Clients/GistsClient.cs b/Octokit/Clients/GistsClient.cs index 929d08e2..e3d567ba 100644 --- a/Octokit/Clients/GistsClient.cs +++ b/Octokit/Clients/GistsClient.cs @@ -87,7 +87,7 @@ namespace Octokit /// The id of the gist public Task Delete(string id) { - Ensure.ArgumentNotNull(id, "id"); + Ensure.ArgumentNotNullOrEmptyString(id, "id"); return ApiConnection.Delete(ApiUrls.Gist(id)); } @@ -101,7 +101,22 @@ namespace Octokit /// public Task> GetAll() { - return ApiConnection.GetAll(ApiUrls.Gist()); + return GetAll(ApiOptions.None); + } + + /// + /// List the authenticated user’s gists or if called anonymously, + /// this will return all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + public Task> GetAll(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.Gist(), options); } /// @@ -114,8 +129,25 @@ namespace Octokit /// Only gists updated at or after this time are returned public Task> GetAll(DateTimeOffset since) { + + return GetAll(since, ApiOptions.None); + } + + /// + /// List the authenticated user’s gists or if called anonymously, + /// this will return all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + public Task> GetAll(DateTimeOffset since, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + var request = new GistRequest(since); - return ApiConnection.GetAll(ApiUrls.Gist(), request.ToParametersDictionary()); + return ApiConnection.GetAll(ApiUrls.Gist(), request.ToParametersDictionary(), options); } /// @@ -126,7 +158,21 @@ namespace Octokit /// public Task> GetAllPublic() { - return ApiConnection.GetAll(ApiUrls.PublicGists()); + return GetAllPublic(ApiOptions.None); + } + + /// + /// Lists all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + public Task> GetAllPublic(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.PublicGists(), options); } /// @@ -137,9 +183,25 @@ namespace Octokit /// /// Only gists updated at or after this time are returned public Task> GetAllPublic(DateTimeOffset since) + { + + return GetAllPublic(since, ApiOptions.None); + } + + /// + /// Lists all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + public Task> GetAllPublic(DateTimeOffset since, ApiOptions options) { + Ensure.ArgumentNotNull(options, "options"); + var request = new GistRequest(since); - return ApiConnection.GetAll(ApiUrls.PublicGists(), request.ToParametersDictionary()); + return ApiConnection.GetAll(ApiUrls.PublicGists(), request.ToParametersDictionary(), options); } /// @@ -150,7 +212,22 @@ namespace Octokit /// public Task> GetAllStarred() { - return ApiConnection.GetAll(ApiUrls.StarredGists()); + + return GetAllStarred(ApiOptions.None); + } + + /// + /// List the authenticated user’s starred gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + public Task> GetAllStarred(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.StarredGists(), options); } /// @@ -161,9 +238,25 @@ namespace Octokit /// /// Only gists updated at or after this time are returned public Task> GetAllStarred(DateTimeOffset since) + { + + return GetAllStarred(since, ApiOptions.None); + } + + /// + /// List the authenticated user’s starred gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + public Task> GetAllStarred(DateTimeOffset since, ApiOptions options) { + Ensure.ArgumentNotNull(options, "options"); + var request = new GistRequest(since); - return ApiConnection.GetAll(ApiUrls.StarredGists(), request.ToParametersDictionary()); + return ApiConnection.GetAll(ApiUrls.StarredGists(), request.ToParametersDictionary(), options); } /// @@ -175,9 +268,25 @@ namespace Octokit /// The user public Task> GetAllForUser(string user) { - Ensure.ArgumentNotNull(user, "user"); + Ensure.ArgumentNotNullOrEmptyString(user, "user"); - return ApiConnection.GetAll(ApiUrls.UsersGists(user)); + return GetAllForUser(user, ApiOptions.None); + } + + /// + /// List a user's gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// The user + /// Options for changing the API response + public Task> GetAllForUser(string user, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.UsersGists(user), options); } /// @@ -190,10 +299,27 @@ namespace Octokit /// Only gists updated at or after this time are returned public Task> GetAllForUser(string user, DateTimeOffset since) { - Ensure.ArgumentNotNull(user, "user"); + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + + return GetAllForUser(user, since, ApiOptions.None); + } + + /// + /// List a user's gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// The user + /// Only gists updated at or after this time are returned + /// Options for changing the API response + public Task> GetAllForUser(string user, DateTimeOffset since, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(user, "user"); + Ensure.ArgumentNotNull(options, "options"); var request = new GistRequest(since); - return ApiConnection.GetAll(ApiUrls.UsersGists(user), request.ToParametersDictionary()); + return ApiConnection.GetAll(ApiUrls.UsersGists(user), request.ToParametersDictionary(), options); } /// @@ -207,7 +333,23 @@ namespace Octokit { Ensure.ArgumentNotNullOrEmptyString(id, "id"); - return ApiConnection.GetAll(ApiUrls.GistCommits(id)); + return GetAllCommits(id, ApiOptions.None); + } + + /// + /// List gist commits + /// + /// + /// http://developer.github.com/v3/gists/#list-gists-commits + /// + /// The id of the gist + /// Options for changing the API response + public Task> GetAllCommits(string id, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(id, "id"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.GistCommits(id), options); } /// @@ -221,7 +363,23 @@ namespace Octokit { Ensure.ArgumentNotNullOrEmptyString(id, "id"); - return ApiConnection.GetAll(ApiUrls.ForkGist(id)); + return GetAllForks(id, ApiOptions.None); + } + + /// + /// List gist forks + /// + /// + /// http://developer.github.com/v3/gists/#list-gists-forks + /// + /// The id of the gist + /// Options for changing the API response + public Task> GetAllForks(string id, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(id, "id"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.ForkGist(id), options); } /// @@ -234,7 +392,7 @@ namespace Octokit /// The update to the gist public Task Edit(string id, GistUpdate gistUpdate) { - Ensure.ArgumentNotNull(id, "id"); + Ensure.ArgumentNotNullOrEmptyString(id, "id"); Ensure.ArgumentNotNull(gistUpdate, "gistUpdate"); var filesAsJsonObject = new JsonObject(); @@ -261,6 +419,8 @@ namespace Octokit /// The id of the gist public Task Star(string id) { + Ensure.ArgumentNotNullOrEmptyString(id, "id"); + return ApiConnection.Put(ApiUrls.StarGist(id)); } @@ -273,6 +433,8 @@ namespace Octokit /// The id of the gist public Task Unstar(string id) { + Ensure.ArgumentNotNullOrEmptyString(id, "id"); + return ApiConnection.Delete(ApiUrls.StarGist(id)); } diff --git a/Octokit/Clients/IGistsClient.cs b/Octokit/Clients/IGistsClient.cs index 5ac92298..877a3ce1 100644 --- a/Octokit/Clients/IGistsClient.cs +++ b/Octokit/Clients/IGistsClient.cs @@ -35,6 +35,16 @@ namespace Octokit /// Task> GetAll(); + /// + /// List the authenticated user’s gists or if called anonymously, + /// this will return all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + Task> GetAll(ApiOptions options); + /// /// List the authenticated user’s gists or if called anonymously, /// this will return all public gists @@ -45,6 +55,17 @@ namespace Octokit /// Only gists updated at or after this time are returned Task> GetAll(DateTimeOffset since); + /// + /// List the authenticated user’s gists or if called anonymously, + /// this will return all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + Task> GetAll(DateTimeOffset since, ApiOptions options); + /// /// Lists all public gists /// @@ -53,6 +74,15 @@ namespace Octokit /// Task> GetAllPublic(); + /// + /// Lists all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + Task> GetAllPublic(ApiOptions options); + /// /// Lists all public gists /// @@ -62,6 +92,18 @@ namespace Octokit /// Only gists updated at or after this time are returned Task> GetAllPublic(DateTimeOffset since); + /// + /// Lists all public gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + Task> GetAllPublic(DateTimeOffset since, ApiOptions options); + + + /// /// List the authenticated user’s starred gists /// @@ -70,6 +112,15 @@ namespace Octokit /// Task> GetAllStarred(); + /// + /// List the authenticated user’s starred gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Options for changing the API response + Task> GetAllStarred(ApiOptions options); + /// /// List the authenticated user’s starred gists /// @@ -79,6 +130,16 @@ namespace Octokit /// Only gists updated at or after this time are returned Task> GetAllStarred(DateTimeOffset since); + /// + /// List the authenticated user’s starred gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// Only gists updated at or after this time are returned + /// Options for changing the API response + Task> GetAllStarred(DateTimeOffset since, ApiOptions options); + /// /// List a user's gists /// @@ -88,6 +149,16 @@ namespace Octokit /// The user Task> GetAllForUser(string user); + /// + /// List a user's gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// The user + /// Options for changing the API response + Task> GetAllForUser(string user, ApiOptions options); + /// /// List a user's gists /// @@ -98,6 +169,17 @@ namespace Octokit /// Only gists updated at or after this time are returned Task> GetAllForUser(string user, DateTimeOffset since); + /// + /// List a user's gists + /// + /// + /// http://developer.github.com/v3/gists/#list-gists + /// + /// The user + /// Only gists updated at or after this time are returned + /// Options for changing the API response + Task> GetAllForUser(string user, DateTimeOffset since, ApiOptions options); + /// /// List gist commits /// @@ -107,6 +189,16 @@ namespace Octokit /// The id of the gist Task> GetAllCommits(string id); + /// + /// List gist commits + /// + /// + /// http://developer.github.com/v3/gists/#list-gists-commits + /// + /// The id of the gist + /// Options for changing the API response + Task> GetAllCommits(string id, ApiOptions options); + /// /// List gist forks /// @@ -116,6 +208,16 @@ namespace Octokit /// The id of the gist Task> GetAllForks(string id); + /// + /// List gist forks + /// + /// + /// http://developer.github.com/v3/gists/#list-gists-forks + /// + /// The id of the gist + /// Options for changing the API response + Task> GetAllForks(string id, ApiOptions options); + /// /// Creates a new gist /// From 190ccf04c2ea978410d74659b1669887b24d3e88 Mon Sep 17 00:00:00 2001 From: Alexander Efremov Date: Tue, 19 Apr 2016 14:08:02 +0700 Subject: [PATCH 114/123] Add ApiOption overloads to methods on IRepositoryHooksClient (#1272) --- .../IObservableRepositoryHooksClient.cs | 12 ++ .../ObservableRepositoryHooksClient.cs | 21 +++- .../Clients/RepositoryHooksClientTests.cs | 63 +++++++++- .../Octokit.Tests.Integration.csproj | 1 + .../ObservableRepositoryHooksClientTests.cs | 115 ++++++++++++++++++ .../fixtures/RepositoriesHooksFixture.cs | 19 ++- .../Clients/RepositoryHooksClientTest.cs | 27 +++- Octokit.Tests/Octokit.Tests.csproj | 1 + .../ObservableRepositoryHooksClientTests.cs | 89 ++++++++++++++ Octokit/Clients/IRepositoryHooksClient.cs | 12 ++ Octokit/Clients/RepositoryHooksClient.cs | 21 +++- 11 files changed, 370 insertions(+), 11 deletions(-) create mode 100644 Octokit.Tests.Integration/Reactive/ObservableRepositoryHooksClientTests.cs create mode 100644 Octokit.Tests/Reactive/ObservableRepositoryHooksClientTests.cs diff --git a/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs index f3176e0a..53d2f592 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryHooksClient.cs @@ -10,9 +10,21 @@ namespace Octokit.Reactive /// Gets the list of hooks defined for a repository /// /// See API documentation for more information. + /// The repository's owner + /// The repository's name /// IObservable GetAll(string owner, string repositoryName); + /// + /// Gets the list of hooks defined for a repository + /// + /// See API documentation for more information. + /// The repository's owner + /// The repository's name + /// Options for changing the API response + /// + IObservable GetAll(string owner, string repositoryName, ApiOptions options); + /// /// Gets a single hook defined for a repository by id /// diff --git a/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs index 7b229dd2..24bca1f4 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryHooksClient.cs @@ -22,13 +22,32 @@ namespace Octokit.Reactive /// Gets the list of hooks defined for a repository /// /// See API documentation for more information. + /// The repository's owner + /// The repository's name /// public IObservable GetAll(string owner, string repositoryName) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryHooks(owner, repositoryName)); + return GetAll(owner, repositoryName, ApiOptions.None); + } + + /// + /// Gets the list of hooks defined for a repository + /// + /// See API documentation for more information. + /// The repository's owner + /// The repository's name + /// Options for changing the API response + /// + public IObservable GetAll(string owner, string repositoryName, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryHooks(owner, repositoryName), options); } /// diff --git a/Octokit.Tests.Integration/Clients/RepositoryHooksClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryHooksClientTests.cs index d0fd6c6e..35c1f68d 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryHooksClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryHooksClientTests.cs @@ -25,11 +25,70 @@ namespace Octokit.Tests.Integration.Clients var hooks = await github.Repository.Hooks.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName); - Assert.Single(hooks); - var actualHook = hooks[0]; + Assert.Equal(_fixture.ExpectedHooks.Count, hooks.Count); + var actualHook = hooks[0]; AssertHook(_fixture.ExpectedHook, actualHook); } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfHooksWithoutStart() + { + var github = Helper.GetAuthenticatedClient(); + + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var hooks = await github.Repository.Hooks.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, options); + + Assert.Equal(_fixture.ExpectedHooks.Count, hooks.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfHooksWithStart() + { + var github = Helper.GetAuthenticatedClient(); + + var options = new ApiOptions + { + PageSize = 2, + PageCount = 1, + StartPage = 3 + }; + + var hooks = await github.Repository.Hooks.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, options); + + Assert.Equal(1, hooks.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var github = Helper.GetAuthenticatedClient(); + + var startOptions = new ApiOptions + { + PageSize = 2, + PageCount = 1 + }; + + var firstPage = await github.Repository.Hooks.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, startOptions); + + var skipStartOptions = new ApiOptions + { + PageSize = 2, + PageCount = 1, + StartPage = 2 + }; + + var secondPage = await github.Repository.Hooks.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, skipStartOptions); + + Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); + Assert.NotEqual(firstPage[1].Id, secondPage[1].Id); + } } [Collection(RepositoriesHooksCollection.Name)] diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 2155cd1e..d790c35a 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -156,6 +156,7 @@ + diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositoryHooksClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryHooksClientTests.cs new file mode 100644 index 00000000..76d62db1 --- /dev/null +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryHooksClientTests.cs @@ -0,0 +1,115 @@ +using System.Reactive.Linq; +using System.Threading.Tasks; +using Octokit.Reactive; +using Octokit.Tests.Integration.fixtures; +using Xunit; + +namespace Octokit.Tests.Integration.Reactive +{ + public class ObservableRepositoryHooksClientTests + { + [Collection(RepositoriesHooksCollection.Name)] + public class TheGetAllMethod + { + readonly RepositoriesHooksFixture _fixture; + + public TheGetAllMethod(RepositoriesHooksFixture fixture) + { + _fixture = fixture; + } + + [IntegrationTest] + public async Task ReturnsAllHooksFromRepository() + { + var github = Helper.GetAuthenticatedClient(); + + var client = new ObservableRepositoryHooksClient(github); + + var hooks = await client.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName).ToList(); + + Assert.Equal(_fixture.ExpectedHooks.Count, hooks.Count); + + var actualHook = hooks[0]; + AssertHook(_fixture.ExpectedHook, actualHook); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfHooksWithoutStart() + { + var github = Helper.GetAuthenticatedClient(); + + var client = new ObservableRepositoryHooksClient(github); + + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var hooks = await client.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, options).ToList(); + + Assert.Equal(_fixture.ExpectedHooks.Count, hooks.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfHooksWithStart() + { + var github = Helper.GetAuthenticatedClient(); + + var client = new ObservableRepositoryHooksClient(github); + + var options = new ApiOptions + { + PageSize = 2, + PageCount = 1, + StartPage = 3 + }; + + var hooks = await client.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, options).ToList(); + + Assert.Equal(1, hooks.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var github = Helper.GetAuthenticatedClient(); + + var client = new ObservableRepositoryHooksClient(github); + + var startOptions = new ApiOptions + { + PageSize = 2, + PageCount = 1 + }; + + var firstPage = await client.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, startOptions).ToList(); + + var skipStartOptions = new ApiOptions + { + PageSize = 2, + PageCount = 1, + StartPage = 2 + }; + + var secondPage = await client.GetAll(_fixture.RepositoryOwner, _fixture.RepositoryName, skipStartOptions).ToList(); + + Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); + Assert.NotEqual(firstPage[1].Id, secondPage[1].Id); + } + + static void AssertHook(RepositoryHook expectedHook, RepositoryHook actualHook) + { + Assert.Equal(expectedHook.Id, actualHook.Id); + Assert.Equal(expectedHook.Active, actualHook.Active); + Assert.Equal(expectedHook.Config, actualHook.Config); + Assert.Equal(expectedHook.CreatedAt, actualHook.CreatedAt); + Assert.Equal(expectedHook.Name, actualHook.Name); + Assert.Equal(expectedHook.PingUrl, actualHook.PingUrl); + Assert.Equal(expectedHook.TestUrl, actualHook.TestUrl); + Assert.Equal(expectedHook.UpdatedAt, actualHook.UpdatedAt); + Assert.Equal(expectedHook.Url, actualHook.Url); + } + } + } +} diff --git a/Octokit.Tests.Integration/fixtures/RepositoriesHooksFixture.cs b/Octokit.Tests.Integration/fixtures/RepositoriesHooksFixture.cs index cda77a8a..09b47c1c 100644 --- a/Octokit.Tests.Integration/fixtures/RepositoriesHooksFixture.cs +++ b/Octokit.Tests.Integration/fixtures/RepositoriesHooksFixture.cs @@ -8,12 +8,21 @@ namespace Octokit.Tests.Integration.fixtures readonly IGitHubClient _github; readonly Repository _repository; readonly RepositoryHook _hook; + readonly IList _hooks; public RepositoriesHooksFixture() { _github = Helper.GetAuthenticatedClient(); _repository = CreateRepository(_github); - _hook = CreateHook(_github, _repository); + _hooks = new List(5) + { + CreateHook(_github, _repository, "awscodedeploy", "deployment"), + CreateHook(_github, _repository, "awsopsworks", "push"), + CreateHook(_github, _repository, "activecollab", "push"), + CreateHook(_github, _repository, "acunote", "push"), + CreateHook(_github, _repository, "agilebench", "push") + }; + _hook = _hooks[0]; } public string RepositoryOwner { get { return _repository.Owner.Login; } } @@ -22,6 +31,8 @@ namespace Octokit.Tests.Integration.fixtures public RepositoryHook ExpectedHook { get { return _hook; } } + public IList ExpectedHooks { get { return _hooks; } } + public void Dispose() { _github.Repository.Delete(_repository.Owner.Login, _repository.Name); @@ -35,12 +46,12 @@ namespace Octokit.Tests.Integration.fixtures return repository.Result; } - static RepositoryHook CreateHook(IGitHubClient github, Repository repository) + static RepositoryHook CreateHook(IGitHubClient github, Repository repository, string hookName, string eventName) { var config = new Dictionary { { "content_type", "json" }, { "url", "http://test.com/example" } }; - var parameters = new NewRepositoryHook("apropos", config) + var parameters = new NewRepositoryHook(hookName, config) { - Events = new[] { "commit_comment" }, + Events = new[] { eventName }, Active = false }; var createdHook = github.Repository.Hooks.Create(Helper.UserName, repository.Name, parameters); diff --git a/Octokit.Tests/Clients/RepositoryHooksClientTest.cs b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs index 9175e2aa..7a138807 100644 --- a/Octokit.Tests/Clients/RepositoryHooksClientTest.cs +++ b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs @@ -1,7 +1,7 @@ -using NSubstitute; -using System; +using System; using System.Collections.Generic; using System.Threading.Tasks; +using NSubstitute; using Xunit; namespace Octokit.Tests.Clients @@ -28,7 +28,28 @@ namespace Octokit.Tests.Clients client.Hooks.GetAll("fake", "repo"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks"), + Args.ApiOptions); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + + client.Hooks.GetAll("fake", "repo", options); + + connection.Received(1) + .GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/hooks"), + options); } [Fact] diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 0cc589e2..4d36e03a 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -220,6 +220,7 @@ + diff --git a/Octokit.Tests/Reactive/ObservableRepositoryHooksClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryHooksClientTests.cs new file mode 100644 index 00000000..f3c7961c --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableRepositoryHooksClientTests.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using NSubstitute; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableRepositoryHooksClientTests + { + public class ObservableAuthorizationsClientTests + { + const string owner = "owner"; + const string repositoryName = "name"; + + public class TheGetAllMethod + { + [Fact] + public void GetsCorrectUrl() + { + var client = Substitute.For(); + var authEndpoint = new ObservableRepositoryHooksClient(client); + var expectedUrl = string.Format("repos/{0}/{1}/hooks", owner, repositoryName); + + authEndpoint.GetAll(owner, repositoryName); + + client.Connection.Received(1).Get>(Arg.Is(u => u.ToString() == expectedUrl), + Arg.Is>(dictionary => dictionary.Count == 0), null); + } + + [Fact] + public void GetsCorrectUrlWithApiOption() + { + var gitHubClient = Substitute.For(); + var hooksClient = new ObservableRepositoryHooksClient(gitHubClient); + var expectedUrl = string.Format("repos/{0}/{1}/hooks", owner, repositoryName); + + // all properties are setted => only 2 options (StartPage, PageSize) in dictionary + var options = new ApiOptions + { + StartPage = 1, + PageCount = 1, + PageSize = 1 + }; + + hooksClient.GetAll(owner, repositoryName, options); + gitHubClient.Connection.Received(1) + .Get>(Arg.Is(u => u.ToString() == expectedUrl), + Arg.Is>(dictionary => dictionary.Count == 2), + null); + + // StartPage is setted => only 1 option (StartPage) in dictionary + options = new ApiOptions + { + StartPage = 1 + }; + + hooksClient.GetAll(owner, repositoryName, options); + gitHubClient.Connection.Received(1) + .Get>(Arg.Is(u => u.ToString() == expectedUrl), + Arg.Is>(dictionary => dictionary.Count == 1), + null); + + // PageCount is setted => none of options in dictionary + options = new ApiOptions + { + PageCount = 1 + }; + + hooksClient.GetAll(owner, repositoryName, options); + gitHubClient.Connection.Received(1) + .Get>(Arg.Is(u => u.ToString() == expectedUrl), + Arg.Is>(dictionary => dictionary.Count == 0), + null); + } + } + } + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ObservableRepositoryHooksClient(null)); + } + } + } +} \ No newline at end of file diff --git a/Octokit/Clients/IRepositoryHooksClient.cs b/Octokit/Clients/IRepositoryHooksClient.cs index c282a372..571306a4 100644 --- a/Octokit/Clients/IRepositoryHooksClient.cs +++ b/Octokit/Clients/IRepositoryHooksClient.cs @@ -10,9 +10,21 @@ namespace Octokit /// Gets the list of hooks defined for a repository /// /// See API documentation for more information. + /// The repository's owner + /// The repository's name /// Task> GetAll(string owner, string repositoryName); + /// + /// Gets the list of hooks defined for a repository + /// + /// See API documentation for more information. + /// The repository's owner + /// The repository's name + /// Options for changing the API response + /// + Task> GetAll(string owner, string repositoryName, ApiOptions options); + /// /// Gets a single hook by Id /// diff --git a/Octokit/Clients/RepositoryHooksClient.cs b/Octokit/Clients/RepositoryHooksClient.cs index 458a1596..f2e6e9df 100644 --- a/Octokit/Clients/RepositoryHooksClient.cs +++ b/Octokit/Clients/RepositoryHooksClient.cs @@ -18,13 +18,32 @@ namespace Octokit /// Gets the list of hooks defined for a repository /// /// See API documentation for more information. + /// The repository's owner + /// The repository's name /// public Task> GetAll(string owner, string repositoryName) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - return ApiConnection.GetAll(ApiUrls.RepositoryHooks(owner, repositoryName)); + return GetAll(owner, repositoryName, ApiOptions.None); + } + + /// + /// Gets the list of hooks defined for a repository + /// + /// See API documentation for more information. + /// The repository's owner + /// The repository's name + /// Options for changing the API response + /// + public Task> GetAll(string owner, string repositoryName, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.RepositoryHooks(owner, repositoryName), options); } /// From 494bbfda426531b9947e09330fa6e31f842e990c Mon Sep 17 00:00:00 2001 From: Alexander Efremov Date: Tue, 19 Apr 2016 18:02:36 +0700 Subject: [PATCH 115/123] Method of assembly determination was changed in order to use types of top level (#1273) --- Octokit.Tests.Conventions/ModelTests.cs | 4 ++-- Octokit.Tests.Conventions/PaginationTests.cs | 2 +- Octokit.Tests.Conventions/SyncObservableClients.cs | 2 +- Octokit.Tests.Conventions/TypeExtensions.cs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Octokit.Tests.Conventions/ModelTests.cs b/Octokit.Tests.Conventions/ModelTests.cs index 0cfcb3c8..1d3f5e16 100644 --- a/Octokit.Tests.Conventions/ModelTests.cs +++ b/Octokit.Tests.Conventions/ModelTests.cs @@ -97,7 +97,7 @@ namespace Octokit.Tests.Conventions public static IEnumerable GetClientInterfaces() { - return typeof(IEventsClient) + return typeof(IGitHubClient) .Assembly .ExportedTypes .Where(TypeExtensions.IsClientInterface) @@ -119,7 +119,7 @@ namespace Octokit.Tests.Conventions { var allModelTypes = new HashSet(); - var clientInterfaces = typeof(IEventsClient).Assembly.ExportedTypes + var clientInterfaces = typeof(IGitHubClient).Assembly.ExportedTypes .Where(type => type.IsClientInterface()); foreach (var exportedType in clientInterfaces) diff --git a/Octokit.Tests.Conventions/PaginationTests.cs b/Octokit.Tests.Conventions/PaginationTests.cs index 3c2565e7..2f1c3c88 100644 --- a/Octokit.Tests.Conventions/PaginationTests.cs +++ b/Octokit.Tests.Conventions/PaginationTests.cs @@ -89,7 +89,7 @@ namespace Octokit.Tests.Conventions public static IEnumerable GetClientInterfaces() { - return typeof(IEventsClient).Assembly.ExportedTypes + return typeof(IGitHubClient).Assembly.ExportedTypes .Where(TypeExtensions.IsClientInterface) .Where(type => type != typeof(IStatisticsClient)) .Select(type => new[] { type }); diff --git a/Octokit.Tests.Conventions/SyncObservableClients.cs b/Octokit.Tests.Conventions/SyncObservableClients.cs index 3d005992..02fd3981 100644 --- a/Octokit.Tests.Conventions/SyncObservableClients.cs +++ b/Octokit.Tests.Conventions/SyncObservableClients.cs @@ -120,7 +120,7 @@ namespace Octokit.Tests.Conventions public static IEnumerable GetClientInterfaces() { - return typeof(IEventsClient) + return typeof(IGitHubClient) .Assembly .ExportedTypes .Where(TypeExtensions.IsClientInterface) diff --git a/Octokit.Tests.Conventions/TypeExtensions.cs b/Octokit.Tests.Conventions/TypeExtensions.cs index 7d3ef6d3..95610c51 100644 --- a/Octokit.Tests.Conventions/TypeExtensions.cs +++ b/Octokit.Tests.Conventions/TypeExtensions.cs @@ -70,7 +70,7 @@ namespace Octokit.Tests.Conventions public static bool IsClientInterface(this Type type) { - return type.IsInterface && type.Name.EndsWith(ClientSuffix) && type.Namespace == typeof(IEventsClient).Namespace; + return type.IsInterface && type.Name.EndsWith(ClientSuffix) && type.Namespace == typeof(IGitHubClient).Namespace; } public static Type GetObservableClientInterface(this Type type) From d7d03fafa3c306e20706ee321e98c79411672a4f Mon Sep 17 00:00:00 2001 From: Alexander Efremov Date: Thu, 21 Apr 2016 13:15:26 +0700 Subject: [PATCH 116/123] Redundant parentheses were removed. (#1275) --- .../Reactive/ObservableUserAdministrationClientTests.cs | 2 +- .../Reactive/ObservableUserKeysClientTests.cs | 6 +++--- Octokit/Exceptions/ApiException.cs | 4 ++-- Octokit/Exceptions/RepositoryExistsException.cs | 2 +- Octokit/Exceptions/TwoFactorAuthorizationException.cs | 2 +- Octokit/Helpers/ModelExtensions.cs | 2 +- Octokit/Models/Request/NewArbitraryMarkDown.cs | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Octokit.Tests.Integration/Reactive/ObservableUserAdministrationClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableUserAdministrationClientTests.cs index efaea9a0..49d79d1e 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableUserAdministrationClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableUserAdministrationClientTests.cs @@ -174,7 +174,7 @@ namespace Octokit.Tests.Integration.Clients // Get public keys var observable = _github.User.Administration.ListAllPublicKeys(); - var keys = await (observable.ToList()); + var keys = await observable.ToList(); Assert.NotNull(keys); Assert.True(keys.Count > 0); diff --git a/Octokit.Tests.Integration/Reactive/ObservableUserKeysClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableUserKeysClientTests.cs index 4e48c55f..56a04f1d 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableUserKeysClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableUserKeysClientTests.cs @@ -22,7 +22,7 @@ namespace Octokit.Tests.Integration.Clients using (var context = await _github.CreatePublicKeyContext()) { var observable = _github.User.Keys.GetAllForCurrent(); - var keys = await (observable.ToList()); + var keys = await observable.ToList(); Assert.NotEmpty(keys); @@ -38,7 +38,7 @@ namespace Octokit.Tests.Integration.Clients public async Task CanGetAllForGivenUser() { var observable = _github.User.Keys.GetAll("shiftkey"); - var keys = await (observable.ToList()); + var keys = await observable.ToList(); Assert.NotEmpty(keys); @@ -80,7 +80,7 @@ namespace Octokit.Tests.Integration.Clients await _github.User.Keys.Delete(key.Id); // Verify key no longer exists - var keys = await (_github.User.Keys.GetAllForCurrent().ToList()); + var keys = await _github.User.Keys.GetAllForCurrent().ToList(); Assert.False(keys.Any(k => k.Title == keyTitle && k.Key == keyData)); } } diff --git a/Octokit/Exceptions/ApiException.cs b/Octokit/Exceptions/ApiException.cs index 9f4aff05..adee41be 100644 --- a/Octokit/Exceptions/ApiException.cs +++ b/Octokit/Exceptions/ApiException.cs @@ -154,8 +154,8 @@ namespace Octokit : base(info, context) { if (info == null) return; - StatusCode = (HttpStatusCode)(info.GetInt32("HttpStatusCode")); - ApiError = (ApiError)(info.GetValue("ApiError", typeof(ApiError))); + StatusCode = (HttpStatusCode) info.GetInt32("HttpStatusCode"); + ApiError = (ApiError) info.GetValue("ApiError", typeof(ApiError)); } public override void GetObjectData(SerializationInfo info, StreamingContext context) diff --git a/Octokit/Exceptions/RepositoryExistsException.cs b/Octokit/Exceptions/RepositoryExistsException.cs index d637d87a..c772926a 100644 --- a/Octokit/Exceptions/RepositoryExistsException.cs +++ b/Octokit/Exceptions/RepositoryExistsException.cs @@ -114,7 +114,7 @@ namespace Octokit RepositoryName = info.GetString("RepositoryName"); Organization = info.GetString("Organization"); OwnerIsOrganization = info.GetBoolean("OwnerIsOrganization"); - ExistingRepositoryWebUrl = (Uri)(info.GetValue("ExistingRepositoryWebUrl", typeof(Uri))); + ExistingRepositoryWebUrl = (Uri) info.GetValue("ExistingRepositoryWebUrl", typeof(Uri)); } public override void GetObjectData(SerializationInfo info, StreamingContext context) diff --git a/Octokit/Exceptions/TwoFactorAuthorizationException.cs b/Octokit/Exceptions/TwoFactorAuthorizationException.cs index 4279c801..db6d1a6f 100644 --- a/Octokit/Exceptions/TwoFactorAuthorizationException.cs +++ b/Octokit/Exceptions/TwoFactorAuthorizationException.cs @@ -77,7 +77,7 @@ namespace Octokit : base(info, context) { if (info == null) return; - TwoFactorType = (TwoFactorType)(info.GetInt32("TwoFactorType")); + TwoFactorType = (TwoFactorType) info.GetInt32("TwoFactorType"); } public override void GetObjectData(SerializationInfo info, StreamingContext context) diff --git a/Octokit/Helpers/ModelExtensions.cs b/Octokit/Helpers/ModelExtensions.cs index ab5cf8c0..ecf52b2b 100644 --- a/Octokit/Helpers/ModelExtensions.cs +++ b/Octokit/Helpers/ModelExtensions.cs @@ -28,7 +28,7 @@ namespace Octokit var key = sshKey.Key; if (key == null) return null; var match = sshKeyRegex.Match(key); - return (match.Success ? new SshKeyInfo(match.Groups["data"].Value, match.Groups["name"].Value) : null); + return match.Success ? new SshKeyInfo(match.Groups["data"].Value, match.Groups["name"].Value) : null; } /// diff --git a/Octokit/Models/Request/NewArbitraryMarkDown.cs b/Octokit/Models/Request/NewArbitraryMarkDown.cs index 5a4020b3..763440fb 100644 --- a/Octokit/Models/Request/NewArbitraryMarkDown.cs +++ b/Octokit/Models/Request/NewArbitraryMarkDown.cs @@ -81,7 +81,7 @@ namespace Octokit { if (mode != _markdown && mode != _gfm) { - throw (new FormatException("The mode must be either 'markdown' or 'gfm'")); + throw new FormatException("The mode must be either 'markdown' or 'gfm'"); } else return mode; From cdc708450fe289d81ae54278cdde04d84550d6eb Mon Sep 17 00:00:00 2001 From: Alexander Efremov Date: Thu, 21 Apr 2016 13:21:33 +0700 Subject: [PATCH 117/123] Modifiers declaration order was adjusted (#1276) --- .../Helpers/ObservableGithubClientExtensions.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Octokit.Tests.Integration/Helpers/ObservableGithubClientExtensions.cs b/Octokit.Tests.Integration/Helpers/ObservableGithubClientExtensions.cs index 8ef1fbbc..f455608a 100644 --- a/Octokit.Tests.Integration/Helpers/ObservableGithubClientExtensions.cs +++ b/Octokit.Tests.Integration/Helpers/ObservableGithubClientExtensions.cs @@ -6,7 +6,7 @@ namespace Octokit.Tests.Integration.Helpers { internal static class ObservableGithubClientExtensions { - internal async static Task CreateRepositoryContext(this IObservableGitHubClient client, string repositoryName) + internal static async Task CreateRepositoryContext(this IObservableGitHubClient client, string repositoryName) { var repoName = Helper.MakeNameWithTimestamp(repositoryName); var repo = await client.Repository.Create(new NewRepository(repoName) { AutoInit = true }); @@ -14,35 +14,35 @@ namespace Octokit.Tests.Integration.Helpers return new RepositoryContext(repo); } - internal async static Task CreateRepositoryContext(this IObservableGitHubClient client, string organizationLogin, NewRepository newRepository) + internal static async Task CreateRepositoryContext(this IObservableGitHubClient client, string organizationLogin, NewRepository newRepository) { var repo = await client.Repository.Create(organizationLogin, newRepository); return new RepositoryContext(repo); } - internal async static Task CreateRepositoryContext(this IObservableGitHubClient client, NewRepository newRepository) + internal static async Task CreateRepositoryContext(this IObservableGitHubClient client, NewRepository newRepository) { var repo = await client.Repository.Create(newRepository); return new RepositoryContext(repo); } - internal async static Task CreateEnterpriseTeamContext(this IObservableGitHubClient client, string organization, NewTeam newTeam) + internal static async Task CreateEnterpriseTeamContext(this IObservableGitHubClient client, string organization, NewTeam newTeam) { var team = await client.Organization.Team.Create(organization, newTeam); return new EnterpriseTeamContext(team); } - internal async static Task CreateEnterpriseUserContext(this IObservableGitHubClient client, NewUser newUser) + internal static async Task CreateEnterpriseUserContext(this IObservableGitHubClient client, NewUser newUser) { var user = await client.User.Administration.Create(newUser); return new EnterpriseUserContext(user); } - internal async static Task CreatePublicKeyContext(this IObservableGitHubClient client) + internal static async Task CreatePublicKeyContext(this IObservableGitHubClient client) { // Create a key string keyTitle = "title"; From db839f58d458d6bda1f41cbc5f0aae59bfd9633c Mon Sep 17 00:00:00 2001 From: Alexander Efremov Date: Thu, 21 Apr 2016 13:23:42 +0700 Subject: [PATCH 118/123] Redundant braces of argument list were removed (#1277) --- Octokit.Tests.Integration/Clients/BranchesClientTests.cs | 8 ++++---- .../Clients/RepositoryDeployKeysClientTests.cs | 8 ++++---- .../Reactive/ObservableRepositoryDeployKeysClientTests.cs | 8 ++++---- Octokit.Tests/Clients/GistsClientTests.cs | 2 +- Octokit.Tests/Clients/IssueCommentsClientTests.cs | 2 +- Octokit.Tests/Clients/RepositoryHooksClientTest.cs | 2 +- Octokit.Tests/Http/RedirectHandlerTests.cs | 2 +- Octokit.Tests/Models/RequestParametersTests.cs | 2 +- Octokit.Tests/Reactive/ObservableGistsTests.cs | 8 ++++---- .../Reactive/ObservableIssueCommentsClientTests.cs | 4 ++-- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/BranchesClientTests.cs b/Octokit.Tests.Integration/Clients/BranchesClientTests.cs index 70217181..f661518f 100644 --- a/Octokit.Tests.Integration/Clients/BranchesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/BranchesClientTests.cs @@ -40,7 +40,7 @@ public class BranchesClientTests public async Task CreateTheWorld() { // Set master branch to be protected, with some status checks - var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List() { "check1", "check2" }); + var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List { "check1", "check2" }); var update = new BranchUpdate(); update.Protection = new BranchProtection(true, requiredStatusChecks); @@ -52,7 +52,7 @@ public class BranchesClientTests public async Task ProtectsBranch() { // Set master branch to be protected, with some status checks - var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List() { "check1", "check2", "check3" }); + var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List { "check1", "check2", "check3" }); var update = new BranchUpdate(); update.Protection = new BranchProtection(true, requiredStatusChecks); @@ -77,7 +77,7 @@ public class BranchesClientTests await CreateTheWorld(); // Remove status check enforcement - var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Off, new List() { "check1" }); + var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Off, new List { "check1" }); var update = new BranchUpdate(); update.Protection = new BranchProtection(true, requiredStatusChecks); @@ -103,7 +103,7 @@ public class BranchesClientTests // Unprotect branch // Deliberately set Enforcement and Contexts to some values (these should be ignored) - var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List() { "check1" }); + var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List { "check1" }); var update = new BranchUpdate(); update.Protection = new BranchProtection(false, requiredStatusChecks); diff --git a/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs index 998770f5..78487674 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryDeployKeysClientTests.cs @@ -24,7 +24,7 @@ public class RepositoryDeployKeysClientTests : IDisposable [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for investigating this failing test")] public async Task CanCreateADeployKey() { - var deployKey = new NewDeployKey() + var deployKey = new NewDeployKey { Key = _key, Title = _keyTitle @@ -42,7 +42,7 @@ public class RepositoryDeployKeysClientTests : IDisposable var deployKeys = await _fixture.GetAll(_context.RepositoryOwner, _context.RepositoryName); Assert.Equal(0, deployKeys.Count); - var deployKey = new NewDeployKey() + var deployKey = new NewDeployKey { Key = _key, Title = _keyTitle @@ -59,7 +59,7 @@ public class RepositoryDeployKeysClientTests : IDisposable [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for the resolution to this failing test")] public async Task CanRetrieveADeployKey() { - var newDeployKey = new NewDeployKey() + var newDeployKey = new NewDeployKey { Key = _key, Title = _keyTitle @@ -76,7 +76,7 @@ public class RepositoryDeployKeysClientTests : IDisposable [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for the resolution to this failing test")] public async Task CanRemoveADeployKey() { - var newDeployKey = new NewDeployKey() + var newDeployKey = new NewDeployKey { Key = _key, Title = _keyTitle diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositoryDeployKeysClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryDeployKeysClientTests.cs index 19fe4a83..41b14256 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableRepositoryDeployKeysClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryDeployKeysClientTests.cs @@ -28,7 +28,7 @@ public class ObservableRespositoryDeployKeysClientTests : IDisposable [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for investigating this failing test")] public async Task CanCreateADeployKey() { - var deployKey = new NewDeployKey() + var deployKey = new NewDeployKey { Key = _key, Title = _keyTitle @@ -48,7 +48,7 @@ public class ObservableRespositoryDeployKeysClientTests : IDisposable var deployKeys = await _client.GetAll(_owner, _repository.Name).ToList(); Assert.Empty(deployKeys); - var deployKey = new NewDeployKey() + var deployKey = new NewDeployKey { Key = _key, Title = _keyTitle @@ -64,7 +64,7 @@ public class ObservableRespositoryDeployKeysClientTests : IDisposable [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for investigating this failing test")] public async Task CanRetrieveADeployKey() { - var newDeployKey = new NewDeployKey() + var newDeployKey = new NewDeployKey { Key = _key, Title = _keyTitle @@ -82,7 +82,7 @@ public class ObservableRespositoryDeployKeysClientTests : IDisposable [IntegrationTest(Skip = "see https://github.com/octokit/octokit.net/issues/533 for investigating this failing test")] public async Task CanRemoveADeployKey() { - var newDeployKey = new NewDeployKey() + var newDeployKey = new NewDeployKey { Key = _key, Title = _keyTitle diff --git a/Octokit.Tests/Clients/GistsClientTests.cs b/Octokit.Tests/Clients/GistsClientTests.cs index 8934f52e..6e9dcb91 100644 --- a/Octokit.Tests/Clients/GistsClientTests.cs +++ b/Octokit.Tests/Clients/GistsClientTests.cs @@ -370,7 +370,7 @@ public class GistsClientTests var connection = Substitute.For(); var client = new GistsClient(connection); - var options = new ApiOptions() + var options = new ApiOptions { PageSize = 1, PageCount = 1, diff --git a/Octokit.Tests/Clients/IssueCommentsClientTests.cs b/Octokit.Tests/Clients/IssueCommentsClientTests.cs index dcae0577..3f4578ed 100644 --- a/Octokit.Tests/Clients/IssueCommentsClientTests.cs +++ b/Octokit.Tests/Clients/IssueCommentsClientTests.cs @@ -54,7 +54,7 @@ namespace Octokit.Tests.Clients var connection = Substitute.For(); var client = new IssueCommentsClient(connection); - var options = new ApiOptions() + var options = new ApiOptions { PageCount = 1, PageSize = 1, diff --git a/Octokit.Tests/Clients/RepositoryHooksClientTest.cs b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs index 7a138807..5b750bed 100644 --- a/Octokit.Tests/Clients/RepositoryHooksClientTest.cs +++ b/Octokit.Tests/Clients/RepositoryHooksClientTest.cs @@ -152,7 +152,7 @@ namespace Octokit.Tests.Clients { var connection = Substitute.For(); var client = new RepositoriesClient(connection); - var editRepositoryHook = new EditRepositoryHook() { Active = false }; + var editRepositoryHook = new EditRepositoryHook { Active = false }; client.Hooks.Edit("owner", "repo", 12345678, editRepositoryHook); diff --git a/Octokit.Tests/Http/RedirectHandlerTests.cs b/Octokit.Tests/Http/RedirectHandlerTests.cs index 14e46e96..0d68b0ff 100644 --- a/Octokit.Tests/Http/RedirectHandlerTests.cs +++ b/Octokit.Tests/Http/RedirectHandlerTests.cs @@ -165,7 +165,7 @@ namespace Octokit.Tests.Http static HttpMessageInvoker CreateInvoker(HttpResponseMessage httpResponseMessage1, HttpResponseMessage httpResponseMessage2 = null) { - var redirectHandler = new RedirectHandler() + var redirectHandler = new RedirectHandler { InnerHandler = new MockRedirectHandler(httpResponseMessage1, httpResponseMessage2) }; diff --git a/Octokit.Tests/Models/RequestParametersTests.cs b/Octokit.Tests/Models/RequestParametersTests.cs index 187e8806..e62be643 100644 --- a/Octokit.Tests/Models/RequestParametersTests.cs +++ b/Octokit.Tests/Models/RequestParametersTests.cs @@ -116,7 +116,7 @@ namespace Octokit.Tests.Models [Fact] public void UsesParameterAttributeForKey() { - var model = new WithPropertyNameDifferentFromKey() { LongPropertyName = "verbose" }; + var model = new WithPropertyNameDifferentFromKey { LongPropertyName = "verbose" }; var result = model.ToParametersDictionary(); diff --git a/Octokit.Tests/Reactive/ObservableGistsTests.cs b/Octokit.Tests/Reactive/ObservableGistsTests.cs index 7a8280d8..6f7e7348 100644 --- a/Octokit.Tests/Reactive/ObservableGistsTests.cs +++ b/Octokit.Tests/Reactive/ObservableGistsTests.cs @@ -81,7 +81,7 @@ namespace Octokit.Tests.Reactive var gitHubClient = Substitute.For(); var client = new ObservableGistsClient(gitHubClient); - var options = new ApiOptions() + var options = new ApiOptions { PageCount = 1, PageSize = 1, @@ -153,7 +153,7 @@ namespace Octokit.Tests.Reactive var gitHubClient = Substitute.For(); var client = new ObservableGistsClient(gitHubClient); - var options = new ApiOptions() + var options = new ApiOptions { PageCount = 1, PageSize = 1, @@ -225,7 +225,7 @@ namespace Octokit.Tests.Reactive var gitHubClient = Substitute.For(); var client = new ObservableGistsClient(gitHubClient); - var options = new ApiOptions() + var options = new ApiOptions { PageCount = 1, PageSize = 1, @@ -298,7 +298,7 @@ namespace Octokit.Tests.Reactive var gitHubClient = Substitute.For(); var client = new ObservableGistsClient(gitHubClient); - var options = new ApiOptions() + var options = new ApiOptions { PageCount = 1, PageSize = 1, diff --git a/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs b/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs index 2992c74a..7efeb88a 100644 --- a/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs @@ -55,7 +55,7 @@ namespace Octokit.Tests.Reactive var gitHubClient = Substitute.For(); var client = new ObservableIssueCommentsClient(gitHubClient); - var options=new ApiOptions() + var options=new ApiOptions { StartPage = 1, PageSize = 1, @@ -103,7 +103,7 @@ namespace Octokit.Tests.Reactive var gitHubClient = Substitute.For(); var client = new ObservableIssueCommentsClient(gitHubClient); - var options=new ApiOptions() + var options=new ApiOptions { StartPage = 1, PageSize = 1, From 9b289195c1e1e6adca84fd9843b57d24f76c9256 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Fri, 22 Apr 2016 17:27:35 +0700 Subject: [PATCH 119/123] redundant @ prefix was removed --- Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs b/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs index 12a4ebf8..2cc9c479 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryCommitsClients.cs @@ -14,7 +14,7 @@ namespace Octokit.Reactive /// The reference to use as the head commit /// [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "base")] - IObservable Compare(string owner, string name, string @base, string @head); + IObservable Compare(string owner, string name, string @base, string head); /// /// Gets all commits for a given repository From 39ef6e069adba9689dc5a3f59a4aa1d928c2da4b Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Fri, 22 Apr 2016 17:28:52 +0700 Subject: [PATCH 120/123] redundant explicit array type specifications were removed --- .../Clients/UserAdministrationClientTests.cs | 2 +- .../Reactive/ObservableUserAdministrationClientTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/UserAdministrationClientTests.cs b/Octokit.Tests.Integration/Clients/UserAdministrationClientTests.cs index b9c049ab..0a68edd2 100644 --- a/Octokit.Tests.Integration/Clients/UserAdministrationClientTests.cs +++ b/Octokit.Tests.Integration/Clients/UserAdministrationClientTests.cs @@ -91,7 +91,7 @@ namespace Octokit.Tests.Integration.Clients // Create Impersonation token var token = await _github.User.Administration.CreateImpersonationToken( context.UserLogin, - new NewImpersonationToken(new string[] { "public_repo" })); + new NewImpersonationToken(new[] { "public_repo" })); Assert.NotNull(token); Assert.True( diff --git a/Octokit.Tests.Integration/Reactive/ObservableUserAdministrationClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableUserAdministrationClientTests.cs index 49d79d1e..ad15c402 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableUserAdministrationClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableUserAdministrationClientTests.cs @@ -94,7 +94,7 @@ namespace Octokit.Tests.Integration.Clients // Create Impersonation token var observable = _github.User.Administration.CreateImpersonationToken( context.UserLogin, - new NewImpersonationToken(new string[] { "public_repo" })); + new NewImpersonationToken(new[] { "public_repo" })); var token = await observable; Assert.NotNull(token); From f7fe51a8480a03d27b3f78112a2b142ca9929ac5 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Fri, 22 Apr 2016 17:29:41 +0700 Subject: [PATCH 121/123] redundant argument list was removed --- Octokit.Tests/Clients/GistsClientTests.cs | 2 +- Octokit.Tests/Clients/IssueCommentsClientTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests/Clients/GistsClientTests.cs b/Octokit.Tests/Clients/GistsClientTests.cs index 6e9dcb91..536d7619 100644 --- a/Octokit.Tests/Clients/GistsClientTests.cs +++ b/Octokit.Tests/Clients/GistsClientTests.cs @@ -414,7 +414,7 @@ public class GistsClientTests var connection = Substitute.For(); var client = new GistsClient(connection); - var options = new ApiOptions() + var options = new ApiOptions { PageSize = 1, PageCount = 1, diff --git a/Octokit.Tests/Clients/IssueCommentsClientTests.cs b/Octokit.Tests/Clients/IssueCommentsClientTests.cs index 3f4578ed..7584eeb9 100644 --- a/Octokit.Tests/Clients/IssueCommentsClientTests.cs +++ b/Octokit.Tests/Clients/IssueCommentsClientTests.cs @@ -100,7 +100,7 @@ namespace Octokit.Tests.Clients var connection = Substitute.For(); var client = new IssueCommentsClient(connection); - var options = new ApiOptions() + var options = new ApiOptions { StartPage = 1, PageSize = 1, From f1896888c664e1f48aa64b07a117189cee677c11 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Fri, 22 Apr 2016 17:30:37 +0700 Subject: [PATCH 122/123] Redundant commas in object initializer were removed. --- Octokit.Tests.Integration/Clients/IssuesClientTests.cs | 6 +++--- .../Clients/PullRequestReviewCommentsClientTests.cs | 4 ++-- .../Clients/RepositoryCommitsClientTests.cs | 2 +- .../Reactive/ObservableRepositoryCommitsClientTests.cs | 2 +- Octokit.Tests/Http/ApiInfoTests.cs | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs index f8ef4495..b8ae2d64 100644 --- a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs @@ -297,7 +297,7 @@ public class IssuesClientTests : IDisposable var newIssue = new NewIssue("A test issue1") { - Body = "A new unassigned issue", + Body = "A new unassigned issue" }; newIssue.Labels.Add("something"); @@ -320,7 +320,7 @@ public class IssuesClientTests : IDisposable // setup us the issue var newIssue = new NewIssue("A test issue1") { - Body = "A new unassigned issue", + Body = "A new unassigned issue" }; newIssue.Labels.Add("something"); @@ -345,7 +345,7 @@ public class IssuesClientTests : IDisposable // setup us the issue var newIssue = new NewIssue("A test issue1") { - Body = "A new unassigned issue", + Body = "A new unassigned issue" }; newIssue.Labels.Add("something"); newIssue.Labels.Add("another thing"); diff --git a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs index f1af40d1..92d38d2f 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentsClientTests.cs @@ -249,7 +249,7 @@ public class PullRequestReviewCommentsClientTests : IDisposable var data = new PullRequestData { Sha = createdCommitInBranch.Sha, - Number = createdPullRequest.Number, + Number = createdPullRequest.Number }; return data; @@ -273,7 +273,7 @@ public class PullRequestReviewCommentsClientTests : IDisposable Type = TreeType.Blob, Mode = FileMode.File, Path = treePath, - Sha = createdBlob.Sha, + Sha = createdBlob.Sha }); var createdTree = await _github.Git.Tree.Create(Helper.UserName, repoName, newTree); diff --git a/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs index c0bf59bc..d6f61a20 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommitsClientTests.cs @@ -82,7 +82,7 @@ public class RepositoryCommitsClientTests var startOptions = new ApiOptions { PageSize = 5, - PageCount = 1, + PageCount = 1 }; var skipStartOptions = new ApiOptions diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositoryCommitsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryCommitsClientTests.cs index 63995c8c..48b6a75f 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableRepositoryCommitsClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryCommitsClientTests.cs @@ -51,7 +51,7 @@ namespace Octokit.Tests.Integration.Reactive var startOptions = new ApiOptions { PageSize = 5, - PageCount = 1, + PageCount = 1 }; var skipStartOptions = new ApiOptions diff --git a/Octokit.Tests/Http/ApiInfoTests.cs b/Octokit.Tests/Http/ApiInfoTests.cs index d9c213c7..8b713ca3 100644 --- a/Octokit.Tests/Http/ApiInfoTests.cs +++ b/Octokit.Tests/Http/ApiInfoTests.cs @@ -36,7 +36,7 @@ namespace Octokit.Tests.Http }, new List { - "user", + "user" }, new List { From eb5687d721fe4003aadffb98a5c930ebf569bb74 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Fri, 22 Apr 2016 17:40:22 +0700 Subject: [PATCH 123/123] Incosistent modifiers declaration order was fixed. Unused usings were removed in GithubClientExtensions.cs --- .../Helpers/GithubClientExtensions.cs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs b/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs index 95de0794..8f982e43 100644 --- a/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs +++ b/Octokit.Tests.Integration/Helpers/GithubClientExtensions.cs @@ -1,14 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Threading.Tasks; namespace Octokit.Tests.Integration.Helpers { internal static class GithubClientExtensions { - internal async static Task CreateRepositoryContext(this IGitHubClient client, string repositoryName) + internal static async Task CreateRepositoryContext(this IGitHubClient client, string repositoryName) { var repoName = Helper.MakeNameWithTimestamp(repositoryName); var repo = await client.Repository.Create(new NewRepository(repoName) { AutoInit = true }); @@ -16,35 +12,35 @@ namespace Octokit.Tests.Integration.Helpers return new RepositoryContext(repo); } - internal async static Task CreateRepositoryContext(this IGitHubClient client, string organizationLogin, NewRepository newRepository) + internal static async Task CreateRepositoryContext(this IGitHubClient client, string organizationLogin, NewRepository newRepository) { var repo = await client.Repository.Create(organizationLogin, newRepository); return new RepositoryContext(repo); } - internal async static Task CreateRepositoryContext(this IGitHubClient client, NewRepository newRepository) + internal static async Task CreateRepositoryContext(this IGitHubClient client, NewRepository newRepository) { var repo = await client.Repository.Create(newRepository); return new RepositoryContext(repo); } - internal async static Task CreateEnterpriseTeamContext(this IGitHubClient client, string organization, NewTeam newTeam) + internal static async Task CreateEnterpriseTeamContext(this IGitHubClient client, string organization, NewTeam newTeam) { var team = await client.Organization.Team.Create(organization, newTeam); return new EnterpriseTeamContext(team); } - internal async static Task CreateEnterpriseUserContext(this IGitHubClient client, NewUser newUser) + internal static async Task CreateEnterpriseUserContext(this IGitHubClient client, NewUser newUser) { var user = await client.User.Administration.Create(newUser); return new EnterpriseUserContext(user); } - internal async static Task CreatePublicKeyContext(this IGitHubClient client) + internal static async Task CreatePublicKeyContext(this IGitHubClient client) { // Create a key string keyTitle = "title";