From 7c993503c7855d77a47c644d1bacb5ac72157383 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 25 May 2016 12:11:46 +0200 Subject: [PATCH 01/65] add new method for reaction in RepositoryCommentsClient.cs --- Octokit/Clients/IRepositoryCommentsClient.cs | 11 +++++++++++ Octokit/Clients/RepositoryCommentsClient.cs | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/Octokit/Clients/IRepositoryCommentsClient.cs b/Octokit/Clients/IRepositoryCommentsClient.cs index f378dafe88..a6bbcdbb83 100644 --- a/Octokit/Clients/IRepositoryCommentsClient.cs +++ b/Octokit/Clients/IRepositoryCommentsClient.cs @@ -95,5 +95,16 @@ public interface IRepositoryCommentsClient /// The comment id /// Task Delete(string owner, string name, int number); + + /// + /// Creates a reaction for specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction for + /// + Task CreateReaction(string owner, string name, int number, NewCommitCommentReaction reaction); } } diff --git a/Octokit/Clients/RepositoryCommentsClient.cs b/Octokit/Clients/RepositoryCommentsClient.cs index 2935c26767..6a24a713cb 100644 --- a/Octokit/Clients/RepositoryCommentsClient.cs +++ b/Octokit/Clients/RepositoryCommentsClient.cs @@ -156,5 +156,22 @@ public Task Delete(string owner, string name, int number) return ApiConnection.Delete(ApiUrls.CommitComment(owner, name, number)); } + + /// + /// Creates a reaction for specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction for + /// + public Task CreateReaction(string owner, string name, int number, NewCommitCommentReaction reaction) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return ApiConnection.Post(ApiUrls.CommitCommentReaction(owner, name, number), reaction, AcceptHeaders.Reactions); + } } } From 3d39207723853de6e2a22abd6d48fe36e8e70d1f Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 25 May 2016 12:14:34 +0200 Subject: [PATCH 02/65] add request and response for commit comment reactions --- .../Request/NewCommitCommentReaction.cs | 50 +++++++++++++++ .../Models/Response/CommitCommentReaction.cs | 61 +++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 Octokit/Models/Request/NewCommitCommentReaction.cs create mode 100644 Octokit/Models/Response/CommitCommentReaction.cs diff --git a/Octokit/Models/Request/NewCommitCommentReaction.cs b/Octokit/Models/Request/NewCommitCommentReaction.cs new file mode 100644 index 0000000000..20bcc55647 --- /dev/null +++ b/Octokit/Models/Request/NewCommitCommentReaction.cs @@ -0,0 +1,50 @@ +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class NewCommitCommentReaction + { + /// + /// Initializes a new instance of the class. + /// + /// The reaction type. + public NewCommitCommentReaction(Reaction content) + { + switch (content){ + case Reaction.Plus1: + Content = Reaction.Plus1; + break; + case Reaction.Minus1: + Content = Reaction.Minus1; + break; + case Reaction.Laugh: + Content = Reaction.Laugh; + break; + case Reaction.Hooray: + Content = Reaction.Hooray; + break; + case Reaction.Heart: + Content = Reaction.Heart; + break; + case Reaction.Confused: + Content = Reaction.Confused; + break; + } + } + + /// + /// The reaction type (required) + /// + public Reaction Content { get; private set; } + + internal string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, "Content: {0}", Content); + } + } + } +} diff --git a/Octokit/Models/Response/CommitCommentReaction.cs b/Octokit/Models/Response/CommitCommentReaction.cs new file mode 100644 index 0000000000..6def0a9995 --- /dev/null +++ b/Octokit/Models/Response/CommitCommentReaction.cs @@ -0,0 +1,61 @@ +using Octokit.Internal; +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + public enum Reaction + { + [Parameter(Value = "plus_one")] + Plus1 = 0, + [Parameter(Value = "minus_one")] + Minus1 = 1, + [Parameter(Value = "laugh")] + Laugh = 2, + [Parameter(Value = "confused")] + Confused = 3, + [Parameter(Value = "heart")] + Heart = 4, + [Parameter(Value = "hooray")] + Hooray = 5 + } + + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class CommitCommentReaction + { + public CommitCommentReaction() { } + + public CommitCommentReaction(int id, int userId, Reaction content) + { + Id = id; + UserId = userId; + Content = content; + } + + /// + /// The Id for this reaction. + /// + public int Id { get; protected set; } + + /// + /// The UserId. + /// + public int UserId { get; protected set; } + + /// + /// The reaction type for this commit comment. + /// + [Parameter(Key = "content")] + public Reaction Content { get; protected set; } + + internal string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, "Id: {0}, Reaction: {1}", Id, Content); + } + } + } +} + From d90bfdbd0e61b64114d163bbf92e002da9e95e65 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 25 May 2016 12:18:26 +0200 Subject: [PATCH 03/65] add accept headers for reactions --- Octokit/Helpers/AcceptHeaders.cs | 2 ++ Octokit/Octokit.csproj | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Octokit/Helpers/AcceptHeaders.cs b/Octokit/Helpers/AcceptHeaders.cs index 3d448fb77d..0fc22b8a12 100644 --- a/Octokit/Helpers/AcceptHeaders.cs +++ b/Octokit/Helpers/AcceptHeaders.cs @@ -21,5 +21,7 @@ public static class AcceptHeaders public const string SquashCommitPreview = "application/vnd.github.polaris-preview+json"; public const string MigrationsApiPreview = " application/vnd.github.wyandotte-preview+json"; + + public const string Reactions = "application/vnd.github.squirrel-girl-preview"; } } diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 2f5bac2953..6b59c10892 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -120,6 +120,7 @@ + @@ -156,6 +157,7 @@ + From 9f98916bf401c92a962e26ddda3fdfa2d91c450c Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 25 May 2016 12:21:44 +0200 Subject: [PATCH 04/65] add reaction for observable repository comment client --- .../IObservableRepositoryCommentsClient.cs | 11 +++++++++++ .../ObservableRepositoryCommentsClient.cs | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs index 1a8ed9b9a5..126de0d6bd 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs @@ -89,5 +89,16 @@ public interface IObservableRepositoryCommentsClient /// The comment id /// IObservable Delete(string owner, string name, int number); + + /// + /// Creates a reaction for specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction for + /// + IObservable CreateReaction(string owner, string name, int number, NewCommitCommentReaction reaction); } } diff --git a/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs index 3826850fd5..2f8e74d4bb 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs @@ -154,5 +154,22 @@ public IObservable Delete(string owner, string name, int number) return _client.Delete(owner, name, number).ToObservable(); } + + /// + /// Creates a reaction for specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction for + /// + public IObservable CreateReaction(string owner, string name, int number, NewCommitCommentReaction reaction) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return _client.CreateReaction(owner, name, number, reaction).ToObservable(); + } } } From 7c894cd3823da1b57c07bc4c42b130b4d3903356 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 25 May 2016 12:25:47 +0200 Subject: [PATCH 05/65] add unit test for commit comment reaction --- .../Clients/RepositoryCommentsClientTests.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs index 2628f0601b..d82944ed2d 100644 --- a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs @@ -240,6 +240,34 @@ public async Task EnsuresArgumentsNotNullOrEmpty() } } + public class TheReactionMethod + { + [Fact] + public void RequestsCorrectUrl() + { + NewCommitCommentReaction newCommitCommentReaction = new NewCommitCommentReaction(Reaction.Heart); + + var connection = Substitute.For(); + var client = new RepositoryCommentsClient(connection); + + client.CreateReaction("fake", "repo", 1, newCommitCommentReaction); + + connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), Arg.Any(), AcceptHeaders.Reactions); + } + + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var connection = Substitute.For(); + var client = new RepositoryCommentsClient(connection); + + await Assert.ThrowsAsync(() => client.CreateReaction(null, "name", 1, new NewCommitCommentReaction(Reaction.Heart))); + await Assert.ThrowsAsync(() => client.CreateReaction("", "name", 1, new NewCommitCommentReaction(Reaction.Heart))); + await Assert.ThrowsAsync(() => client.CreateReaction("owner", null, 1, new NewCommitCommentReaction(Reaction.Heart))); + await Assert.ThrowsAsync(() => client.CreateReaction("owner", "", 1, new NewCommitCommentReaction(Reaction.Heart))); + } + } + public class TheCtor { [Fact] From 93ab528ebaff332c5b902ae900f796a8499328aa Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 25 May 2016 13:50:54 +0200 Subject: [PATCH 06/65] add unit test for observable repository comment reaction --- ...ObservableRepositoryCommentsClientTests.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs index 20f8161d3b..76b27f8508 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs @@ -133,5 +133,30 @@ public void EnsuresArgumentsNotNull() Assert.Throws(() => client.GetAllForCommit("", "name", "sha1", Args.ApiOptions)); } } + public class TheReactionMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var githubClient = Substitute.For(); + var client = new ObservableRepositoryCommentsClient(githubClient); + var newCommitCommentReaction = new NewCommitCommentReaction(Reaction.Confused); + + client.CreateReaction("fake", "repo", 1, newCommitCommentReaction); + githubClient.Received().Repository.Comment.CreateReaction("fake", "repo", 1, newCommitCommentReaction); + } + + [Fact] + public void EnsuresArgumentsNotNull() + { + var githubClient = Substitute.For(); + var client = new ObservableRepositoryCommentsClient(githubClient); + + Assert.Throws(() => client.CreateReaction(null, "name", 1, new NewCommitCommentReaction(Reaction.Heart))); + Assert.Throws(() => client.CreateReaction("", "name", 1, new NewCommitCommentReaction(Reaction.Heart))); + Assert.Throws(() => client.CreateReaction("owner", null, 1, new NewCommitCommentReaction(Reaction.Heart))); + Assert.Throws(() => client.CreateReaction("owner", "", 1, new NewCommitCommentReaction(Reaction.Heart))); + } + } } } From b30fadec3e32c393b8004b07e72099a880e307ff Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 25 May 2016 13:54:58 +0200 Subject: [PATCH 07/65] add integration test for repository comment reaction --- .../Clients/RepositoryCommentsClientTests.cs | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs index 5cb9f49d66..4da237d022 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs @@ -367,4 +367,62 @@ public void Dispose() _context.Dispose(); } } + public class TheReactionMethod : IDisposable + { + private readonly IGitHubClient _github; + private readonly RepositoryContext _context; + + public TheReactionMethod() + { + _github = Helper.GetAuthenticatedClient(); + + _context = _github.CreateRepositoryContext("public-repo").Result; + } + private async Task SetupCommitForRepository(IGitHubClient client) + { + var blob = new NewBlob + { + Content = "Hello World!", + Encoding = EncodingType.Utf8 + }; + var blobResult = await client.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob); + + var newTree = new NewTree(); + newTree.Tree.Add(new NewTreeItem + { + Type = TreeType.Blob, + Mode = FileMode.File, + Path = "README.md", + Sha = blobResult.Sha + }); + + var treeResult = await client.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree); + + var newCommit = new NewCommit("test-commit", treeResult.Sha); + + return await client.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit); + } + + [IntegrationTest] + public async Task CanCreateReaction() + { + var commit = await SetupCommitForRepository(_github); + + var comment = new NewCommitComment("test"); + + var result = await _github.Repository.Comment.Create(_context.RepositoryOwner, _context.RepositoryName, + commit.Sha, comment); + + Assert.NotNull(result); + + var newCommitCommentReaction = new NewCommitCommentReaction(Reaction.Confused); + var reaction = await _github.Repository.Comment.CreateReaction(_context.RepositoryOwner, _context.RepositoryName, result.Id, newCommitCommentReaction); + + Assert.IsType(reaction); + } + public void Dispose() + { + _context.Dispose(); + } + } } From 1e7fa47c2a29c0105f1a365fd3e6a431090b2f14 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 25 May 2016 13:55:57 +0200 Subject: [PATCH 08/65] fix .csproj files --- Octokit/Octokit-Mono.csproj | 2 ++ Octokit/Octokit-MonoAndroid.csproj | 2 ++ Octokit/Octokit-Monotouch.csproj | 2 ++ Octokit/Octokit-Portable.csproj | 2 ++ Octokit/Octokit-netcore45.csproj | 2 ++ 5 files changed, 10 insertions(+) diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index 2370eca2ce..a5edbe2004 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -466,6 +466,8 @@ + + \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index f7fadcd7f4..2bdf311f83 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -477,6 +477,8 @@ + + \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index d99d397908..4034868cdf 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -473,6 +473,8 @@ + + diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj index 4c2c15744b..fe318eabe8 100644 --- a/Octokit/Octokit-Portable.csproj +++ b/Octokit/Octokit-Portable.csproj @@ -463,6 +463,8 @@ + + diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index 841d4088a1..358b1d74a1 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -470,6 +470,8 @@ + + From 1a2396b0fbaa802ebf53118a37be187795137105 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 25 May 2016 14:00:25 +0200 Subject: [PATCH 09/65] add apiurl for commit comment reaction --- Octokit/Helpers/ApiUrls.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index c6af35f219..20d730aede 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -386,6 +386,18 @@ public static Uri CommitComments(string owner, string name) return "repos/{0}/{1}/comments".FormatUri(owner, name); } + /// + /// Returns the for the reaction of a specified commit comment. + /// + /// The owner of the repository + /// The name of the repository + /// The comment number + /// + public static Uri CommitCommentReaction(string owner, string name, int number) + { + return "repos/{0}/{1}/comments/{2}/reactions".FormatUri(owner, name, number); + } + /// /// Returns the that returns all of the assignees to which issues may be assigned. /// From 963b979c8036e27f12efe4566950ee116eae594f Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 25 May 2016 14:36:20 +0200 Subject: [PATCH 10/65] change content of newCommitCommentReaction --- .../Request/NewCommitCommentReaction.cs | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/Octokit/Models/Request/NewCommitCommentReaction.cs b/Octokit/Models/Request/NewCommitCommentReaction.cs index 20bcc55647..95b5cdf6a9 100644 --- a/Octokit/Models/Request/NewCommitCommentReaction.cs +++ b/Octokit/Models/Request/NewCommitCommentReaction.cs @@ -12,26 +12,7 @@ public class NewCommitCommentReaction /// The reaction type. public NewCommitCommentReaction(Reaction content) { - switch (content){ - case Reaction.Plus1: - Content = Reaction.Plus1; - break; - case Reaction.Minus1: - Content = Reaction.Minus1; - break; - case Reaction.Laugh: - Content = Reaction.Laugh; - break; - case Reaction.Hooray: - Content = Reaction.Hooray; - break; - case Reaction.Heart: - Content = Reaction.Heart; - break; - case Reaction.Confused: - Content = Reaction.Confused; - break; - } + Content = content; } /// From aac9d69c3b841947e153fea94df6af3def8baaa8 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 25 May 2016 14:39:15 +0200 Subject: [PATCH 11/65] hardcoded accept header in repository comments client test --- Octokit.Tests/Clients/RepositoryCommentsClientTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs index d82944ed2d..dced43edea 100644 --- a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs @@ -252,7 +252,7 @@ public void RequestsCorrectUrl() client.CreateReaction("fake", "repo", 1, newCommitCommentReaction); - connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), Arg.Any(), AcceptHeaders.Reactions); + connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), Arg.Any(), "application/vnd.github.squirrel-girl-preview"); } [Fact] From 29b6fd381725c567d7845912e148a45e1c2511da Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Thu, 26 May 2016 15:09:19 +0200 Subject: [PATCH 12/65] fix some suggestions --- .../Clients/IObservableRepositoryCommentsClient.cs | 4 ++-- .../Clients/RepositoryCommentsClientTests.cs | 7 +++++-- Octokit/Clients/RepositoryCommentsClient.cs | 3 ++- Octokit/Helpers/AcceptHeaders.cs | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs index 126de0d6bd..8fb1be79ca 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs @@ -93,11 +93,11 @@ public interface IObservableRepositoryCommentsClient /// /// Creates a reaction for specified Commit Comment /// - /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment + /// https://developer.github.com/v3/reactions/#create-reaction-for-a-commit-comment /// The owner of the repository /// The name of the repository /// The comment id - /// The reaction for + /// The reaction to create /// IObservable CreateReaction(string owner, string name, int number, NewCommitCommentReaction reaction); } diff --git a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs index 4da237d022..5a989b7fa9 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs @@ -367,17 +367,19 @@ public void Dispose() _context.Dispose(); } } - public class TheReactionMethod : IDisposable + + public class TheCreateReactionMethod : IDisposable { private readonly IGitHubClient _github; private readonly RepositoryContext _context; - public TheReactionMethod() + public TheCreateReactionMethod() { _github = Helper.GetAuthenticatedClient(); _context = _github.CreateRepositoryContext("public-repo").Result; } + private async Task SetupCommitForRepository(IGitHubClient client) { var blob = new NewBlob @@ -420,6 +422,7 @@ public async Task CanCreateReaction() Assert.IsType(reaction); } + public void Dispose() { _context.Dispose(); diff --git a/Octokit/Clients/RepositoryCommentsClient.cs b/Octokit/Clients/RepositoryCommentsClient.cs index 6a24a713cb..fdc2889b51 100644 --- a/Octokit/Clients/RepositoryCommentsClient.cs +++ b/Octokit/Clients/RepositoryCommentsClient.cs @@ -170,8 +170,9 @@ public Task CreateReaction(string owner, string name, int { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(reaction, "reaction"); - return ApiConnection.Post(ApiUrls.CommitCommentReaction(owner, name, number), reaction, AcceptHeaders.Reactions); + return ApiConnection.Post(ApiUrls.CommitCommentReaction(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); } } } diff --git a/Octokit/Helpers/AcceptHeaders.cs b/Octokit/Helpers/AcceptHeaders.cs index 0fc22b8a12..156bba7e7f 100644 --- a/Octokit/Helpers/AcceptHeaders.cs +++ b/Octokit/Helpers/AcceptHeaders.cs @@ -22,6 +22,6 @@ public static class AcceptHeaders public const string MigrationsApiPreview = " application/vnd.github.wyandotte-preview+json"; - public const string Reactions = "application/vnd.github.squirrel-girl-preview"; + public const string ReactionsPreview = "application/vnd.github.squirrel-girl-preview"; } } From ad419b3d2a68eec545b56e8fcee2259e73749585 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Thu, 26 May 2016 15:11:13 +0200 Subject: [PATCH 13/65] change parameter values for reactions --- Octokit/Models/Response/CommitCommentReaction.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit/Models/Response/CommitCommentReaction.cs b/Octokit/Models/Response/CommitCommentReaction.cs index 6def0a9995..f54faf0bc9 100644 --- a/Octokit/Models/Response/CommitCommentReaction.cs +++ b/Octokit/Models/Response/CommitCommentReaction.cs @@ -7,9 +7,9 @@ namespace Octokit { public enum Reaction { - [Parameter(Value = "plus_one")] + [Parameter(Value = "+1")] Plus1 = 0, - [Parameter(Value = "minus_one")] + [Parameter(Value = "-1")] Minus1 = 1, [Parameter(Value = "laugh")] Laugh = 2, From 913956226923716e7ae13d3c3dece37b5226f3ac Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Thu, 26 May 2016 15:13:05 +0200 Subject: [PATCH 14/65] change reaction enum --- Octokit/Models/Response/CommitCommentReaction.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Octokit/Models/Response/CommitCommentReaction.cs b/Octokit/Models/Response/CommitCommentReaction.cs index f54faf0bc9..b4660715f9 100644 --- a/Octokit/Models/Response/CommitCommentReaction.cs +++ b/Octokit/Models/Response/CommitCommentReaction.cs @@ -8,17 +8,17 @@ namespace Octokit public enum Reaction { [Parameter(Value = "+1")] - Plus1 = 0, + Plus1, [Parameter(Value = "-1")] - Minus1 = 1, + Minus1, [Parameter(Value = "laugh")] - Laugh = 2, + Laugh, [Parameter(Value = "confused")] - Confused = 3, + Confused, [Parameter(Value = "heart")] - Heart = 4, + Heart, [Parameter(Value = "hooray")] - Hooray = 5 + Hooray } [DebuggerDisplay("{DebuggerDisplay,nq}")] From 14bbf8c728bc0ee7204e202efb68130d420999c9 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Fri, 27 May 2016 08:17:03 +0200 Subject: [PATCH 15/65] compare reaction respone fields --- .../Clients/RepositoryCommentsClientTests.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs index 5a989b7fa9..448c304391 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs @@ -421,6 +421,10 @@ public async Task CanCreateReaction() var reaction = await _github.Repository.Comment.CreateReaction(_context.RepositoryOwner, _context.RepositoryName, result.Id, newCommitCommentReaction); Assert.IsType(reaction); + + Assert.Equal(Reaction.Confused, reaction.Content); + + Assert.Equal(result.User.Id, reaction.UserId); } public void Dispose() From 69afe63a8cc08e4907e4d074de71470adbe909fc Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Fri, 27 May 2016 09:53:37 +0200 Subject: [PATCH 16/65] change response and request clients for reactions --- .../Clients/IObservableRepositoryCommentsClient.cs | 2 +- .../Clients/ObservableRepositoryCommentsClient.cs | 2 +- .../Clients/RepositoryCommentsClientTests.cs | 8 ++++---- .../Clients/RepositoryCommentsClientTests.cs | 14 +++++++------- .../ObservableRepositoryCommentsClientTests.cs | 14 +++++++------- Octokit/Clients/IRepositoryCommentsClient.cs | 2 +- Octokit/Clients/RepositoryCommentsClient.cs | 4 ++-- ...{NewCommitCommentReaction.cs => NewReaction.cs} | 8 ++++---- .../{CommitCommentReaction.cs => Reaction.cs} | 10 +++++----- Octokit/Octokit-Mono.csproj | 4 ++-- Octokit/Octokit-MonoAndroid.csproj | 4 ++-- Octokit/Octokit-Monotouch.csproj | 4 ++-- Octokit/Octokit-Portable.csproj | 6 +++--- Octokit/Octokit-netcore45.csproj | 6 +++--- Octokit/Octokit.csproj | 4 ++-- 15 files changed, 46 insertions(+), 46 deletions(-) rename Octokit/Models/Request/{NewCommitCommentReaction.cs => NewReaction.cs} (69%) rename Octokit/Models/Response/{CommitCommentReaction.cs => Reaction.cs} (83%) diff --git a/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs index 8fb1be79ca..0883509dfd 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs @@ -99,6 +99,6 @@ public interface IObservableRepositoryCommentsClient /// The comment id /// The reaction to create /// - IObservable CreateReaction(string owner, string name, int number, NewCommitCommentReaction reaction); + IObservable CreateReaction(string owner, string name, int number, NewReaction reaction); } } diff --git a/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs index 2f8e74d4bb..4406991517 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs @@ -164,7 +164,7 @@ public IObservable Delete(string owner, string name, int number) /// The comment id /// The reaction for /// - public IObservable CreateReaction(string owner, string name, int number, NewCommitCommentReaction reaction) + public IObservable CreateReaction(string owner, string name, int number, NewReaction reaction) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); diff --git a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs index 448c304391..70df517311 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs @@ -417,12 +417,12 @@ public async Task CanCreateReaction() Assert.NotNull(result); - var newCommitCommentReaction = new NewCommitCommentReaction(Reaction.Confused); - var reaction = await _github.Repository.Comment.CreateReaction(_context.RepositoryOwner, _context.RepositoryName, result.Id, newCommitCommentReaction); + var newReaction = new NewReaction(EnumReaction.Confused); + var reaction = await _github.Repository.Comment.CreateReaction(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReaction); - Assert.IsType(reaction); + Assert.IsType(reaction); - Assert.Equal(Reaction.Confused, reaction.Content); + Assert.Equal(EnumReaction.Confused, reaction.Content); Assert.Equal(result.User.Id, reaction.UserId); } diff --git a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs index dced43edea..0a0b6a7da4 100644 --- a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs @@ -245,14 +245,14 @@ public class TheReactionMethod [Fact] public void RequestsCorrectUrl() { - NewCommitCommentReaction newCommitCommentReaction = new NewCommitCommentReaction(Reaction.Heart); + NewReaction newReaction = new NewReaction(EnumReaction.Heart); var connection = Substitute.For(); var client = new RepositoryCommentsClient(connection); - client.CreateReaction("fake", "repo", 1, newCommitCommentReaction); + client.CreateReaction("fake", "repo", 1, newReaction); - connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), Arg.Any(), "application/vnd.github.squirrel-girl-preview"); + connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), Arg.Any(), "application/vnd.github.squirrel-girl-preview"); } [Fact] @@ -261,10 +261,10 @@ public async Task EnsuresArgumentsNotNull() var connection = Substitute.For(); var client = new RepositoryCommentsClient(connection); - await Assert.ThrowsAsync(() => client.CreateReaction(null, "name", 1, new NewCommitCommentReaction(Reaction.Heart))); - await Assert.ThrowsAsync(() => client.CreateReaction("", "name", 1, new NewCommitCommentReaction(Reaction.Heart))); - await Assert.ThrowsAsync(() => client.CreateReaction("owner", null, 1, new NewCommitCommentReaction(Reaction.Heart))); - await Assert.ThrowsAsync(() => client.CreateReaction("owner", "", 1, new NewCommitCommentReaction(Reaction.Heart))); + await Assert.ThrowsAsync(() => client.CreateReaction(null, "name", 1, new NewReaction(EnumReaction.Heart))); + await Assert.ThrowsAsync(() => client.CreateReaction("", "name", 1, new NewReaction(EnumReaction.Heart))); + await Assert.ThrowsAsync(() => client.CreateReaction("owner", null, 1, new NewReaction(EnumReaction.Heart))); + await Assert.ThrowsAsync(() => client.CreateReaction("owner", "", 1, new NewReaction(EnumReaction.Heart))); } } diff --git a/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs index 76b27f8508..1ac164cfcc 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs @@ -140,10 +140,10 @@ public void RequestsCorrectUrl() { var githubClient = Substitute.For(); var client = new ObservableRepositoryCommentsClient(githubClient); - var newCommitCommentReaction = new NewCommitCommentReaction(Reaction.Confused); + var newReaction = new NewReaction(EnumReaction.Confused); - client.CreateReaction("fake", "repo", 1, newCommitCommentReaction); - githubClient.Received().Repository.Comment.CreateReaction("fake", "repo", 1, newCommitCommentReaction); + client.CreateReaction("fake", "repo", 1, newReaction); + githubClient.Received().Repository.Comment.CreateReaction("fake", "repo", 1, newReaction); } [Fact] @@ -152,10 +152,10 @@ public void EnsuresArgumentsNotNull() var githubClient = Substitute.For(); var client = new ObservableRepositoryCommentsClient(githubClient); - Assert.Throws(() => client.CreateReaction(null, "name", 1, new NewCommitCommentReaction(Reaction.Heart))); - Assert.Throws(() => client.CreateReaction("", "name", 1, new NewCommitCommentReaction(Reaction.Heart))); - Assert.Throws(() => client.CreateReaction("owner", null, 1, new NewCommitCommentReaction(Reaction.Heart))); - Assert.Throws(() => client.CreateReaction("owner", "", 1, new NewCommitCommentReaction(Reaction.Heart))); + Assert.Throws(() => client.CreateReaction(null, "name", 1, new NewReaction(EnumReaction.Heart))); + Assert.Throws(() => client.CreateReaction("", "name", 1, new NewReaction(EnumReaction.Heart))); + Assert.Throws(() => client.CreateReaction("owner", null, 1, new NewReaction(EnumReaction.Heart))); + Assert.Throws(() => client.CreateReaction("owner", "", 1, new NewReaction(EnumReaction.Heart))); } } } diff --git a/Octokit/Clients/IRepositoryCommentsClient.cs b/Octokit/Clients/IRepositoryCommentsClient.cs index a6bbcdbb83..a32e5c6158 100644 --- a/Octokit/Clients/IRepositoryCommentsClient.cs +++ b/Octokit/Clients/IRepositoryCommentsClient.cs @@ -105,6 +105,6 @@ public interface IRepositoryCommentsClient /// The comment id /// The reaction for /// - Task CreateReaction(string owner, string name, int number, NewCommitCommentReaction reaction); + Task CreateReaction(string owner, string name, int number, NewReaction reaction); } } diff --git a/Octokit/Clients/RepositoryCommentsClient.cs b/Octokit/Clients/RepositoryCommentsClient.cs index fdc2889b51..f6a07b7e74 100644 --- a/Octokit/Clients/RepositoryCommentsClient.cs +++ b/Octokit/Clients/RepositoryCommentsClient.cs @@ -166,13 +166,13 @@ public Task Delete(string owner, string name, int number) /// The comment id /// The reaction for /// - public Task CreateReaction(string owner, string name, int number, NewCommitCommentReaction reaction) + public Task CreateReaction(string owner, string name, int number, NewReaction reaction) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(reaction, "reaction"); - return ApiConnection.Post(ApiUrls.CommitCommentReaction(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); + return ApiConnection.Post(ApiUrls.CommitCommentReaction(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); } } } diff --git a/Octokit/Models/Request/NewCommitCommentReaction.cs b/Octokit/Models/Request/NewReaction.cs similarity index 69% rename from Octokit/Models/Request/NewCommitCommentReaction.cs rename to Octokit/Models/Request/NewReaction.cs index 95b5cdf6a9..060f0df17e 100644 --- a/Octokit/Models/Request/NewCommitCommentReaction.cs +++ b/Octokit/Models/Request/NewReaction.cs @@ -4,13 +4,13 @@ namespace Octokit { [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class NewCommitCommentReaction + public class NewReaction { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The reaction type. - public NewCommitCommentReaction(Reaction content) + public NewReaction(EnumReaction content) { Content = content; } @@ -18,7 +18,7 @@ public NewCommitCommentReaction(Reaction content) /// /// The reaction type (required) /// - public Reaction Content { get; private set; } + public EnumReaction Content { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/CommitCommentReaction.cs b/Octokit/Models/Response/Reaction.cs similarity index 83% rename from Octokit/Models/Response/CommitCommentReaction.cs rename to Octokit/Models/Response/Reaction.cs index b4660715f9..92ec308dc5 100644 --- a/Octokit/Models/Response/CommitCommentReaction.cs +++ b/Octokit/Models/Response/Reaction.cs @@ -5,7 +5,7 @@ namespace Octokit { - public enum Reaction + public enum EnumReaction { [Parameter(Value = "+1")] Plus1, @@ -22,11 +22,11 @@ public enum Reaction } [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class CommitCommentReaction + public class Reaction { - public CommitCommentReaction() { } + public Reaction() { } - public CommitCommentReaction(int id, int userId, Reaction content) + public Reaction(int id, int userId, EnumReaction content) { Id = id; UserId = userId; @@ -47,7 +47,7 @@ public CommitCommentReaction(int id, int userId, Reaction content) /// The reaction type for this commit comment. /// [Parameter(Key = "content")] - public Reaction Content { get; protected set; } + public EnumReaction Content { get; protected set; } internal string DebuggerDisplay { diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index a5edbe2004..e1d404be1e 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -466,8 +466,8 @@ - - + + \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index 2bdf311f83..88be5cf0c6 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -477,8 +477,8 @@ - - + + \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index 4034868cdf..0b16601cf4 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -473,8 +473,8 @@ - - + + diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj index fe318eabe8..ca97a4c66c 100644 --- a/Octokit/Octokit-Portable.csproj +++ b/Octokit/Octokit-Portable.csproj @@ -462,9 +462,9 @@ - - - + + + diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index 358b1d74a1..16f76baf59 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -469,9 +469,9 @@ - - - + + + diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 6b59c10892..00b0cfca91 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -120,7 +120,7 @@ - + @@ -157,7 +157,7 @@ - + From 9f22e17fb562cdf0c2c393c6ab4efa32ec63b5fb Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Fri, 27 May 2016 10:30:10 +0200 Subject: [PATCH 17/65] change class name for enum reactions --- .../Clients/RepositoryCommentsClientTests.cs | 4 ++-- Octokit.Tests/Clients/RepositoryCommentsClientTests.cs | 10 +++++----- .../ObservableRepositoryCommentsClientTests.cs | 10 +++++----- Octokit/Models/Request/NewReaction.cs | 4 ++-- Octokit/Models/Response/Reaction.cs | 6 +++--- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs index 70df517311..dd1d2907ef 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs @@ -417,12 +417,12 @@ public async Task CanCreateReaction() Assert.NotNull(result); - var newReaction = new NewReaction(EnumReaction.Confused); + var newReaction = new NewReaction(ReactionType.Confused); var reaction = await _github.Repository.Comment.CreateReaction(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReaction); Assert.IsType(reaction); - Assert.Equal(EnumReaction.Confused, reaction.Content); + Assert.Equal(ReactionType.Confused, reaction.Content); Assert.Equal(result.User.Id, reaction.UserId); } diff --git a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs index 0a0b6a7da4..7e67269c7f 100644 --- a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs @@ -245,7 +245,7 @@ public class TheReactionMethod [Fact] public void RequestsCorrectUrl() { - NewReaction newReaction = new NewReaction(EnumReaction.Heart); + NewReaction newReaction = new NewReaction(ReactionType.Heart); var connection = Substitute.For(); var client = new RepositoryCommentsClient(connection); @@ -261,10 +261,10 @@ public async Task EnsuresArgumentsNotNull() var connection = Substitute.For(); var client = new RepositoryCommentsClient(connection); - await Assert.ThrowsAsync(() => client.CreateReaction(null, "name", 1, new NewReaction(EnumReaction.Heart))); - await Assert.ThrowsAsync(() => client.CreateReaction("", "name", 1, new NewReaction(EnumReaction.Heart))); - await Assert.ThrowsAsync(() => client.CreateReaction("owner", null, 1, new NewReaction(EnumReaction.Heart))); - await Assert.ThrowsAsync(() => client.CreateReaction("owner", "", 1, new NewReaction(EnumReaction.Heart))); + await Assert.ThrowsAsync(() => client.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); } } diff --git a/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs index 1ac164cfcc..61ed989ed2 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs @@ -140,7 +140,7 @@ public void RequestsCorrectUrl() { var githubClient = Substitute.For(); var client = new ObservableRepositoryCommentsClient(githubClient); - var newReaction = new NewReaction(EnumReaction.Confused); + var newReaction = new NewReaction(ReactionType.Confused); client.CreateReaction("fake", "repo", 1, newReaction); githubClient.Received().Repository.Comment.CreateReaction("fake", "repo", 1, newReaction); @@ -152,10 +152,10 @@ public void EnsuresArgumentsNotNull() var githubClient = Substitute.For(); var client = new ObservableRepositoryCommentsClient(githubClient); - Assert.Throws(() => client.CreateReaction(null, "name", 1, new NewReaction(EnumReaction.Heart))); - Assert.Throws(() => client.CreateReaction("", "name", 1, new NewReaction(EnumReaction.Heart))); - Assert.Throws(() => client.CreateReaction("owner", null, 1, new NewReaction(EnumReaction.Heart))); - Assert.Throws(() => client.CreateReaction("owner", "", 1, new NewReaction(EnumReaction.Heart))); + Assert.Throws(() => client.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => client.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => client.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => client.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); } } } diff --git a/Octokit/Models/Request/NewReaction.cs b/Octokit/Models/Request/NewReaction.cs index 060f0df17e..45607c14b8 100644 --- a/Octokit/Models/Request/NewReaction.cs +++ b/Octokit/Models/Request/NewReaction.cs @@ -10,7 +10,7 @@ public class NewReaction /// Initializes a new instance of the class. /// /// The reaction type. - public NewReaction(EnumReaction content) + public NewReaction(ReactionType content) { Content = content; } @@ -18,7 +18,7 @@ public NewReaction(EnumReaction content) /// /// The reaction type (required) /// - public EnumReaction Content { get; private set; } + public ReactionType Content { get; private set; } internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/Reaction.cs b/Octokit/Models/Response/Reaction.cs index 92ec308dc5..6ad8e4c15c 100644 --- a/Octokit/Models/Response/Reaction.cs +++ b/Octokit/Models/Response/Reaction.cs @@ -5,7 +5,7 @@ namespace Octokit { - public enum EnumReaction + public enum ReactionType { [Parameter(Value = "+1")] Plus1, @@ -26,7 +26,7 @@ public class Reaction { public Reaction() { } - public Reaction(int id, int userId, EnumReaction content) + public Reaction(int id, int userId, ReactionType content) { Id = id; UserId = userId; @@ -47,7 +47,7 @@ public Reaction(int id, int userId, EnumReaction content) /// The reaction type for this commit comment. /// [Parameter(Key = "content")] - public EnumReaction Content { get; protected set; } + public ReactionType Content { get; protected set; } internal string DebuggerDisplay { From 06fdace3b417572311db6b5de43a41703726cb07 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Fri, 27 May 2016 15:17:56 +0200 Subject: [PATCH 18/65] create classes for standalone reaction client and CommitCommentReaction --- Octokit/Clients/IReactionCommitComment.cs | 29 ++++++++++++++ Octokit/Clients/ReactionCommitComment.cs | 49 +++++++++++++++++++++++ Octokit/Clients/ReactionsClient.cs | 17 ++++++++ Octokit/GitHubClient.cs | 9 +++++ Octokit/IGitHubClient.cs | 8 ++++ Octokit/IReactionsClient.cs | 19 +++++++++ Octokit/Octokit-Mono.csproj | 4 ++ Octokit/Octokit-MonoAndroid.csproj | 4 ++ Octokit/Octokit-Monotouch.csproj | 4 ++ Octokit/Octokit-Portable.csproj | 6 ++- Octokit/Octokit-netcore45.csproj | 6 ++- Octokit/Octokit.csproj | 4 ++ 12 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 Octokit/Clients/IReactionCommitComment.cs create mode 100644 Octokit/Clients/ReactionCommitComment.cs create mode 100644 Octokit/Clients/ReactionsClient.cs create mode 100644 Octokit/IReactionsClient.cs diff --git a/Octokit/Clients/IReactionCommitComment.cs b/Octokit/Clients/IReactionCommitComment.cs new file mode 100644 index 0000000000..a6db7cc359 --- /dev/null +++ b/Octokit/Clients/IReactionCommitComment.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + public interface ICommitCommentReaction + { + /// + /// Creates a reaction for an specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction for + /// + Task CreateReaction(string owner, string name, int number, NewReaction reaction); + + /// + /// List reactions for a specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#list-reaction-for-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// + Task> ListReactions(string owner, string name, int number); + } +} diff --git a/Octokit/Clients/ReactionCommitComment.cs b/Octokit/Clients/ReactionCommitComment.cs new file mode 100644 index 0000000000..11162ae29a --- /dev/null +++ b/Octokit/Clients/ReactionCommitComment.cs @@ -0,0 +1,49 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + public class CommitCommentReaction : ApiClient, ICommitCommentReaction + { + public CommitCommentReaction(IApiConnection apiConnection) + : base(apiConnection) + { + } + + /// + /// Creates a reaction for a specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction for + /// + public Task CreateReaction(string owner, string name, int number, NewReaction reaction) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(reaction, "reaction"); + + return ApiConnection.Post(ApiUrls.CommitCommentReaction(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); + } + + /// + /// List reactions for a specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction for + /// + public Task> ListReactions(string owner, string name, int number, NewReaction reaction) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(reaction, "reaction"); + + return ApiConnection.Get(ApiUrls.CommitCommentReaction(owner, name, number),"", AcceptHeaders.ReactionsPreview); + } + } +} diff --git a/Octokit/Clients/ReactionsClient.cs b/Octokit/Clients/ReactionsClient.cs new file mode 100644 index 0000000000..0c887deb3a --- /dev/null +++ b/Octokit/Clients/ReactionsClient.cs @@ -0,0 +1,17 @@ +namespace Octokit +{ + public class ReactionsClient : ApiClient, IReactionsClient + { + /// + /// Instantiates a new GitHub Reactions API client + /// + /// An API connection + public ReactionsClient(IApiConnection apiConnection) + : base(apiConnection) + { + CommitComments = new CommitCommentReaction(apiConnection); + } + + public ICommitCommentReaction CommitComments { get; private set; } + } +} diff --git a/Octokit/GitHubClient.cs b/Octokit/GitHubClient.cs index 4daa1bfc7b..9d7cb4ef72 100644 --- a/Octokit/GitHubClient.cs +++ b/Octokit/GitHubClient.cs @@ -99,6 +99,7 @@ public GitHubClient(IConnection connection) Search = new SearchClient(apiConnection); SshKey = new SshKeysClient(apiConnection); User = new UsersClient(apiConnection); + Reaction = new ReactionsClient(apiConnection); } /// @@ -305,6 +306,14 @@ public IReleasesClient Release /// public IEnterpriseClient Enterprise { get; private set; } + /// + /// Access GitHub's Reactions API + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ + /// + public IReactionsClient Reaction { get; private set; } + static Uri FixUpBaseUri(Uri uri) { Ensure.ArgumentNotNull(uri, "uri"); diff --git a/Octokit/IGitHubClient.cs b/Octokit/IGitHubClient.cs index f91d99f304..03e861d75b 100644 --- a/Octokit/IGitHubClient.cs +++ b/Octokit/IGitHubClient.cs @@ -162,5 +162,13 @@ public interface IGitHubClient : IApiInfoProvider /// Refer to the API documentation for more information: https://developer.github.com/v3/enterprise/ /// IEnterpriseClient Enterprise { get; } + + /// + /// Access GitHub's Reactions API + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ + /// + IReactionsClient Reaction { get; } } } diff --git a/Octokit/IReactionsClient.cs b/Octokit/IReactionsClient.cs new file mode 100644 index 0000000000..5fc2115a63 --- /dev/null +++ b/Octokit/IReactionsClient.cs @@ -0,0 +1,19 @@ +namespace Octokit +{ + /// + /// A client for GitHub's Reactions Events API. + /// + /// + /// See the Reactions API documentation for more information + /// + public interface IReactionsClient + { + /// + /// Access GitHub's Reactions API. + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ + /// + ICommitCommentReaction CommitComments { get; } + } +} diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index e1d404be1e..4700c2fbaf 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -468,6 +468,10 @@ + + + + \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index 88be5cf0c6..3ecbbfab5f 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -479,6 +479,10 @@ + + + + \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index 0b16601cf4..5fc7326171 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -475,6 +475,10 @@ + + + + diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj index ca97a4c66c..1d3e3bdd8a 100644 --- a/Octokit/Octokit-Portable.csproj +++ b/Octokit/Octokit-Portable.csproj @@ -462,9 +462,13 @@ - + + + + + diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index 16f76baf59..fdc22f54f1 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -469,9 +469,13 @@ - + + + + + diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 00b0cfca91..5ec68bae7e 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -58,6 +58,7 @@ Properties\SolutionInfo.cs + @@ -85,6 +86,8 @@ + + @@ -118,6 +121,7 @@ + From 6bedcf89934fd517d4e9077eb555dbbfbacffd3e Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Fri, 27 May 2016 15:23:26 +0200 Subject: [PATCH 19/65] add GetAll Method for uri and accepts add api fix GetAllMethod fix ApiOptions --- Octokit/Clients/ReactionCommitComment.cs | 7 +++---- Octokit/Http/ApiConnection.cs | 15 ++++++++++++++- Octokit/Http/IApiConnection.cs | 12 +++++++++++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/Octokit/Clients/ReactionCommitComment.cs b/Octokit/Clients/ReactionCommitComment.cs index 11162ae29a..d145f51cc6 100644 --- a/Octokit/Clients/ReactionCommitComment.cs +++ b/Octokit/Clients/ReactionCommitComment.cs @@ -37,13 +37,12 @@ public Task CreateReaction(string owner, string name, int number, NewR /// The comment id /// The reaction for /// - public Task> ListReactions(string owner, string name, int number, NewReaction reaction) + public Task> ListReactions(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - Ensure.ArgumentNotNull(reaction, "reaction"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return ApiConnection.Get(ApiUrls.CommitCommentReaction(owner, name, number),"", AcceptHeaders.ReactionsPreview); + return ApiConnection.GetAll(ApiUrls.CommitCommentReaction(owner, name, number), AcceptHeaders.ReactionsPreview); } } } diff --git a/Octokit/Http/ApiConnection.cs b/Octokit/Http/ApiConnection.cs index 3838e555b3..30c9634c8b 100644 --- a/Octokit/Http/ApiConnection.cs +++ b/Octokit/Http/ApiConnection.cs @@ -144,6 +144,19 @@ public Task> GetAll(Uri uri, IDictionary par return GetAll(uri, parameters, null, ApiOptions.None); } + /// + /// Gets all API resources in the list at the specified URI. + /// + /// Type of the API resource in the list. + /// URI of the API resource to get + /// Accept header to use for the API request + /// of the The API resources in the list. + /// Thrown when an API error occurs. + public Task> GetAll(Uri uri, string accepts) + { + return GetAll(uri, null, accepts, ApiOptions.None); + } + /// /// Gets all API resources in the list at the specified URI. /// @@ -463,7 +476,7 @@ 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); } /// diff --git a/Octokit/Http/IApiConnection.cs b/Octokit/Http/IApiConnection.cs index 2e50e8c4a0..0444e3dd36 100644 --- a/Octokit/Http/IApiConnection.cs +++ b/Octokit/Http/IApiConnection.cs @@ -91,6 +91,16 @@ public interface IApiConnection /// Thrown when an API error occurs. Task> GetAll(Uri uri, IDictionary parameters); + /// + /// Gets all API resources in the list at the specified URI. + /// + /// Type of the API resource in the list. + /// URI of the API resource to get + /// Accept header to use for the API request + /// of the The API resources in the list. + /// Thrown when an API error occurs. + Task> GetAll(Uri uri, string accepts); + /// /// Gets all API resources in the list at the specified URI. /// @@ -301,7 +311,7 @@ public interface IApiConnection /// 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. From 831ff1cf3170ab23ffbaf9abd280e97a910ddd52 Mon Sep 17 00:00:00 2001 From: lrz-hal Date: Sun, 29 May 2016 14:07:37 +0200 Subject: [PATCH 20/65] Add observable reactions client --- Octokit.Reactive/Clients/IObservableReactionsClient.cs | 6 ++++++ Octokit.Reactive/Clients/ObservableReactionsClient.cs | 10 ++++++++++ Octokit.Reactive/IObservableGitHubClient.cs | 1 + Octokit.Reactive/ObservableGitHubClient.cs | 2 ++ Octokit.Reactive/Octokit.Reactive.csproj | 2 ++ ...actionCommitComment.cs => CommitCommentReaction.cs} | 0 ...ctionCommitComment.cs => ICommitCommentReaction.cs} | 0 Octokit/{ => Clients}/IReactionsClient.cs | 0 Octokit/Octokit.csproj | 6 +++--- 9 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 Octokit.Reactive/Clients/IObservableReactionsClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableReactionsClient.cs rename Octokit/Clients/{ReactionCommitComment.cs => CommitCommentReaction.cs} (100%) rename Octokit/Clients/{IReactionCommitComment.cs => ICommitCommentReaction.cs} (100%) rename Octokit/{ => Clients}/IReactionsClient.cs (100%) diff --git a/Octokit.Reactive/Clients/IObservableReactionsClient.cs b/Octokit.Reactive/Clients/IObservableReactionsClient.cs new file mode 100644 index 0000000000..3d25f253e3 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableReactionsClient.cs @@ -0,0 +1,6 @@ +namespace Octokit.Reactive +{ + public interface IObservableReactionsClient + { + } +} diff --git a/Octokit.Reactive/Clients/ObservableReactionsClient.cs b/Octokit.Reactive/Clients/ObservableReactionsClient.cs new file mode 100644 index 0000000000..1e80a04c69 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableReactionsClient.cs @@ -0,0 +1,10 @@ +namespace Octokit.Reactive +{ + public class ObservableReactionsClient : IObservableReactionsClient + { + public ObservableReactionsClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, "client"); + } + } +} diff --git a/Octokit.Reactive/IObservableGitHubClient.cs b/Octokit.Reactive/IObservableGitHubClient.cs index 00650ab5f6..aa608c8880 100644 --- a/Octokit.Reactive/IObservableGitHubClient.cs +++ b/Octokit.Reactive/IObservableGitHubClient.cs @@ -27,5 +27,6 @@ public interface IObservableGitHubClient : IApiInfoProvider IObservableSearchClient Search { get; } IObservableEnterpriseClient Enterprise { get; } IObservableMigrationClient Migration { get; } + IObservableReactionsClient Reaction { get; } } } \ No newline at end of file diff --git a/Octokit.Reactive/ObservableGitHubClient.cs b/Octokit.Reactive/ObservableGitHubClient.cs index 0d71234444..a5aec6b545 100644 --- a/Octokit.Reactive/ObservableGitHubClient.cs +++ b/Octokit.Reactive/ObservableGitHubClient.cs @@ -47,6 +47,7 @@ public ObservableGitHubClient(IGitHubClient gitHubClient) Search = new ObservableSearchClient(gitHubClient); Enterprise = new ObservableEnterpriseClient(gitHubClient); Migration = new ObservableMigrationClient(gitHubClient); + Reaction = new ObservableReactionsClient(gitHubClient); } public IConnection Connection @@ -74,6 +75,7 @@ public IConnection Connection public IObservableSearchClient Search { get; private set; } public IObservableEnterpriseClient Enterprise { get; private set; } public IObservableMigrationClient Migration { get; private set; } + public IObservableReactionsClient Reaction { get; private set; } /// /// Gets the latest API Info - this will be null if no API calls have been made diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index 920aefbe9c..3b3fefdbec 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -99,9 +99,11 @@ + + diff --git a/Octokit/Clients/ReactionCommitComment.cs b/Octokit/Clients/CommitCommentReaction.cs similarity index 100% rename from Octokit/Clients/ReactionCommitComment.cs rename to Octokit/Clients/CommitCommentReaction.cs diff --git a/Octokit/Clients/IReactionCommitComment.cs b/Octokit/Clients/ICommitCommentReaction.cs similarity index 100% rename from Octokit/Clients/IReactionCommitComment.cs rename to Octokit/Clients/ICommitCommentReaction.cs diff --git a/Octokit/IReactionsClient.cs b/Octokit/Clients/IReactionsClient.cs similarity index 100% rename from Octokit/IReactionsClient.cs rename to Octokit/Clients/IReactionsClient.cs diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 5ec68bae7e..58eec2dc8c 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -58,7 +58,7 @@ Properties\SolutionInfo.cs - + @@ -86,7 +86,7 @@ - + @@ -121,7 +121,7 @@ - + From f983bba1b70ac3090acb589d83e6e0f858439df2 Mon Sep 17 00:00:00 2001 From: lrz-hal Date: Mon, 30 May 2016 10:46:05 +0200 Subject: [PATCH 21/65] add observable Reactions and CommitCommentReaction client fix --- .../IObservableCommitCommentReactionClient.cs | 28 ++++++++++ .../Clients/IObservableReactionsClient.cs | 1 + .../ObservableCommitCommentReactionClient.cs | 55 +++++++++++++++++++ .../Clients/ObservableReactionsClient.cs | 4 ++ Octokit.Reactive/Octokit.Reactive-Mono.csproj | 8 ++- .../Octokit.Reactive-MonoAndroid.csproj | 8 ++- .../Octokit.Reactive-Monotouch.csproj | 8 ++- Octokit.Reactive/Octokit.Reactive.csproj | 2 + ...tion.cs => CommitCommentReactionClient.cs} | 12 ++-- ...ion.cs => ICommitCommentReactionClient.cs} | 8 +-- Octokit/Clients/IReactionsClient.cs | 2 +- Octokit/Clients/ReactionsClient.cs | 6 +- Octokit/Octokit-Mono.csproj | 10 ++-- Octokit/Octokit-MonoAndroid.csproj | 8 +-- Octokit/Octokit-Monotouch.csproj | 8 +-- Octokit/Octokit-Portable.csproj | 8 +-- Octokit/Octokit-netcore45.csproj | 8 +-- Octokit/Octokit.csproj | 4 +- 18 files changed, 148 insertions(+), 40 deletions(-) create mode 100644 Octokit.Reactive/Clients/IObservableCommitCommentReactionClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableCommitCommentReactionClient.cs rename Octokit/Clients/{CommitCommentReaction.cs => CommitCommentReactionClient.cs} (80%) rename Octokit/Clients/{ICommitCommentReaction.cs => ICommitCommentReactionClient.cs} (80%) diff --git a/Octokit.Reactive/Clients/IObservableCommitCommentReactionClient.cs b/Octokit.Reactive/Clients/IObservableCommitCommentReactionClient.cs new file mode 100644 index 0000000000..967786cf5b --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableCommitCommentReactionClient.cs @@ -0,0 +1,28 @@ +using System; + +namespace Octokit.Reactive +{ + public interface IObservableCommitCommentReactionClient + { + /// + /// Creates a reaction for an specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction for + /// + IObservable CreateReaction(string owner, string name, int number, NewReaction reaction); + + /// + /// List reactions for a specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#list-reactions-for-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// + IObservable GetAll(string owner, string name, int number); + } +} diff --git a/Octokit.Reactive/Clients/IObservableReactionsClient.cs b/Octokit.Reactive/Clients/IObservableReactionsClient.cs index 3d25f253e3..f10da10886 100644 --- a/Octokit.Reactive/Clients/IObservableReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableReactionsClient.cs @@ -2,5 +2,6 @@ { public interface IObservableReactionsClient { + IObservableCommitCommentReactionClient CommitComments { get; } } } diff --git a/Octokit.Reactive/Clients/ObservableCommitCommentReactionClient.cs b/Octokit.Reactive/Clients/ObservableCommitCommentReactionClient.cs new file mode 100644 index 0000000000..91f59d9281 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableCommitCommentReactionClient.cs @@ -0,0 +1,55 @@ +using System; +using System.Reactive.Threading.Tasks; +using Octokit.Reactive.Internal; + +namespace Octokit.Reactive +{ + public class ObservableCommitCommentReactionClient : IObservableCommitCommentReactionClient + { + readonly ICommitCommentReactionClient _client; + readonly IConnection _connection; + + public ObservableCommitCommentReactionClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, "client"); + + _client = client.Reaction.CommitComments; + _connection = client.Connection; + } + + /// + /// Creates a reaction for a specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction for + /// + public IObservable CreateReaction(string owner, string name, int number, NewReaction reaction) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(reaction, "reaction"); + + return _client.CreateReaction(owner, name, number, reaction).ToObservable(); + } + + /// + /// List reactions for a specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#list-reactions-for-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction for + /// + public IObservable GetAll(string owner, string name, int number) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return _connection.GetAndFlattenAllPages(ApiUrls.CommitCommentReaction(owner, name, number)); + } + } +} diff --git a/Octokit.Reactive/Clients/ObservableReactionsClient.cs b/Octokit.Reactive/Clients/ObservableReactionsClient.cs index 1e80a04c69..b94bc723ee 100644 --- a/Octokit.Reactive/Clients/ObservableReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableReactionsClient.cs @@ -5,6 +5,10 @@ public class ObservableReactionsClient : IObservableReactionsClient public ObservableReactionsClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); + + CommitComments = new ObservableCommitCommentReactionClient(client); } + + public IObservableCommitCommentReactionClient CommitComments { get; private set; } } } diff --git a/Octokit.Reactive/Octokit.Reactive-Mono.csproj b/Octokit.Reactive/Octokit.Reactive-Mono.csproj index 9601cc8d7c..08f0a67b82 100644 --- a/Octokit.Reactive/Octokit.Reactive-Mono.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Mono.csproj @@ -180,6 +180,12 @@ + + + + + + @@ -188,4 +194,4 @@ Octokit-Mono - + \ No newline at end of file diff --git a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj index bf75c3bf3b..e2b2f8d5ed 100644 --- a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj +++ b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj @@ -188,6 +188,12 @@ + + + + + + @@ -196,4 +202,4 @@ Octokit-MonoAndroid - + \ No newline at end of file diff --git a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj index 065807bc88..625fcdc11e 100644 --- a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj @@ -184,6 +184,12 @@ + + + + + + @@ -192,4 +198,4 @@ Octokit-Monotouch - + \ No newline at end of file diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index 3b3fefdbec..f3bfa18f35 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -90,6 +90,7 @@ + @@ -100,6 +101,7 @@ + diff --git a/Octokit/Clients/CommitCommentReaction.cs b/Octokit/Clients/CommitCommentReactionClient.cs similarity index 80% rename from Octokit/Clients/CommitCommentReaction.cs rename to Octokit/Clients/CommitCommentReactionClient.cs index d145f51cc6..11d79263e8 100644 --- a/Octokit/Clients/CommitCommentReaction.cs +++ b/Octokit/Clients/CommitCommentReactionClient.cs @@ -3,9 +3,9 @@ namespace Octokit { - public class CommitCommentReaction : ApiClient, ICommitCommentReaction + public class CommitCommentReactionClient : ApiClient, ICommitCommentReactionClient { - public CommitCommentReaction(IApiConnection apiConnection) + public CommitCommentReactionClient(IApiConnection apiConnection) : base(apiConnection) { } @@ -29,18 +29,18 @@ public Task CreateReaction(string owner, string name, int number, NewR } /// - /// List reactions for a specified Commit Comment + /// Get all reactions for a specified Commit Comment /// - /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment + /// http://developer.github.com/v3/repos/comments/#list-reactions-for-a-commit-comment /// The owner of the repository /// The name of the repository /// The comment id /// The reaction for /// - public Task> ListReactions(string owner, string name, int number) + public Task> GetAll(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); return ApiConnection.GetAll(ApiUrls.CommitCommentReaction(owner, name, number), AcceptHeaders.ReactionsPreview); } diff --git a/Octokit/Clients/ICommitCommentReaction.cs b/Octokit/Clients/ICommitCommentReactionClient.cs similarity index 80% rename from Octokit/Clients/ICommitCommentReaction.cs rename to Octokit/Clients/ICommitCommentReactionClient.cs index a6db7cc359..c3865f1096 100644 --- a/Octokit/Clients/ICommitCommentReaction.cs +++ b/Octokit/Clients/ICommitCommentReactionClient.cs @@ -3,7 +3,7 @@ namespace Octokit { - public interface ICommitCommentReaction + public interface ICommitCommentReactionClient { /// /// Creates a reaction for an specified Commit Comment @@ -17,13 +17,13 @@ public interface ICommitCommentReaction Task CreateReaction(string owner, string name, int number, NewReaction reaction); /// - /// List reactions for a specified Commit Comment + /// Get all reactions for a specified Commit Comment /// - /// http://developer.github.com/v3/repos/comments/#list-reaction-for-a-commit-comment + /// http://developer.github.com/v3/repos/comments/#list-reactions-for-a-commit-comment /// The owner of the repository /// The name of the repository /// The comment id /// - Task> ListReactions(string owner, string name, int number); + Task> GetAll(string owner, string name, int number); } } diff --git a/Octokit/Clients/IReactionsClient.cs b/Octokit/Clients/IReactionsClient.cs index 5fc2115a63..c71a349655 100644 --- a/Octokit/Clients/IReactionsClient.cs +++ b/Octokit/Clients/IReactionsClient.cs @@ -14,6 +14,6 @@ public interface IReactionsClient /// /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// - ICommitCommentReaction CommitComments { get; } + ICommitCommentReactionClient CommitComments { get; } } } diff --git a/Octokit/Clients/ReactionsClient.cs b/Octokit/Clients/ReactionsClient.cs index 0c887deb3a..6924942eb5 100644 --- a/Octokit/Clients/ReactionsClient.cs +++ b/Octokit/Clients/ReactionsClient.cs @@ -6,12 +6,12 @@ public class ReactionsClient : ApiClient, IReactionsClient /// Instantiates a new GitHub Reactions API client /// /// An API connection - public ReactionsClient(IApiConnection apiConnection) + public ReactionsClient(IApiConnection apiConnection) : base(apiConnection) { - CommitComments = new CommitCommentReaction(apiConnection); + CommitComments = new CommitCommentReactionClient(apiConnection); } - public ICommitCommentReaction CommitComments { get; private set; } + public ICommitCommentReactionClient CommitComments { get; private set; } } } diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index 4700c2fbaf..ae3e80f4d4 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -467,11 +467,11 @@ - - - - - + + + + + \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index 3ecbbfab5f..9fb7fc9f0f 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -479,10 +479,10 @@ - - - - + + + + \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index 5fc7326171..9b4e968a9d 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -475,10 +475,10 @@ - - - - + + + + diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj index 1d3e3bdd8a..ab755f2679 100644 --- a/Octokit/Octokit-Portable.csproj +++ b/Octokit/Octokit-Portable.csproj @@ -465,10 +465,10 @@ - - - - + + + + diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index fdc22f54f1..91e377ed4d 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -472,10 +472,10 @@ - - - - + + + + diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 58eec2dc8c..e3545ae95e 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -58,7 +58,7 @@ Properties\SolutionInfo.cs - + @@ -86,7 +86,7 @@ - + From 6fef1ce1ed433697f4359f230a59aed000db2510 Mon Sep 17 00:00:00 2001 From: lrz-hal Date: Mon, 30 May 2016 12:53:35 +0200 Subject: [PATCH 22/65] add unit tests for reactions --- .../IObservableRepositoryCommentsClient.cs | 13 +-- .../ObservableCommitCommentReactionClient.cs | 3 +- .../ObservableRepositoryCommentsClient.cs | 17 ---- .../Clients/RepositoryCommentsClientTests.cs | 96 +++++++++---------- Octokit.Tests/Clients/ReactionsClientTests.cs | 55 +++++++++++ .../Clients/RepositoryCommentsClientTests.cs | 28 ------ Octokit.Tests/OctoKit.Tests-NetCore45.csproj | 4 + Octokit.Tests/Octokit.Tests.csproj | 2 + .../ObservableReactionsClientTests.cs | 65 +++++++++++++ ...ObservableRepositoryCommentsClientTests.cs | 25 ----- .../Clients/CommitCommentReactionClient.cs | 3 +- Octokit/Clients/IRepositoryCommentsClient.cs | 13 +-- Octokit/Clients/RepositoryCommentsClient.cs | 18 ---- 13 files changed, 178 insertions(+), 164 deletions(-) create mode 100644 Octokit.Tests/Clients/ReactionsClientTests.cs create mode 100644 Octokit.Tests/Reactive/ObservableReactionsClientTests.cs diff --git a/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs index 0883509dfd..24f01ff7c1 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs @@ -88,17 +88,6 @@ public interface IObservableRepositoryCommentsClient /// The name of the repository /// The comment id /// - IObservable Delete(string owner, string name, int number); - - /// - /// Creates a reaction for specified Commit Comment - /// - /// https://developer.github.com/v3/reactions/#create-reaction-for-a-commit-comment - /// The owner of the repository - /// The name of the repository - /// The comment id - /// The reaction to create - /// - IObservable CreateReaction(string owner, string name, int number, NewReaction reaction); + IObservable Delete(string owner, string name, int number); } } diff --git a/Octokit.Reactive/Clients/ObservableCommitCommentReactionClient.cs b/Octokit.Reactive/Clients/ObservableCommitCommentReactionClient.cs index 91f59d9281..6b632fced0 100644 --- a/Octokit.Reactive/Clients/ObservableCommitCommentReactionClient.cs +++ b/Octokit.Reactive/Clients/ObservableCommitCommentReactionClient.cs @@ -41,8 +41,7 @@ public IObservable CreateReaction(string owner, string name, int numbe /// http://developer.github.com/v3/repos/comments/#list-reactions-for-a-commit-comment /// The owner of the repository /// The name of the repository - /// The comment id - /// The reaction for + /// The comment id /// public IObservable GetAll(string owner, string name, int number) { diff --git a/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs index 4406991517..3826850fd5 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs @@ -154,22 +154,5 @@ public IObservable Delete(string owner, string name, int number) return _client.Delete(owner, name, number).ToObservable(); } - - /// - /// Creates a reaction for specified Commit Comment - /// - /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment - /// The owner of the repository - /// The name of the repository - /// The comment id - /// The reaction for - /// - public IObservable CreateReaction(string owner, string name, int number, NewReaction reaction) - { - Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - - return _client.CreateReaction(owner, name, number, reaction).ToObservable(); - } } } diff --git a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs index f00b8d1c2d..c6a81129a1 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs @@ -377,68 +377,68 @@ public void Dispose() } } - public class TheCreateReactionMethod : IDisposable - { - private readonly IGitHubClient _github; - private readonly RepositoryContext _context; + //public class TheCreateReactionMethod : IDisposable + //{ + // private readonly IGitHubClient _github; + // private readonly RepositoryContext _context; - public TheCreateReactionMethod() - { - _github = Helper.GetAuthenticatedClient(); + // public TheCreateReactionMethod() + // { + // _github = Helper.GetAuthenticatedClient(); - _context = _github.CreateRepositoryContext("public-repo").Result; - } + // _context = _github.CreateRepositoryContext("public-repo").Result; + // } - private async Task SetupCommitForRepository(IGitHubClient client) - { - var blob = new NewBlob - { - Content = "Hello World!", - Encoding = EncodingType.Utf8 - }; - var blobResult = await client.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob); + // private async Task SetupCommitForRepository(IGitHubClient client) + // { + // var blob = new NewBlob + // { + // Content = "Hello World!", + // Encoding = EncodingType.Utf8 + // }; + // var blobResult = await client.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob); - 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 = await client.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree); + // var treeResult = await client.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree); - var newCommit = new NewCommit("test-commit", treeResult.Sha); + // var newCommit = new NewCommit("test-commit", treeResult.Sha); - return await client.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit); - } + // return await client.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit); + // } - [IntegrationTest] - public async Task CanCreateReaction() - { - var commit = await SetupCommitForRepository(_github); + // [IntegrationTest] + // public async Task CanCreateReaction() + // { + // var commit = await SetupCommitForRepository(_github); - var comment = new NewCommitComment("test"); + // var comment = new NewCommitComment("test"); - var result = await _github.Repository.Comment.Create(_context.RepositoryOwner, _context.RepositoryName, - commit.Sha, comment); + // var result = await _github.Repository.Comment.Create(_context.RepositoryOwner, _context.RepositoryName, + // commit.Sha, comment); - Assert.NotNull(result); + // Assert.NotNull(result); - var newReaction = new NewReaction(ReactionType.Confused); - var reaction = await _github.Repository.Comment.CreateReaction(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReaction); + // var newReaction = new NewReaction(ReactionType.Confused); + // var reaction = await _github.Repository.Comment.CreateReaction(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReaction); - Assert.IsType(reaction); + // Assert.IsType(reaction); - Assert.Equal(ReactionType.Confused, reaction.Content); + // Assert.Equal(ReactionType.Confused, reaction.Content); - Assert.Equal(result.User.Id, reaction.UserId); - } + // Assert.Equal(result.User.Id, reaction.UserId); + // } - public void Dispose() - { - _context.Dispose(); - } - } + // public void Dispose() + // { + // _context.Dispose(); + // } + //} } diff --git a/Octokit.Tests/Clients/ReactionsClientTests.cs b/Octokit.Tests/Clients/ReactionsClientTests.cs new file mode 100644 index 0000000000..bfe37b3b26 --- /dev/null +++ b/Octokit.Tests/Clients/ReactionsClientTests.cs @@ -0,0 +1,55 @@ +using NSubstitute; +using Octokit; +using Octokit.Tests; +using System; +using System.Threading.Tasks; +using Xunit; + +public class ReactionsClientTests +{ + public class CommitComments + { + public class TheGetAllMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ReactionsClient(connection); + + client.CommitComments.GetAll("fake", "repo", 42); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), "application/vnd.github.squirrel-girl-preview"); + } + + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var connection = Substitute.For(); + var client = new ReactionsClient(connection); + + await Assert.ThrowsAsync(() => client.CommitComments.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.CommitComments.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.CommitComments.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.CommitComments.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); + } + } + + public class TheCreateMethod + { + [Fact] + public void RequestsCorrectUrl() + { + NewReaction newReaction = new NewReaction(ReactionType.Heart); + + var connection = Substitute.For(); + var client = new ReactionsClient(connection); + + client.CommitComments.CreateReaction("fake", "repo", 1, newReaction); + + connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), Arg.Any(), "application/vnd.github.squirrel-girl-preview"); + } + } + } +} + diff --git a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs index 7e67269c7f..2628f0601b 100644 --- a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs @@ -240,34 +240,6 @@ public async Task EnsuresArgumentsNotNullOrEmpty() } } - public class TheReactionMethod - { - [Fact] - public void RequestsCorrectUrl() - { - NewReaction newReaction = new NewReaction(ReactionType.Heart); - - var connection = Substitute.For(); - var client = new RepositoryCommentsClient(connection); - - client.CreateReaction("fake", "repo", 1, newReaction); - - connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), Arg.Any(), "application/vnd.github.squirrel-girl-preview"); - } - - [Fact] - public async Task EnsuresArgumentsNotNull() - { - var connection = Substitute.For(); - var client = new RepositoryCommentsClient(connection); - - await Assert.ThrowsAsync(() => client.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); - } - } - public class TheCtor { [Fact] diff --git a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj b/Octokit.Tests/OctoKit.Tests-NetCore45.csproj index c6f5566f49..206f9b23ed 100644 --- a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj +++ b/Octokit.Tests/OctoKit.Tests-NetCore45.csproj @@ -180,6 +180,10 @@ + + {49EF16A2-5ED1-480F-80A1-D1D05D6C1BE4} + Octokit-Mono + {c8bc13b6-3fa3-4716-827d-e7706f976fe1} Octokit-NetCore45 diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 87cd858a35..72afce19ba 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -93,6 +93,7 @@ + @@ -208,6 +209,7 @@ + diff --git a/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs b/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs new file mode 100644 index 0000000000..ebaf6b2fe5 --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs @@ -0,0 +1,65 @@ +using NSubstitute; +using Octokit.Reactive; +using System; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableReactionsClientTests + { + public class CommitComments + { + public class TheGetMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var githubClient = Substitute.For(); + var client = new ObservableReactionsClient(githubClient); + + client.CommitComments.GetAll("fake", "repo", 42); + githubClient.Received().Reaction.CommitComments.GetAll("fake", "repo", 42); + } + + [Fact] + public void EnsuresArgumentsNotNull() + { + var githubClient = Substitute.For(); + var client = new ObservableReactionsClient(githubClient); + + Assert.Throws(() => client.CommitComments.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => client.CommitComments.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => client.CommitComments.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => client.CommitComments.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); + } + } + + public class TheCreateMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var githubClient = Substitute.For(); + var client = new ObservableReactionsClient(githubClient); + var newReaction = new NewReaction(ReactionType.Confused); + + client.CommitComments.CreateReaction("fake", "repo", 1, newReaction); + githubClient.Received().Reaction.CommitComments.CreateReaction("fake", "repo", 1, newReaction); + } + + [Fact] + public void EnsuresArgumentsNotNull() + { + var githubClient = Substitute.For(); + var client = new ObservableReactionsClient(githubClient); + + Assert.Throws(() => client.CommitComments.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => client.CommitComments.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => client.CommitComments.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => client.CommitComments.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); + } + } + } + } +} + diff --git a/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs index 61ed989ed2..20f8161d3b 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs @@ -133,30 +133,5 @@ public void EnsuresArgumentsNotNull() Assert.Throws(() => client.GetAllForCommit("", "name", "sha1", Args.ApiOptions)); } } - public class TheReactionMethod - { - [Fact] - public void RequestsCorrectUrl() - { - var githubClient = Substitute.For(); - var client = new ObservableRepositoryCommentsClient(githubClient); - var newReaction = new NewReaction(ReactionType.Confused); - - client.CreateReaction("fake", "repo", 1, newReaction); - githubClient.Received().Repository.Comment.CreateReaction("fake", "repo", 1, newReaction); - } - - [Fact] - public void EnsuresArgumentsNotNull() - { - var githubClient = Substitute.For(); - var client = new ObservableRepositoryCommentsClient(githubClient); - - Assert.Throws(() => client.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => client.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => client.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => client.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); - } - } } } diff --git a/Octokit/Clients/CommitCommentReactionClient.cs b/Octokit/Clients/CommitCommentReactionClient.cs index 11d79263e8..2351132434 100644 --- a/Octokit/Clients/CommitCommentReactionClient.cs +++ b/Octokit/Clients/CommitCommentReactionClient.cs @@ -34,8 +34,7 @@ public Task CreateReaction(string owner, string name, int number, NewR /// http://developer.github.com/v3/repos/comments/#list-reactions-for-a-commit-comment /// The owner of the repository /// The name of the repository - /// The comment id - /// The reaction for + /// The comment id /// public Task> GetAll(string owner, string name, int number) { diff --git a/Octokit/Clients/IRepositoryCommentsClient.cs b/Octokit/Clients/IRepositoryCommentsClient.cs index a32e5c6158..840d36c275 100644 --- a/Octokit/Clients/IRepositoryCommentsClient.cs +++ b/Octokit/Clients/IRepositoryCommentsClient.cs @@ -94,17 +94,6 @@ public interface IRepositoryCommentsClient /// The name of the repository /// The comment id /// - Task Delete(string owner, string name, int number); - - /// - /// Creates a reaction for specified Commit Comment - /// - /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment - /// The owner of the repository - /// The name of the repository - /// The comment id - /// The reaction for - /// - Task CreateReaction(string owner, string name, int number, NewReaction reaction); + Task Delete(string owner, string name, int number); } } diff --git a/Octokit/Clients/RepositoryCommentsClient.cs b/Octokit/Clients/RepositoryCommentsClient.cs index f6a07b7e74..2935c26767 100644 --- a/Octokit/Clients/RepositoryCommentsClient.cs +++ b/Octokit/Clients/RepositoryCommentsClient.cs @@ -156,23 +156,5 @@ public Task Delete(string owner, string name, int number) return ApiConnection.Delete(ApiUrls.CommitComment(owner, name, number)); } - - /// - /// Creates a reaction for specified Commit Comment - /// - /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment - /// The owner of the repository - /// The name of the repository - /// The comment id - /// The reaction for - /// - public Task CreateReaction(string owner, string name, int number, NewReaction reaction) - { - Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - Ensure.ArgumentNotNull(reaction, "reaction"); - - return ApiConnection.Post(ApiUrls.CommitCommentReaction(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); - } } } From c536b85ebf984faca3c60f39d4f2f55de37be030 Mon Sep 17 00:00:00 2001 From: lrz-hal Date: Mon, 30 May 2016 16:19:54 +0200 Subject: [PATCH 23/65] Check null for newReaction --- Octokit.Tests/Clients/ReactionsClientTests.cs | 1 + .../Reactive/ObservableReactionsClientTests.cs | 17 +++-------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/Octokit.Tests/Clients/ReactionsClientTests.cs b/Octokit.Tests/Clients/ReactionsClientTests.cs index bfe37b3b26..5f838c8b4f 100644 --- a/Octokit.Tests/Clients/ReactionsClientTests.cs +++ b/Octokit.Tests/Clients/ReactionsClientTests.cs @@ -32,6 +32,7 @@ public async Task EnsuresArgumentsNotNull() await Assert.ThrowsAsync(() => client.CommitComments.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); await Assert.ThrowsAsync(() => client.CommitComments.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); await Assert.ThrowsAsync(() => client.CommitComments.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.CommitComments.CreateReaction("owner", "name", 1, null)); } } diff --git a/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs b/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs index ebaf6b2fe5..845d7bc1d0 100644 --- a/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs @@ -31,12 +31,13 @@ public void EnsuresArgumentsNotNull() Assert.Throws(() => client.CommitComments.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); Assert.Throws(() => client.CommitComments.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); Assert.Throws(() => client.CommitComments.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => client.CommitComments.CreateReaction("owner", "name", 1, null)); } } - + public class TheCreateMethod { - [Fact] + [Fact] public void RequestsCorrectUrl() { var githubClient = Substitute.For(); @@ -45,18 +46,6 @@ public void RequestsCorrectUrl() client.CommitComments.CreateReaction("fake", "repo", 1, newReaction); githubClient.Received().Reaction.CommitComments.CreateReaction("fake", "repo", 1, newReaction); - } - - [Fact] - public void EnsuresArgumentsNotNull() - { - var githubClient = Substitute.For(); - var client = new ObservableReactionsClient(githubClient); - - Assert.Throws(() => client.CommitComments.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => client.CommitComments.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => client.CommitComments.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => client.CommitComments.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); } } } From 10fe3cd7c9e1904a6541edfe27127ac0c1d8f35d Mon Sep 17 00:00:00 2001 From: lrz-hal Date: Mon, 30 May 2016 17:01:45 +0200 Subject: [PATCH 24/65] create unit tests for CommitCommentReactionClient --- ...cs => CommitCommentReactionClientTests.cs} | 16 ++++-- Octokit.Tests/Octokit.Tests.csproj | 4 +- ...ervableCommitCommentReactionClientTests.cs | 56 +++++++++++++++++++ .../ObservableReactionsClientTests.cs | 54 ------------------ 4 files changed, 69 insertions(+), 61 deletions(-) rename Octokit.Tests/Clients/{ReactionsClientTests.cs => CommitCommentReactionClientTests.cs} (87%) create mode 100644 Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs delete mode 100644 Octokit.Tests/Reactive/ObservableReactionsClientTests.cs diff --git a/Octokit.Tests/Clients/ReactionsClientTests.cs b/Octokit.Tests/Clients/CommitCommentReactionClientTests.cs similarity index 87% rename from Octokit.Tests/Clients/ReactionsClientTests.cs rename to Octokit.Tests/Clients/CommitCommentReactionClientTests.cs index 5f838c8b4f..8f7087a03c 100644 --- a/Octokit.Tests/Clients/ReactionsClientTests.cs +++ b/Octokit.Tests/Clients/CommitCommentReactionClientTests.cs @@ -1,14 +1,21 @@ using NSubstitute; -using Octokit; -using Octokit.Tests; using System; using System.Threading.Tasks; using Xunit; -public class ReactionsClientTests +namespace Octokit.Tests.Clients { - public class CommitComments + public class CommitCommentReactionClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new CommitCommentReactionClient(null)); + } + } + public class TheGetAllMethod { [Fact] @@ -53,4 +60,3 @@ public void RequestsCorrectUrl() } } } - diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 72afce19ba..41c611c2da 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -85,6 +85,7 @@ + @@ -93,7 +94,6 @@ - @@ -207,9 +207,9 @@ + - diff --git a/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs b/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs new file mode 100644 index 0000000000..3cbb86dee4 --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs @@ -0,0 +1,56 @@ +using NSubstitute; +using Octokit.Reactive; +using System; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableCommitCommentReactionClientTests + { + public class TheGetAllMethod + { + private readonly IGitHubClient _githubClient; + private readonly IObservableReactionsClient _client; + private const string owner = "owner"; + private const string name = "name"; + + public TheGetAllMethod() + { + _githubClient = Substitute.For(); + _client = new ObservableReactionsClient(_githubClient); + } + + [Fact] + public void RequestsCorrectUrl() + { + _client.CommitComments.GetAll("fake", "repo", 42); + _githubClient.Received().Reaction.CommitComments.GetAll("fake", "repo", 42); + } + + [Fact] + public void EnsuresArgumentsNotNull() + { + + Assert.Throws(() => _client.CommitComments.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.CommitComments.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.CommitComments.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.CommitComments.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.CommitComments.CreateReaction("owner", "name", 1, null)); + } + } + + public class TheCreateMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var githubClient = Substitute.For(); + var client = new ObservableReactionsClient(githubClient); + var newReaction = new NewReaction(ReactionType.Confused); + + client.CommitComments.CreateReaction("fake", "repo", 1, newReaction); + githubClient.Received().Reaction.CommitComments.CreateReaction("fake", "repo", 1, newReaction); + } + } + } +} diff --git a/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs b/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs deleted file mode 100644 index 845d7bc1d0..0000000000 --- a/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs +++ /dev/null @@ -1,54 +0,0 @@ -using NSubstitute; -using Octokit.Reactive; -using System; -using Xunit; - -namespace Octokit.Tests.Reactive -{ - public class ObservableReactionsClientTests - { - public class CommitComments - { - public class TheGetMethod - { - [Fact] - public void RequestsCorrectUrl() - { - var githubClient = Substitute.For(); - var client = new ObservableReactionsClient(githubClient); - - client.CommitComments.GetAll("fake", "repo", 42); - githubClient.Received().Reaction.CommitComments.GetAll("fake", "repo", 42); - } - - [Fact] - public void EnsuresArgumentsNotNull() - { - var githubClient = Substitute.For(); - var client = new ObservableReactionsClient(githubClient); - - Assert.Throws(() => client.CommitComments.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => client.CommitComments.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => client.CommitComments.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => client.CommitComments.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => client.CommitComments.CreateReaction("owner", "name", 1, null)); - } - } - - public class TheCreateMethod - { - [Fact] - public void RequestsCorrectUrl() - { - var githubClient = Substitute.For(); - var client = new ObservableReactionsClient(githubClient); - var newReaction = new NewReaction(ReactionType.Confused); - - client.CommitComments.CreateReaction("fake", "repo", 1, newReaction); - githubClient.Received().Reaction.CommitComments.CreateReaction("fake", "repo", 1, newReaction); - } - } - } - } -} - From 18946fb03fac802ef5362e46494988ba50eec7b1 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Tue, 31 May 2016 14:28:41 +0200 Subject: [PATCH 25/65] add IssuesReactionsClient; some fixes --- ...bservableCommitCommentsReactionsClient.cs} | 4 +- .../IObservableIssuesReactionsClient.cs | 28 +++++++++ .../Clients/IObservableReactionsClient.cs | 4 +- ...ObservableCommitCommentsReactionClient.cs} | 12 ++-- .../ObservableIssuesReactionsClient.cs | 54 ++++++++++++++++ .../Clients/ObservableReactionsClient.cs | 11 +++- Octokit.Reactive/Octokit.Reactive-Mono.csproj | 4 ++ .../Octokit.Reactive-MonoAndroid.csproj | 4 ++ .../Octokit.Reactive-Monotouch.csproj | 4 ++ Octokit.Reactive/Octokit.Reactive.csproj | 6 +- ... => CommitCommentsReactionsClientTests.cs} | 18 +++--- .../Clients/IssuesReactionsClientTests.cs | 62 +++++++++++++++++++ Octokit.Tests/Octokit.Tests.csproj | 3 +- ...ervableCommitCommentReactionClientTests.cs | 18 +++--- ...nt.cs => CommitCommentsReactionsClient.cs} | 10 +-- ...t.cs => ICommitCommentsReactionsClient.cs} | 4 +- Octokit/Clients/IIssuesReactionsClient.cs | 29 +++++++++ Octokit/Clients/IReactionsClient.cs | 12 +++- Octokit/Clients/IRepositoryCommentsClient.cs | 2 +- Octokit/Clients/IssuesReactionsClient.cs | 48 ++++++++++++++ Octokit/Clients/ReactionsClient.cs | 19 +++++- Octokit/Helpers/ApiUrls.cs | 14 ++++- Octokit/Octokit-Mono.csproj | 12 ++-- Octokit/Octokit-MonoAndroid.csproj | 10 +-- Octokit/Octokit-Monotouch.csproj | 10 +-- Octokit/Octokit-Portable.csproj | 10 +-- Octokit/Octokit-netcore45.csproj | 10 +-- Octokit/Octokit.csproj | 6 +- 28 files changed, 359 insertions(+), 69 deletions(-) rename Octokit.Reactive/Clients/{IObservableCommitCommentReactionClient.cs => IObservableCommitCommentsReactionsClient.cs} (89%) create mode 100644 Octokit.Reactive/Clients/IObservableIssuesReactionsClient.cs rename Octokit.Reactive/Clients/{ObservableCommitCommentReactionClient.cs => ObservableCommitCommentsReactionClient.cs} (82%) create mode 100644 Octokit.Reactive/Clients/ObservableIssuesReactionsClient.cs rename Octokit.Tests/Clients/{CommitCommentReactionClientTests.cs => CommitCommentsReactionsClientTests.cs} (76%) create mode 100644 Octokit.Tests/Clients/IssuesReactionsClientTests.cs rename Octokit/Clients/{CommitCommentReactionClient.cs => CommitCommentsReactionsClient.cs} (81%) rename Octokit/Clients/{ICommitCommentReactionClient.cs => ICommitCommentsReactionsClient.cs} (90%) create mode 100644 Octokit/Clients/IIssuesReactionsClient.cs create mode 100644 Octokit/Clients/IssuesReactionsClient.cs diff --git a/Octokit.Reactive/Clients/IObservableCommitCommentReactionClient.cs b/Octokit.Reactive/Clients/IObservableCommitCommentsReactionsClient.cs similarity index 89% rename from Octokit.Reactive/Clients/IObservableCommitCommentReactionClient.cs rename to Octokit.Reactive/Clients/IObservableCommitCommentsReactionsClient.cs index 967786cf5b..a277900035 100644 --- a/Octokit.Reactive/Clients/IObservableCommitCommentReactionClient.cs +++ b/Octokit.Reactive/Clients/IObservableCommitCommentsReactionsClient.cs @@ -2,7 +2,7 @@ namespace Octokit.Reactive { - public interface IObservableCommitCommentReactionClient + public interface IObservableCommitCommentsReactionsClient { /// /// Creates a reaction for an specified Commit Comment @@ -11,7 +11,7 @@ public interface IObservableCommitCommentReactionClient /// The owner of the repository /// The name of the repository /// The comment id - /// The reaction for + /// The reaction to create /// IObservable CreateReaction(string owner, string name, int number, NewReaction reaction); diff --git a/Octokit.Reactive/Clients/IObservableIssuesReactionsClient.cs b/Octokit.Reactive/Clients/IObservableIssuesReactionsClient.cs new file mode 100644 index 0000000000..f4982598b9 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableIssuesReactionsClient.cs @@ -0,0 +1,28 @@ +using System; + +namespace Octokit.Reactive +{ + public interface IObservableIssuesReactionsClient + { + /// + /// Creates a reaction for an specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#create-reaction-for-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue id + /// The reaction to create + /// + IObservable CreateReaction(string owner, string name, int number, NewReaction reaction); + + /// + /// List reactions for a specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#list-reactions-for-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue id + /// + IObservable GetAll(string owner, string name, int number); + } +} diff --git a/Octokit.Reactive/Clients/IObservableReactionsClient.cs b/Octokit.Reactive/Clients/IObservableReactionsClient.cs index f10da10886..4ac7125ebb 100644 --- a/Octokit.Reactive/Clients/IObservableReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableReactionsClient.cs @@ -2,6 +2,8 @@ { public interface IObservableReactionsClient { - IObservableCommitCommentReactionClient CommitComments { get; } + IObservableCommitCommentsReactionsClient CommitComment { get; } + + IObservableIssuesReactionsClient Issue { get; } } } diff --git a/Octokit.Reactive/Clients/ObservableCommitCommentReactionClient.cs b/Octokit.Reactive/Clients/ObservableCommitCommentsReactionClient.cs similarity index 82% rename from Octokit.Reactive/Clients/ObservableCommitCommentReactionClient.cs rename to Octokit.Reactive/Clients/ObservableCommitCommentsReactionClient.cs index 6b632fced0..8b31913269 100644 --- a/Octokit.Reactive/Clients/ObservableCommitCommentReactionClient.cs +++ b/Octokit.Reactive/Clients/ObservableCommitCommentsReactionClient.cs @@ -4,16 +4,16 @@ namespace Octokit.Reactive { - public class ObservableCommitCommentReactionClient : IObservableCommitCommentReactionClient + public class ObservableCommitCommentsReactionClient : IObservableCommitCommentsReactionsClient { - readonly ICommitCommentReactionClient _client; + readonly ICommitCommentsReactionsClient _client; readonly IConnection _connection; - public ObservableCommitCommentReactionClient(IGitHubClient client) + public ObservableCommitCommentsReactionClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); - _client = client.Reaction.CommitComments; + _client = client.Reaction.CommitComment; _connection = client.Connection; } @@ -24,7 +24,7 @@ public ObservableCommitCommentReactionClient(IGitHubClient client) /// The owner of the repository /// The name of the repository /// The comment id - /// The reaction for + /// The reaction to create /// public IObservable CreateReaction(string owner, string name, int number, NewReaction reaction) { @@ -48,7 +48,7 @@ public IObservable GetAll(string owner, string name, int number) Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return _connection.GetAndFlattenAllPages(ApiUrls.CommitCommentReaction(owner, name, number)); + return _connection.GetAndFlattenAllPages(ApiUrls.CommitCommentReactions(owner, name, number)); } } } diff --git a/Octokit.Reactive/Clients/ObservableIssuesReactionsClient.cs b/Octokit.Reactive/Clients/ObservableIssuesReactionsClient.cs new file mode 100644 index 0000000000..04f2146871 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableIssuesReactionsClient.cs @@ -0,0 +1,54 @@ +using Octokit.Reactive.Internal; +using System; +using System.Reactive.Threading.Tasks; + +namespace Octokit.Reactive +{ + public class ObservableIssuesReactionsClient : IObservableIssuesReactionsClient + { + readonly IIssuesReactionsClient _client; + readonly IConnection _connection; + + public ObservableIssuesReactionsClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, "client"); + + _client = client.Reaction.Issue; + _connection = client.Connection; + } + + /// + /// Creates a reaction for a specified Issue + /// + /// http://developer.github.com/v3/repos/comments/#create-reaction-for-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue id + /// The reaction to create + /// + public IObservable CreateReaction(string owner, string name, int number, NewReaction reaction) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(reaction, "reaction"); + + return _client.CreateReaction(owner, name, number, reaction).ToObservable(); + } + + /// + /// List reactions for a specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#list-reactions-for-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// + public IObservable GetAll(string owner, string name, int number) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return _connection.GetAndFlattenAllPages(ApiUrls.IssueReactions(owner, name, number)); + } + } +} diff --git a/Octokit.Reactive/Clients/ObservableReactionsClient.cs b/Octokit.Reactive/Clients/ObservableReactionsClient.cs index b94bc723ee..1f4ed3fbf6 100644 --- a/Octokit.Reactive/Clients/ObservableReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableReactionsClient.cs @@ -1,4 +1,6 @@ -namespace Octokit.Reactive +using System; + +namespace Octokit.Reactive { public class ObservableReactionsClient : IObservableReactionsClient { @@ -6,9 +8,12 @@ public ObservableReactionsClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); - CommitComments = new ObservableCommitCommentReactionClient(client); + CommitComment = new ObservableCommitCommentsReactionClient(client); + Issue = new ObservableIssuesReactionsClient(client); } - public IObservableCommitCommentReactionClient CommitComments { get; private set; } + public IObservableCommitCommentsReactionsClient CommitComment { get; private set; } + + public IObservableIssuesReactionsClient Issue { get; private set; } } } diff --git a/Octokit.Reactive/Octokit.Reactive-Mono.csproj b/Octokit.Reactive/Octokit.Reactive-Mono.csproj index 08f0a67b82..8c0e0bcfc8 100644 --- a/Octokit.Reactive/Octokit.Reactive-Mono.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Mono.csproj @@ -186,6 +186,10 @@ + + + + diff --git a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj index e2b2f8d5ed..fb3396269a 100644 --- a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj +++ b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj @@ -194,6 +194,10 @@ + + + + diff --git a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj index 625fcdc11e..6fb59a7a74 100644 --- a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj @@ -190,6 +190,10 @@ + + + + diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index f3bfa18f35..ab9b6c20ce 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -90,7 +90,8 @@ - + + @@ -101,7 +102,8 @@ - + + diff --git a/Octokit.Tests/Clients/CommitCommentReactionClientTests.cs b/Octokit.Tests/Clients/CommitCommentsReactionsClientTests.cs similarity index 76% rename from Octokit.Tests/Clients/CommitCommentReactionClientTests.cs rename to Octokit.Tests/Clients/CommitCommentsReactionsClientTests.cs index 8f7087a03c..e8028b1591 100644 --- a/Octokit.Tests/Clients/CommitCommentReactionClientTests.cs +++ b/Octokit.Tests/Clients/CommitCommentsReactionsClientTests.cs @@ -5,14 +5,14 @@ namespace Octokit.Tests.Clients { - public class CommitCommentReactionClientTests + public class CommitCommentsReactionsClientTests { public class TheCtor { [Fact] public void EnsuresNonNullArguments() { - Assert.Throws(() => new CommitCommentReactionClient(null)); + Assert.Throws(() => new CommitCommentsReactionsClient(null)); } } @@ -24,7 +24,7 @@ public async Task RequestsCorrectUrl() var connection = Substitute.For(); var client = new ReactionsClient(connection); - client.CommitComments.GetAll("fake", "repo", 42); + client.CommitComment.GetAll("fake", "repo", 42); connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), "application/vnd.github.squirrel-girl-preview"); } @@ -35,11 +35,11 @@ public async Task EnsuresArgumentsNotNull() var connection = Substitute.For(); var client = new ReactionsClient(connection); - await Assert.ThrowsAsync(() => client.CommitComments.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.CommitComments.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.CommitComments.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.CommitComments.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.CommitComments.CreateReaction("owner", "name", 1, null)); + await Assert.ThrowsAsync(() => client.CommitComment.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.CommitComment.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.CommitComment.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.CommitComment.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.CommitComment.CreateReaction("owner", "name", 1, null)); } } @@ -53,7 +53,7 @@ public void RequestsCorrectUrl() var connection = Substitute.For(); var client = new ReactionsClient(connection); - client.CommitComments.CreateReaction("fake", "repo", 1, newReaction); + client.CommitComment.CreateReaction("fake", "repo", 1, newReaction); connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), Arg.Any(), "application/vnd.github.squirrel-girl-preview"); } diff --git a/Octokit.Tests/Clients/IssuesReactionsClientTests.cs b/Octokit.Tests/Clients/IssuesReactionsClientTests.cs new file mode 100644 index 0000000000..2a4c3c8e47 --- /dev/null +++ b/Octokit.Tests/Clients/IssuesReactionsClientTests.cs @@ -0,0 +1,62 @@ +using NSubstitute; +using System; +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class IssuesReactionsClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new CommitCommentsReactionsClient(null)); + } + } + + public class TheGetAllMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ReactionsClient(connection); + + client.CommitComment.GetAll("fake", "repo", 42); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/1/reactions"), "application/vnd.github.squirrel-girl-preview"); + } + + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var connection = Substitute.For(); + var client = new ReactionsClient(connection); + + await Assert.ThrowsAsync(() => client.Issue.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.Issue.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.Issue.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.Issue.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.Issue.CreateReaction("owner", "name", 1, null)); + } + } + + public class TheCreateMethod + { + [Fact] + public void RequestsCorrectUrl() + { + NewReaction newReaction = new NewReaction(ReactionType.Heart); + + var connection = Substitute.For(); + var client = new ReactionsClient(connection); + + client.CommitComment.CreateReaction("fake", "repo", 1, newReaction); + + connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/1/reactions"), Arg.Any(), "application/vnd.github.squirrel-girl-preview"); + } + } + } +} diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 41c611c2da..87c1ed5bde 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -85,7 +85,8 @@ - + + diff --git a/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs b/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs index 3cbb86dee4..cd23ef1555 100644 --- a/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs @@ -23,19 +23,19 @@ public TheGetAllMethod() [Fact] public void RequestsCorrectUrl() { - _client.CommitComments.GetAll("fake", "repo", 42); - _githubClient.Received().Reaction.CommitComments.GetAll("fake", "repo", 42); + _client.CommitComment.GetAll("fake", "repo", 42); + _githubClient.Received().Reaction.CommitComment.GetAll("fake", "repo", 42); } [Fact] public void EnsuresArgumentsNotNull() { - Assert.Throws(() => _client.CommitComments.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => _client.CommitComments.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => _client.CommitComments.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => _client.CommitComments.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => _client.CommitComments.CreateReaction("owner", "name", 1, null)); + Assert.Throws(() => _client.CommitComment.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.CommitComment.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.CommitComment.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.CommitComment.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.CommitComment.CreateReaction("owner", "name", 1, null)); } } @@ -48,8 +48,8 @@ public void RequestsCorrectUrl() var client = new ObservableReactionsClient(githubClient); var newReaction = new NewReaction(ReactionType.Confused); - client.CommitComments.CreateReaction("fake", "repo", 1, newReaction); - githubClient.Received().Reaction.CommitComments.CreateReaction("fake", "repo", 1, newReaction); + client.CommitComment.CreateReaction("fake", "repo", 1, newReaction); + githubClient.Received().Reaction.CommitComment.CreateReaction("fake", "repo", 1, newReaction); } } } diff --git a/Octokit/Clients/CommitCommentReactionClient.cs b/Octokit/Clients/CommitCommentsReactionsClient.cs similarity index 81% rename from Octokit/Clients/CommitCommentReactionClient.cs rename to Octokit/Clients/CommitCommentsReactionsClient.cs index 2351132434..f81e960c58 100644 --- a/Octokit/Clients/CommitCommentReactionClient.cs +++ b/Octokit/Clients/CommitCommentsReactionsClient.cs @@ -3,9 +3,9 @@ namespace Octokit { - public class CommitCommentReactionClient : ApiClient, ICommitCommentReactionClient + public class CommitCommentsReactionsClient : ApiClient, ICommitCommentsReactionsClient { - public CommitCommentReactionClient(IApiConnection apiConnection) + public CommitCommentsReactionsClient(IApiConnection apiConnection) : base(apiConnection) { } @@ -17,7 +17,7 @@ public CommitCommentReactionClient(IApiConnection apiConnection) /// The owner of the repository /// The name of the repository /// The comment id - /// The reaction for + /// The reaction to create /// public Task CreateReaction(string owner, string name, int number, NewReaction reaction) { @@ -25,7 +25,7 @@ public Task CreateReaction(string owner, string name, int number, NewR Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(reaction, "reaction"); - return ApiConnection.Post(ApiUrls.CommitCommentReaction(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); + return ApiConnection.Post(ApiUrls.CommitCommentReactions(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); } /// @@ -41,7 +41,7 @@ public Task> GetAll(string owner, string name, int numbe Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return ApiConnection.GetAll(ApiUrls.CommitCommentReaction(owner, name, number), AcceptHeaders.ReactionsPreview); + return ApiConnection.GetAll(ApiUrls.CommitCommentReactions(owner, name, number), AcceptHeaders.ReactionsPreview); } } } diff --git a/Octokit/Clients/ICommitCommentReactionClient.cs b/Octokit/Clients/ICommitCommentsReactionsClient.cs similarity index 90% rename from Octokit/Clients/ICommitCommentReactionClient.cs rename to Octokit/Clients/ICommitCommentsReactionsClient.cs index c3865f1096..52af4ed824 100644 --- a/Octokit/Clients/ICommitCommentReactionClient.cs +++ b/Octokit/Clients/ICommitCommentsReactionsClient.cs @@ -3,7 +3,7 @@ namespace Octokit { - public interface ICommitCommentReactionClient + public interface ICommitCommentsReactionsClient { /// /// Creates a reaction for an specified Commit Comment @@ -12,7 +12,7 @@ public interface ICommitCommentReactionClient /// The owner of the repository /// The name of the repository /// The comment id - /// The reaction for + /// The reaction to create /// Task CreateReaction(string owner, string name, int number, NewReaction reaction); diff --git a/Octokit/Clients/IIssuesReactionsClient.cs b/Octokit/Clients/IIssuesReactionsClient.cs new file mode 100644 index 0000000000..d62a738cdf --- /dev/null +++ b/Octokit/Clients/IIssuesReactionsClient.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + public interface IIssuesReactionsClient + { + /// + /// Get all reactions for an specified Issue + /// + /// http://developer.github.com/v3/repos/comments/#list-reactions-for-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue id + /// + Task> GetAll(string owner, string name, int number); + + /// + /// Creates a reaction for an specified Issue + /// + /// http://developer.github.com/v3/repos/comments/#create-reaction-for-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue id + /// The reaction to create + /// + Task CreateReaction(string owner, string name, int number, NewReaction reaction); + } +} diff --git a/Octokit/Clients/IReactionsClient.cs b/Octokit/Clients/IReactionsClient.cs index c71a349655..ef610bcd86 100644 --- a/Octokit/Clients/IReactionsClient.cs +++ b/Octokit/Clients/IReactionsClient.cs @@ -9,11 +9,19 @@ public interface IReactionsClient { /// - /// Access GitHub's Reactions API. + /// Access GitHub's Reactions API for Commit Comments. /// /// /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// - ICommitCommentReactionClient CommitComments { get; } + ICommitCommentsReactionsClient CommitComment { get; } + + /// + /// Access GitHub's Reactions API for Issues. + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ + /// + IIssuesReactionsClient Issue { get; } } } diff --git a/Octokit/Clients/IRepositoryCommentsClient.cs b/Octokit/Clients/IRepositoryCommentsClient.cs index 840d36c275..f378dafe88 100644 --- a/Octokit/Clients/IRepositoryCommentsClient.cs +++ b/Octokit/Clients/IRepositoryCommentsClient.cs @@ -94,6 +94,6 @@ public interface IRepositoryCommentsClient /// The name of the repository /// The comment id /// - Task Delete(string owner, string name, int number); + Task Delete(string owner, string name, int number); } } diff --git a/Octokit/Clients/IssuesReactionsClient.cs b/Octokit/Clients/IssuesReactionsClient.cs new file mode 100644 index 0000000000..6d7e2d8de7 --- /dev/null +++ b/Octokit/Clients/IssuesReactionsClient.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + public class IssuesReactionsClient : ApiClient, IIssuesReactionsClient + { + public IssuesReactionsClient(IApiConnection apiConnection) + : base(apiConnection) + { + } + + /// + /// Creates a reaction for an specified Issue + /// + /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The issue id + /// The reaction to create + /// + public Task CreateReaction(string owner, string name, int number, NewReaction reaction) + { + Ensure.ArgumentNotNull(owner, "owner"); + Ensure.ArgumentNotNull(name, "name"); + Ensure.ArgumentNotNull(reaction, "reaction"); + + return ApiConnection.Post(ApiUrls.IssueReactions(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); + } + + /// + /// Get all reactions for an specified Issue + /// + /// http://developer.github.com/v3/repos/comments/#list-reactions-for-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The issue id + /// + public Task> GetAll(string owner, string name, int number) + { + Ensure.ArgumentNotNull(owner, "owner"); + Ensure.ArgumentNotNull(name, "name"); + + return ApiConnection.GetAll(ApiUrls.IssueReactions(owner, name, number), AcceptHeaders.ReactionsPreview); + } + } +} diff --git a/Octokit/Clients/ReactionsClient.cs b/Octokit/Clients/ReactionsClient.cs index 6924942eb5..8bd7c57514 100644 --- a/Octokit/Clients/ReactionsClient.cs +++ b/Octokit/Clients/ReactionsClient.cs @@ -9,9 +9,24 @@ public class ReactionsClient : ApiClient, IReactionsClient public ReactionsClient(IApiConnection apiConnection) : base(apiConnection) { - CommitComments = new CommitCommentReactionClient(apiConnection); + CommitComment = new CommitCommentsReactionsClient(apiConnection); + Issue = new IssuesReactionsClient(apiConnection); } - public ICommitCommentReactionClient CommitComments { get; private set; } + /// + /// Access GitHub's Reactions API for Commit Comments. + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ + /// + public ICommitCommentsReactionsClient CommitComment { get; private set; } + + /// + /// Access GitHub's Reactions API for Issues. + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ + /// + public IIssuesReactionsClient Issue { get; private set; } } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 20d730aede..c65aadb58b 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -316,6 +316,18 @@ 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 reaction of an specified issue. + /// + /// The owner of the repository + /// The name of the repository + /// The issue number + /// + public static Uri IssueReactions(string owner, string name, int number) + { + return "repos/{0}/{1}/issues/{2}/reactions".FormatUri(owner, name, number); + } + /// /// Returns the for the comments for all issues in a specific repo. /// @@ -393,7 +405,7 @@ public static Uri CommitComments(string owner, string name) /// The name of the repository /// The comment number /// - public static Uri CommitCommentReaction(string owner, string name, int number) + public static Uri CommitCommentReactions(string owner, string name, int number) { return "repos/{0}/{1}/comments/{2}/reactions".FormatUri(owner, name, number); } diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index ae3e80f4d4..9911e5b201 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -467,11 +467,13 @@ - - - - - + + + + + + + \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index 9fb7fc9f0f..6fcb0cf607 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -479,10 +479,12 @@ - - - - + + + + + + \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index 9b4e968a9d..214aae4741 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -475,10 +475,12 @@ - - - - + + + + + + diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj index ab755f2679..8d830ad5a4 100644 --- a/Octokit/Octokit-Portable.csproj +++ b/Octokit/Octokit-Portable.csproj @@ -465,10 +465,12 @@ - - - - + + + + + + diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index 91e377ed4d..b92c367dab 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -471,11 +471,13 @@ - - + - - + + + + + diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index e3545ae95e..c46b0aa76e 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -58,7 +58,9 @@ Properties\SolutionInfo.cs - + + + @@ -86,7 +88,7 @@ - + From c9fdb451147737c817c2cb837db72d68ae51f36f Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 1 Jun 2016 08:50:42 +0200 Subject: [PATCH 26/65] set singular on reaction clients --- ...ient.cs => IObservableCommitCommentReactionsClient.cs} | 2 +- ...ctionsClient.cs => IObservableIssueReactionsClient.cs} | 2 +- Octokit.Reactive/Clients/IObservableReactionsClient.cs | 4 ++-- ...lient.cs => ObservableCommitCommentReactionsClient.cs} | 6 +++--- ...actionsClient.cs => ObservableIssueReactionsClient.cs} | 6 +++--- Octokit.Reactive/Clients/ObservableReactionsClient.cs | 8 ++++---- Octokit.Reactive/Octokit.Reactive-Mono.csproj | 4 ++++ Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj | 4 ++++ Octokit.Reactive/Octokit.Reactive-Monotouch.csproj | 4 ++++ Octokit.Reactive/Octokit.Reactive.csproj | 8 ++++---- .../Clients/CommitCommentsReactionsClientTests.cs | 2 +- Octokit.Tests/Clients/IssuesReactionsClientTests.cs | 2 +- ...ReactionsClient.cs => CommitCommentReactionsClient.cs} | 4 ++-- ...eactionsClient.cs => ICommitCommentReactionsClient.cs} | 2 +- ...IIssuesReactionsClient.cs => IIssueReactionsClient.cs} | 2 +- Octokit/Clients/IReactionsClient.cs | 4 ++-- .../{IssuesReactionsClient.cs => IssueReactionsClient.cs} | 4 ++-- Octokit/Clients/ReactionsClient.cs | 8 ++++---- Octokit/Octokit-Mono.csproj | 8 ++++---- Octokit/Octokit-MonoAndroid.csproj | 8 ++++---- Octokit/Octokit-Monotouch.csproj | 8 ++++---- Octokit/Octokit-Portable.csproj | 8 ++++---- Octokit/Octokit-netcore45.csproj | 8 ++++---- Octokit/Octokit.csproj | 8 ++++---- 24 files changed, 68 insertions(+), 56 deletions(-) rename Octokit.Reactive/Clients/{IObservableCommitCommentsReactionsClient.cs => IObservableCommitCommentReactionsClient.cs} (95%) rename Octokit.Reactive/Clients/{IObservableIssuesReactionsClient.cs => IObservableIssueReactionsClient.cs} (95%) rename Octokit.Reactive/Clients/{ObservableCommitCommentsReactionClient.cs => ObservableCommitCommentReactionsClient.cs} (90%) rename Octokit.Reactive/Clients/{ObservableIssuesReactionsClient.cs => ObservableIssueReactionsClient.cs} (90%) rename Octokit/Clients/{CommitCommentsReactionsClient.cs => CommitCommentReactionsClient.cs} (92%) rename Octokit/Clients/{ICommitCommentsReactionsClient.cs => ICommitCommentReactionsClient.cs} (96%) rename Octokit/Clients/{IIssuesReactionsClient.cs => IIssueReactionsClient.cs} (96%) rename Octokit/Clients/{IssuesReactionsClient.cs => IssueReactionsClient.cs} (92%) diff --git a/Octokit.Reactive/Clients/IObservableCommitCommentsReactionsClient.cs b/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs similarity index 95% rename from Octokit.Reactive/Clients/IObservableCommitCommentsReactionsClient.cs rename to Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs index a277900035..dfa5141fa2 100644 --- a/Octokit.Reactive/Clients/IObservableCommitCommentsReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs @@ -2,7 +2,7 @@ namespace Octokit.Reactive { - public interface IObservableCommitCommentsReactionsClient + public interface IObservableCommitCommentReactionsClient { /// /// Creates a reaction for an specified Commit Comment diff --git a/Octokit.Reactive/Clients/IObservableIssuesReactionsClient.cs b/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs similarity index 95% rename from Octokit.Reactive/Clients/IObservableIssuesReactionsClient.cs rename to Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs index f4982598b9..3f7e79557c 100644 --- a/Octokit.Reactive/Clients/IObservableIssuesReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs @@ -2,7 +2,7 @@ namespace Octokit.Reactive { - public interface IObservableIssuesReactionsClient + public interface IObservableIssueReactionsClient { /// /// Creates a reaction for an specified Commit Comment diff --git a/Octokit.Reactive/Clients/IObservableReactionsClient.cs b/Octokit.Reactive/Clients/IObservableReactionsClient.cs index 4ac7125ebb..c8da6f6f9d 100644 --- a/Octokit.Reactive/Clients/IObservableReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableReactionsClient.cs @@ -2,8 +2,8 @@ { public interface IObservableReactionsClient { - IObservableCommitCommentsReactionsClient CommitComment { get; } + IObservableCommitCommentReactionsClient CommitComment { get; } - IObservableIssuesReactionsClient Issue { get; } + IObservableIssueReactionsClient Issue { get; } } } diff --git a/Octokit.Reactive/Clients/ObservableCommitCommentsReactionClient.cs b/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs similarity index 90% rename from Octokit.Reactive/Clients/ObservableCommitCommentsReactionClient.cs rename to Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs index 8b31913269..99371ac62c 100644 --- a/Octokit.Reactive/Clients/ObservableCommitCommentsReactionClient.cs +++ b/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs @@ -4,12 +4,12 @@ namespace Octokit.Reactive { - public class ObservableCommitCommentsReactionClient : IObservableCommitCommentsReactionsClient + public class ObservableCommitCommentReactionsClient : IObservableCommitCommentReactionsClient { - readonly ICommitCommentsReactionsClient _client; + readonly ICommitCommentReactionsClient _client; readonly IConnection _connection; - public ObservableCommitCommentsReactionClient(IGitHubClient client) + public ObservableCommitCommentReactionsClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); diff --git a/Octokit.Reactive/Clients/ObservableIssuesReactionsClient.cs b/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs similarity index 90% rename from Octokit.Reactive/Clients/ObservableIssuesReactionsClient.cs rename to Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs index 04f2146871..b2b1dc3098 100644 --- a/Octokit.Reactive/Clients/ObservableIssuesReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs @@ -4,12 +4,12 @@ namespace Octokit.Reactive { - public class ObservableIssuesReactionsClient : IObservableIssuesReactionsClient + public class ObservableIssueReactionsClient : IObservableIssueReactionsClient { - readonly IIssuesReactionsClient _client; + readonly IIssueReactionsClient _client; readonly IConnection _connection; - public ObservableIssuesReactionsClient(IGitHubClient client) + public ObservableIssueReactionsClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); diff --git a/Octokit.Reactive/Clients/ObservableReactionsClient.cs b/Octokit.Reactive/Clients/ObservableReactionsClient.cs index 1f4ed3fbf6..dba8f7a4d6 100644 --- a/Octokit.Reactive/Clients/ObservableReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableReactionsClient.cs @@ -8,12 +8,12 @@ public ObservableReactionsClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); - CommitComment = new ObservableCommitCommentsReactionClient(client); - Issue = new ObservableIssuesReactionsClient(client); + CommitComment = new ObservableCommitCommentReactionsClient(client); + Issue = new ObservableIssueReactionsClient(client); } - public IObservableCommitCommentsReactionsClient CommitComment { get; private set; } + public IObservableCommitCommentReactionsClient CommitComment { get; private set; } - public IObservableIssuesReactionsClient Issue { get; private set; } + public IObservableIssueReactionsClient Issue { get; private set; } } } diff --git a/Octokit.Reactive/Octokit.Reactive-Mono.csproj b/Octokit.Reactive/Octokit.Reactive-Mono.csproj index 8c0e0bcfc8..2eae99e7c8 100644 --- a/Octokit.Reactive/Octokit.Reactive-Mono.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Mono.csproj @@ -190,6 +190,10 @@ + + + + diff --git a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj index fb3396269a..e311e3d8b4 100644 --- a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj +++ b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj @@ -198,6 +198,10 @@ + + + + diff --git a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj index 6fb59a7a74..700314d555 100644 --- a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj @@ -194,6 +194,10 @@ + + + + diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index ab9b6c20ce..732721c16b 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -90,8 +90,8 @@ - - + + @@ -102,8 +102,8 @@ - - + + diff --git a/Octokit.Tests/Clients/CommitCommentsReactionsClientTests.cs b/Octokit.Tests/Clients/CommitCommentsReactionsClientTests.cs index e8028b1591..97632bb135 100644 --- a/Octokit.Tests/Clients/CommitCommentsReactionsClientTests.cs +++ b/Octokit.Tests/Clients/CommitCommentsReactionsClientTests.cs @@ -12,7 +12,7 @@ public class TheCtor [Fact] public void EnsuresNonNullArguments() { - Assert.Throws(() => new CommitCommentsReactionsClient(null)); + Assert.Throws(() => new CommitCommentReactionsClient(null)); } } diff --git a/Octokit.Tests/Clients/IssuesReactionsClientTests.cs b/Octokit.Tests/Clients/IssuesReactionsClientTests.cs index 2a4c3c8e47..f8e9c156b9 100644 --- a/Octokit.Tests/Clients/IssuesReactionsClientTests.cs +++ b/Octokit.Tests/Clients/IssuesReactionsClientTests.cs @@ -12,7 +12,7 @@ public class TheCtor [Fact] public void EnsuresNonNullArguments() { - Assert.Throws(() => new CommitCommentsReactionsClient(null)); + Assert.Throws(() => new CommitCommentReactionsClient(null)); } } diff --git a/Octokit/Clients/CommitCommentsReactionsClient.cs b/Octokit/Clients/CommitCommentReactionsClient.cs similarity index 92% rename from Octokit/Clients/CommitCommentsReactionsClient.cs rename to Octokit/Clients/CommitCommentReactionsClient.cs index f81e960c58..7b19b4f038 100644 --- a/Octokit/Clients/CommitCommentsReactionsClient.cs +++ b/Octokit/Clients/CommitCommentReactionsClient.cs @@ -3,9 +3,9 @@ namespace Octokit { - public class CommitCommentsReactionsClient : ApiClient, ICommitCommentsReactionsClient + public class CommitCommentReactionsClient : ApiClient, ICommitCommentReactionsClient { - public CommitCommentsReactionsClient(IApiConnection apiConnection) + public CommitCommentReactionsClient(IApiConnection apiConnection) : base(apiConnection) { } diff --git a/Octokit/Clients/ICommitCommentsReactionsClient.cs b/Octokit/Clients/ICommitCommentReactionsClient.cs similarity index 96% rename from Octokit/Clients/ICommitCommentsReactionsClient.cs rename to Octokit/Clients/ICommitCommentReactionsClient.cs index 52af4ed824..ffe8e5e601 100644 --- a/Octokit/Clients/ICommitCommentsReactionsClient.cs +++ b/Octokit/Clients/ICommitCommentReactionsClient.cs @@ -3,7 +3,7 @@ namespace Octokit { - public interface ICommitCommentsReactionsClient + public interface ICommitCommentReactionsClient { /// /// Creates a reaction for an specified Commit Comment diff --git a/Octokit/Clients/IIssuesReactionsClient.cs b/Octokit/Clients/IIssueReactionsClient.cs similarity index 96% rename from Octokit/Clients/IIssuesReactionsClient.cs rename to Octokit/Clients/IIssueReactionsClient.cs index d62a738cdf..9868a2856d 100644 --- a/Octokit/Clients/IIssuesReactionsClient.cs +++ b/Octokit/Clients/IIssueReactionsClient.cs @@ -3,7 +3,7 @@ namespace Octokit { - public interface IIssuesReactionsClient + public interface IIssueReactionsClient { /// /// Get all reactions for an specified Issue diff --git a/Octokit/Clients/IReactionsClient.cs b/Octokit/Clients/IReactionsClient.cs index ef610bcd86..fc5ad5ecb4 100644 --- a/Octokit/Clients/IReactionsClient.cs +++ b/Octokit/Clients/IReactionsClient.cs @@ -14,7 +14,7 @@ public interface IReactionsClient /// /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// - ICommitCommentsReactionsClient CommitComment { get; } + ICommitCommentReactionsClient CommitComment { get; } /// /// Access GitHub's Reactions API for Issues. @@ -22,6 +22,6 @@ public interface IReactionsClient /// /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// - IIssuesReactionsClient Issue { get; } + IIssueReactionsClient Issue { get; } } } diff --git a/Octokit/Clients/IssuesReactionsClient.cs b/Octokit/Clients/IssueReactionsClient.cs similarity index 92% rename from Octokit/Clients/IssuesReactionsClient.cs rename to Octokit/Clients/IssueReactionsClient.cs index 6d7e2d8de7..12f5cfb064 100644 --- a/Octokit/Clients/IssuesReactionsClient.cs +++ b/Octokit/Clients/IssueReactionsClient.cs @@ -4,9 +4,9 @@ namespace Octokit { - public class IssuesReactionsClient : ApiClient, IIssuesReactionsClient + public class IssueReactionsClient : ApiClient, IIssueReactionsClient { - public IssuesReactionsClient(IApiConnection apiConnection) + public IssueReactionsClient(IApiConnection apiConnection) : base(apiConnection) { } diff --git a/Octokit/Clients/ReactionsClient.cs b/Octokit/Clients/ReactionsClient.cs index 8bd7c57514..7ef899d541 100644 --- a/Octokit/Clients/ReactionsClient.cs +++ b/Octokit/Clients/ReactionsClient.cs @@ -9,8 +9,8 @@ public class ReactionsClient : ApiClient, IReactionsClient public ReactionsClient(IApiConnection apiConnection) : base(apiConnection) { - CommitComment = new CommitCommentsReactionsClient(apiConnection); - Issue = new IssuesReactionsClient(apiConnection); + CommitComment = new CommitCommentReactionsClient(apiConnection); + Issue = new IssueReactionsClient(apiConnection); } /// @@ -19,7 +19,7 @@ public ReactionsClient(IApiConnection apiConnection) /// /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// - public ICommitCommentsReactionsClient CommitComment { get; private set; } + public ICommitCommentReactionsClient CommitComment { get; private set; } /// /// Access GitHub's Reactions API for Issues. @@ -27,6 +27,6 @@ public ReactionsClient(IApiConnection apiConnection) /// /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// - public IIssuesReactionsClient Issue { get; private set; } + public IIssueReactionsClient Issue { get; private set; } } } diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index 9911e5b201..656cbe6443 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -470,10 +470,10 @@ - - - - + + + + \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index 6fcb0cf607..d04b602155 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -481,10 +481,10 @@ - - - - + + + + \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index 214aae4741..e2d9466cb9 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -477,10 +477,10 @@ - - - - + + + + diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj index 8d830ad5a4..f39ff5fc72 100644 --- a/Octokit/Octokit-Portable.csproj +++ b/Octokit/Octokit-Portable.csproj @@ -467,10 +467,10 @@ - - - - + + + + diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index b92c367dab..b2036f6551 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -473,10 +473,10 @@ - - - - + + + + diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index c46b0aa76e..5521560289 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -58,9 +58,9 @@ Properties\SolutionInfo.cs - - - + + + @@ -88,7 +88,7 @@ - + From 53f61cda523fbb5827f8bbc8aa7eb142ffba293e Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 1 Jun 2016 09:12:31 +0200 Subject: [PATCH 27/65] fix method names for reaction clients --- .../IObservableCommitCommentReactionsClient.cs | 2 +- .../Clients/IObservableIssueReactionsClient.cs | 2 +- .../ObservableCommitCommentReactionsClient.cs | 4 ++-- .../Clients/ObservableIssueReactionsClient.cs | 4 ++-- ...Tests.cs => CommitCommentReactionsClientTests.cs} | 12 ++++++------ ...nsClientTests.cs => IssueReactionsClientTests.cs} | 12 ++++++------ Octokit.Tests/Octokit.Tests.csproj | 4 ++-- Octokit/Clients/CommitCommentReactionsClient.cs | 2 +- Octokit/Clients/ICommitCommentReactionsClient.cs | 2 +- Octokit/Clients/IIssueReactionsClient.cs | 2 +- Octokit/Clients/IssueReactionsClient.cs | 2 +- 11 files changed, 24 insertions(+), 24 deletions(-) rename Octokit.Tests/Clients/{CommitCommentsReactionsClientTests.cs => CommitCommentReactionsClientTests.cs} (80%) rename Octokit.Tests/Clients/{IssuesReactionsClientTests.cs => IssueReactionsClientTests.cs} (82%) diff --git a/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs b/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs index dfa5141fa2..0db4442c96 100644 --- a/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs @@ -13,7 +13,7 @@ public interface IObservableCommitCommentReactionsClient /// The comment id /// The reaction to create /// - IObservable CreateReaction(string owner, string name, int number, NewReaction reaction); + IObservable Create(string owner, string name, int number, NewReaction reaction); /// /// List reactions for a specified Commit Comment diff --git a/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs b/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs index 3f7e79557c..45488f5f95 100644 --- a/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs @@ -13,7 +13,7 @@ public interface IObservableIssueReactionsClient /// The issue id /// The reaction to create /// - IObservable CreateReaction(string owner, string name, int number, NewReaction reaction); + IObservable Create(string owner, string name, int number, NewReaction reaction); /// /// List reactions for a specified Commit Comment diff --git a/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs index 99371ac62c..cb95edac31 100644 --- a/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs @@ -26,13 +26,13 @@ public ObservableCommitCommentReactionsClient(IGitHubClient client) /// The comment id /// The reaction to create /// - public IObservable CreateReaction(string owner, string name, int number, NewReaction reaction) + public IObservable Create(string owner, string name, int number, NewReaction reaction) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(reaction, "reaction"); - return _client.CreateReaction(owner, name, number, reaction).ToObservable(); + return _client.Create(owner, name, number, reaction).ToObservable(); } /// diff --git a/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs b/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs index b2b1dc3098..ffa33fcf06 100644 --- a/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs @@ -26,13 +26,13 @@ public ObservableIssueReactionsClient(IGitHubClient client) /// The issue id /// The reaction to create /// - public IObservable CreateReaction(string owner, string name, int number, NewReaction reaction) + public IObservable Create(string owner, string name, int number, NewReaction reaction) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(reaction, "reaction"); - return _client.CreateReaction(owner, name, number, reaction).ToObservable(); + return _client.Create(owner, name, number, reaction).ToObservable(); } /// diff --git a/Octokit.Tests/Clients/CommitCommentsReactionsClientTests.cs b/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs similarity index 80% rename from Octokit.Tests/Clients/CommitCommentsReactionsClientTests.cs rename to Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs index 97632bb135..0263379ffc 100644 --- a/Octokit.Tests/Clients/CommitCommentsReactionsClientTests.cs +++ b/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs @@ -5,7 +5,7 @@ namespace Octokit.Tests.Clients { - public class CommitCommentsReactionsClientTests + public class CommitCommentReactionsClientTests { public class TheCtor { @@ -35,11 +35,11 @@ public async Task EnsuresArgumentsNotNull() var connection = Substitute.For(); var client = new ReactionsClient(connection); - await Assert.ThrowsAsync(() => client.CommitComment.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.CommitComment.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.CommitComment.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.CommitComment.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.CommitComment.CreateReaction("owner", "name", 1, null)); + await Assert.ThrowsAsync(() => client.CommitComment.Create(null, "name", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.CommitComment.Create("", "name", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.CommitComment.Create("owner", null, 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.CommitComment.Create("owner", "", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.CommitComment.Create("owner", "name", 1, null)); } } diff --git a/Octokit.Tests/Clients/IssuesReactionsClientTests.cs b/Octokit.Tests/Clients/IssueReactionsClientTests.cs similarity index 82% rename from Octokit.Tests/Clients/IssuesReactionsClientTests.cs rename to Octokit.Tests/Clients/IssueReactionsClientTests.cs index f8e9c156b9..22069d468c 100644 --- a/Octokit.Tests/Clients/IssuesReactionsClientTests.cs +++ b/Octokit.Tests/Clients/IssueReactionsClientTests.cs @@ -5,7 +5,7 @@ namespace Octokit.Tests.Clients { - public class IssuesReactionsClientTests + public class IssueReactionsClientTests { public class TheCtor { @@ -35,11 +35,11 @@ public async Task EnsuresArgumentsNotNull() var connection = Substitute.For(); var client = new ReactionsClient(connection); - await Assert.ThrowsAsync(() => client.Issue.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.Issue.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.Issue.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.Issue.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.Issue.CreateReaction("owner", "name", 1, null)); + await Assert.ThrowsAsync(() => client.Issue.Create(null, "name", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.Issue.Create("", "name", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.Issue.Create("owner", null, 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.Issue.Create("owner", "", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.Issue.Create("owner", "name", 1, null)); } } diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 87c1ed5bde..30d5ab71c5 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -85,8 +85,8 @@ - - + + diff --git a/Octokit/Clients/CommitCommentReactionsClient.cs b/Octokit/Clients/CommitCommentReactionsClient.cs index 7b19b4f038..da4ddc07ad 100644 --- a/Octokit/Clients/CommitCommentReactionsClient.cs +++ b/Octokit/Clients/CommitCommentReactionsClient.cs @@ -19,7 +19,7 @@ public CommitCommentReactionsClient(IApiConnection apiConnection) /// The comment id /// The reaction to create /// - public Task CreateReaction(string owner, string name, int number, NewReaction reaction) + public Task Create(string owner, string name, int number, NewReaction reaction) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); diff --git a/Octokit/Clients/ICommitCommentReactionsClient.cs b/Octokit/Clients/ICommitCommentReactionsClient.cs index ffe8e5e601..d4664ecc20 100644 --- a/Octokit/Clients/ICommitCommentReactionsClient.cs +++ b/Octokit/Clients/ICommitCommentReactionsClient.cs @@ -14,7 +14,7 @@ public interface ICommitCommentReactionsClient /// The comment id /// The reaction to create /// - Task CreateReaction(string owner, string name, int number, NewReaction reaction); + Task Create(string owner, string name, int number, NewReaction reaction); /// /// Get all reactions for a specified Commit Comment diff --git a/Octokit/Clients/IIssueReactionsClient.cs b/Octokit/Clients/IIssueReactionsClient.cs index 9868a2856d..208503bfd1 100644 --- a/Octokit/Clients/IIssueReactionsClient.cs +++ b/Octokit/Clients/IIssueReactionsClient.cs @@ -24,6 +24,6 @@ public interface IIssueReactionsClient /// The issue id /// The reaction to create /// - Task CreateReaction(string owner, string name, int number, NewReaction reaction); + Task Create(string owner, string name, int number, NewReaction reaction); } } diff --git a/Octokit/Clients/IssueReactionsClient.cs b/Octokit/Clients/IssueReactionsClient.cs index 12f5cfb064..f4e07714c4 100644 --- a/Octokit/Clients/IssueReactionsClient.cs +++ b/Octokit/Clients/IssueReactionsClient.cs @@ -20,7 +20,7 @@ public IssueReactionsClient(IApiConnection apiConnection) /// The issue id /// The reaction to create /// - public Task CreateReaction(string owner, string name, int number, NewReaction reaction) + public Task Create(string owner, string name, int number, NewReaction reaction) { Ensure.ArgumentNotNull(owner, "owner"); Ensure.ArgumentNotNull(name, "name"); From 17e613786aa9a8762da1aae9453ccc547201b93f Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 1 Jun 2016 09:27:12 +0200 Subject: [PATCH 28/65] add api url for IssueCommentReaction --- Octokit/Helpers/ApiUrls.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index c65aadb58b..05c88c40dd 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -363,6 +363,18 @@ public static Uri IssueComment(string owner, string name, int id) return "repos/{0}/{1}/issues/comments/{2}".FormatUri(owner, name, id); } + /// + /// Returns the for the reaction of an specified issue. + /// + /// The owner of the repository + /// The name of the repository + /// The comment number + /// + public static Uri IssueCommentReactions(string owner, string name, int number) + { + return "repos/{0}/{1}/issues/comment/{2}/reactions".FormatUri(owner, name, number); + } + /// /// Returns the for the specified comment. /// From eddf6023ed354572f67fdd0f6ee840dac157f14f Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 1 Jun 2016 09:46:00 +0200 Subject: [PATCH 29/65] add IssueCommentReactionsClient --- .../IObservableIssueCommentReactionsClient.cs | 28 ++++++++++ .../ObservableCommitCommentReactionsClient.cs | 2 +- .../ObservableIssueCommentReactionsClient.cs | 54 +++++++++++++++++++ .../Clients/ObservableIssueReactionsClient.cs | 2 +- Octokit.Reactive/Octokit.Reactive-Mono.csproj | 2 + .../Octokit.Reactive-MonoAndroid.csproj | 2 + .../Octokit.Reactive-Monotouch.csproj | 2 + Octokit.Reactive/Octokit.Reactive.csproj | 2 + .../Clients/IIssueCommentReactionsClient.cs | 29 ++++++++++ Octokit/Clients/IReactionsClient.cs | 8 +++ .../Clients/IssueCommentReactionsClient.cs | 48 +++++++++++++++++ Octokit/Clients/ReactionsClient.cs | 12 ++++- Octokit/Octokit-Mono.csproj | 4 +- Octokit/Octokit-MonoAndroid.csproj | 4 +- Octokit/Octokit-Monotouch.csproj | 4 +- Octokit/Octokit-Portable.csproj | 4 +- Octokit/Octokit-netcore45.csproj | 2 + Octokit/Octokit.csproj | 2 + 18 files changed, 204 insertions(+), 7 deletions(-) create mode 100644 Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs create mode 100644 Octokit/Clients/IIssueCommentReactionsClient.cs create mode 100644 Octokit/Clients/IssueCommentReactionsClient.cs diff --git a/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs b/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs new file mode 100644 index 0000000000..a04bd9edd0 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs @@ -0,0 +1,28 @@ +using System; + +namespace Octokit.Reactive +{ + public interface IObservableIssueCommentReactionsClient + { + /// + /// Creates a reaction for an specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#create-reaction-for-an-issue-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction to create + /// + IObservable Create(string owner, string name, int number, NewReaction reaction); + + /// + /// List reactions for a specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#list-reactions-for-an-issue-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// + IObservable GetAll(string owner, string name, int number); + } +} diff --git a/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs index cb95edac31..bfd12684b8 100644 --- a/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs @@ -48,7 +48,7 @@ public IObservable GetAll(string owner, string name, int number) Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return _connection.GetAndFlattenAllPages(ApiUrls.CommitCommentReactions(owner, name, number)); + return _connection.GetAndFlattenAllPages(ApiUrls.CommitCommentReactions(owner, name, number), AcceptHeaders.ReactionsPreview); } } } diff --git a/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs new file mode 100644 index 0000000000..833158f33d --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs @@ -0,0 +1,54 @@ +using Octokit.Reactive.Internal; +using System; +using System.Reactive.Threading.Tasks; + +namespace Octokit.Reactive +{ + public class ObservableIssueCommentReactionsClient : IObservableIssueCommentReactionsClient + { + readonly ICommitCommentReactionsClient _client; + readonly IConnection _connection; + + public ObservableIssueCommentReactionsClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, "client"); + + _client = client.Reaction.CommitComment; + _connection = client.Connection; + } + + /// + /// Creates a reaction for an specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#create-reaction-for-an-issue-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction to create + /// + public IObservable Create(string owner, string name, int number, NewReaction reaction) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(reaction, "reaction"); + + return _client.Create(owner, name, number, reaction).ToObservable(); + } + + /// + /// List reactions for a specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#list-reactions-for-an-issue-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// + public IObservable GetAll(string owner, string name, int number) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return _connection.GetAndFlattenAllPages(ApiUrls.IssueCommentReactions(owner, name, number), AcceptHeaders.ReactionsPreview); + } + } +} diff --git a/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs b/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs index ffa33fcf06..8246041c39 100644 --- a/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs @@ -48,7 +48,7 @@ public IObservable GetAll(string owner, string name, int number) Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return _connection.GetAndFlattenAllPages(ApiUrls.IssueReactions(owner, name, number)); + return _connection.GetAndFlattenAllPages(ApiUrls.IssueReactions(owner, name, number), AcceptHeaders.ReactionsPreview); } } } diff --git a/Octokit.Reactive/Octokit.Reactive-Mono.csproj b/Octokit.Reactive/Octokit.Reactive-Mono.csproj index 2eae99e7c8..8996d64c15 100644 --- a/Octokit.Reactive/Octokit.Reactive-Mono.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Mono.csproj @@ -194,6 +194,8 @@ + + diff --git a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj index e311e3d8b4..38d89c8f6a 100644 --- a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj +++ b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj @@ -202,6 +202,8 @@ + + diff --git a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj index 700314d555..bb68d1f02b 100644 --- a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj @@ -198,6 +198,8 @@ + + diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index 732721c16b..a63f8014d4 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -91,6 +91,7 @@ + @@ -103,6 +104,7 @@ + diff --git a/Octokit/Clients/IIssueCommentReactionsClient.cs b/Octokit/Clients/IIssueCommentReactionsClient.cs new file mode 100644 index 0000000000..298e9046a2 --- /dev/null +++ b/Octokit/Clients/IIssueCommentReactionsClient.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + public interface IIssueCommentReactionsClient + { + /// + /// Creates a reaction for an specified Issue Comment + /// + /// http://developer.github.com/v3/repos/comments/#create-reaction-for-an-issue-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction to create + /// + Task Create(string owner, string name, int number, NewReaction reaction); + + /// + /// Get all reactions for a specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#list-reactions-for-an-issue-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// + Task> GetAll(string owner, string name, int number); + } +} diff --git a/Octokit/Clients/IReactionsClient.cs b/Octokit/Clients/IReactionsClient.cs index fc5ad5ecb4..d22b83e1d0 100644 --- a/Octokit/Clients/IReactionsClient.cs +++ b/Octokit/Clients/IReactionsClient.cs @@ -23,5 +23,13 @@ public interface IReactionsClient /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// IIssueReactionsClient Issue { get; } + + /// + /// Access GitHub's Reactions API for Issue Comments. + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ + /// + IIssueCommentReactionsClient IssueComment { get; } } } diff --git a/Octokit/Clients/IssueCommentReactionsClient.cs b/Octokit/Clients/IssueCommentReactionsClient.cs new file mode 100644 index 0000000000..4ee050892d --- /dev/null +++ b/Octokit/Clients/IssueCommentReactionsClient.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + public class IssueCommentReactionsClient : ApiClient, IIssueCommentReactionsClient + { + public IssueCommentReactionsClient(IApiConnection apiConnection) + : base(apiConnection) + { + } + + /// + /// Creates a reaction for an specified Issue Comment + /// + /// http://developer.github.com/v3/repos/comments/#create-reaction-for-an-issue-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction to create + /// + public Task Create(string owner, string name, int number, NewReaction reaction) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(reaction, "reaction"); + + return ApiConnection.Post(ApiUrls.IssueCommentReactions(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); + } + + /// + /// Get all reactions for a specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#list-reactions-for-an-issue-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// + public Task> GetAll(string owner, string name, int number) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return ApiConnection.GetAll(ApiUrls.IssueCommentReactions(owner, name, number), AcceptHeaders.ReactionsPreview); + } + } +} diff --git a/Octokit/Clients/ReactionsClient.cs b/Octokit/Clients/ReactionsClient.cs index 7ef899d541..533642124a 100644 --- a/Octokit/Clients/ReactionsClient.cs +++ b/Octokit/Clients/ReactionsClient.cs @@ -1,4 +1,6 @@ -namespace Octokit +using System; + +namespace Octokit { public class ReactionsClient : ApiClient, IReactionsClient { @@ -28,5 +30,13 @@ public ReactionsClient(IApiConnection apiConnection) /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// public IIssueReactionsClient Issue { get; private set; } + + /// + /// Access GitHub's Reactions API for Issue Comments. + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ + /// + public IIssueCommentReactionsClient IssueComment { get; private set; } } } diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index 656cbe6443..5e46e53ced 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -469,11 +469,13 @@ - + + + \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index d04b602155..d9d8efbef3 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -480,11 +480,13 @@ - + + + \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index e2d9466cb9..3858e96f87 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -476,11 +476,13 @@ - + + + diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj index f39ff5fc72..1e93e924bb 100644 --- a/Octokit/Octokit-Portable.csproj +++ b/Octokit/Octokit-Portable.csproj @@ -466,11 +466,13 @@ - + + + diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index b2036f6551..43aa1886c7 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -478,6 +478,8 @@ + + diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 5521560289..3d3ca2fbd3 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -59,7 +59,9 @@ + + From b5a831c947ed79cebcd09cb47ad9e74d115abe0d Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 1 Jun 2016 10:01:27 +0200 Subject: [PATCH 30/65] extend GetAll Methods for AccepHeaders --- .../Clients/ObservableCommitCommentReactionsClient.cs | 2 +- .../Clients/ObservableIssueCommentReactionsClient.cs | 2 +- Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs index bfd12684b8..270c6d1093 100644 --- a/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs @@ -48,7 +48,7 @@ public IObservable GetAll(string owner, string name, int number) Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return _connection.GetAndFlattenAllPages(ApiUrls.CommitCommentReactions(owner, name, number), AcceptHeaders.ReactionsPreview); + return _connection.GetAndFlattenAllPages(ApiUrls.CommitCommentReactions(owner, name, number), null, AcceptHeaders.ReactionsPreview); } } } diff --git a/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs index 833158f33d..fef2c3c808 100644 --- a/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs @@ -48,7 +48,7 @@ public IObservable GetAll(string owner, string name, int number) Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return _connection.GetAndFlattenAllPages(ApiUrls.IssueCommentReactions(owner, name, number), AcceptHeaders.ReactionsPreview); + return _connection.GetAndFlattenAllPages(ApiUrls.IssueCommentReactions(owner, name, number), null, AcceptHeaders.ReactionsPreview); } } } diff --git a/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs b/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs index 8246041c39..ef93a5d20e 100644 --- a/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs @@ -48,7 +48,7 @@ public IObservable GetAll(string owner, string name, int number) Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return _connection.GetAndFlattenAllPages(ApiUrls.IssueReactions(owner, name, number), AcceptHeaders.ReactionsPreview); + return _connection.GetAndFlattenAllPages(ApiUrls.IssueReactions(owner, name, number), null, AcceptHeaders.ReactionsPreview); } } } From cd40b039324f8167c1e433ddb04b04a16c21ab35 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 1 Jun 2016 10:14:39 +0200 Subject: [PATCH 31/65] new unit tests for reaction clients --- .../CommitCommentReactionsClientTests.cs | 2 +- .../IssueCommentReactionsClientTests.cs | 62 +++++++++++++++++++ .../Clients/IssueReactionsClientTests.cs | 6 +- Octokit.Tests/Octokit.Tests.csproj | 1 + 4 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs diff --git a/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs b/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs index 0263379ffc..67750a3ef3 100644 --- a/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs +++ b/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs @@ -53,7 +53,7 @@ public void RequestsCorrectUrl() var connection = Substitute.For(); var client = new ReactionsClient(connection); - client.CommitComment.CreateReaction("fake", "repo", 1, newReaction); + client.CommitComment.Create("fake", "repo", 1, newReaction); connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), Arg.Any(), "application/vnd.github.squirrel-girl-preview"); } diff --git a/Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs b/Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs new file mode 100644 index 0000000000..027d3dfe18 --- /dev/null +++ b/Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs @@ -0,0 +1,62 @@ +using NSubstitute; +using System; +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class IssueCommentReactionsClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new IssueCommentReactionsClient(null)); + } + } + + public class TheGetAllMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ReactionsClient(connection); + + client.IssueComment.GetAll("fake", "repo", 42); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/1/reactions"), "application/vnd.github.squirrel-girl-preview"); + } + + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var connection = Substitute.For(); + var client = new ReactionsClient(connection); + + await Assert.ThrowsAsync(() => client.IssueComment.Create(null, "name", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.IssueComment.Create("", "name", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.IssueComment.Create("owner", null, 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.IssueComment.Create("owner", "", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.IssueComment.Create("owner", "name", 1, null)); + } + } + + public class TheCreateMethod + { + [Fact] + public void RequestsCorrectUrl() + { + NewReaction newReaction = new NewReaction(ReactionType.Heart); + + var connection = Substitute.For(); + var client = new ReactionsClient(connection); + + client.IssueComment.Create("fake", "repo", 1, newReaction); + + connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/1/reactions"), Arg.Any(), "application/vnd.github.squirrel-girl-preview"); + } + } + } +} diff --git a/Octokit.Tests/Clients/IssueReactionsClientTests.cs b/Octokit.Tests/Clients/IssueReactionsClientTests.cs index 22069d468c..d0565b907c 100644 --- a/Octokit.Tests/Clients/IssueReactionsClientTests.cs +++ b/Octokit.Tests/Clients/IssueReactionsClientTests.cs @@ -12,7 +12,7 @@ public class TheCtor [Fact] public void EnsuresNonNullArguments() { - Assert.Throws(() => new CommitCommentReactionsClient(null)); + Assert.Throws(() => new IssueReactionsClient(null)); } } @@ -24,7 +24,7 @@ public async Task RequestsCorrectUrl() var connection = Substitute.For(); var client = new ReactionsClient(connection); - client.CommitComment.GetAll("fake", "repo", 42); + client.Issue.GetAll("fake", "repo", 42); connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/1/reactions"), "application/vnd.github.squirrel-girl-preview"); } @@ -53,7 +53,7 @@ public void RequestsCorrectUrl() var connection = Substitute.For(); var client = new ReactionsClient(connection); - client.CommitComment.CreateReaction("fake", "repo", 1, newReaction); + client.Issue.Create("fake", "repo", 1, newReaction); connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/1/reactions"), Arg.Any(), "application/vnd.github.squirrel-girl-preview"); } diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 30d5ab71c5..05562f78db 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -86,6 +86,7 @@ + From 191451aa6380f7229832969878c346792d1ca0d7 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 1 Jun 2016 10:18:45 +0200 Subject: [PATCH 32/65] add api url for PullRequestReviewComment --- Octokit/Helpers/ApiUrls.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 05c88c40dd..2a9c168b1f 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -364,7 +364,7 @@ public static Uri IssueComment(string owner, string name, int id) } /// - /// Returns the for the reaction of an specified issue. + /// Returns the for the reaction of an specified issue comment. /// /// The owner of the repository /// The name of the repository @@ -372,7 +372,7 @@ public static Uri IssueComment(string owner, string name, int id) /// public static Uri IssueCommentReactions(string owner, string name, int number) { - return "repos/{0}/{1}/issues/comment/{2}/reactions".FormatUri(owner, name, number); + return "repos/{0}/{1}/issues/comments/{2}/reactions".FormatUri(owner, name, number); } /// @@ -1205,6 +1205,18 @@ public static Uri PullRequestReviewComment(string owner, string name, int number return "repos/{0}/{1}/pulls/comments/{2}".FormatUri(owner, name, number); } + /// + /// Returns the for the reaction of an specified pull request review comment. + /// + /// The owner of the repository + /// The name of the repository + /// The comment number + /// + public static Uri PullRequestReviewCommentReaction(string owner, string name, int number) + { + return "repos/{0}/{1}/pulls/comments/{2}/reactions".FormatUri(owner, name, number); + } + /// /// Returns the for the pull request review comments on a specified repository. /// From dc59d58f1db24f0f8529c2adf82e387873ceea70 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 1 Jun 2016 10:24:58 +0200 Subject: [PATCH 33/65] add IssueComment for Reactions Client --- Octokit.Reactive/Clients/IObservableReactionsClient.cs | 2 ++ Octokit.Reactive/Clients/ObservableReactionsClient.cs | 3 +++ 2 files changed, 5 insertions(+) diff --git a/Octokit.Reactive/Clients/IObservableReactionsClient.cs b/Octokit.Reactive/Clients/IObservableReactionsClient.cs index c8da6f6f9d..c6ce811100 100644 --- a/Octokit.Reactive/Clients/IObservableReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableReactionsClient.cs @@ -5,5 +5,7 @@ public interface IObservableReactionsClient IObservableCommitCommentReactionsClient CommitComment { get; } IObservableIssueReactionsClient Issue { get; } + + IObservableIssueCommentReactionsClient IssueComment { get; } } } diff --git a/Octokit.Reactive/Clients/ObservableReactionsClient.cs b/Octokit.Reactive/Clients/ObservableReactionsClient.cs index dba8f7a4d6..dfb34007a4 100644 --- a/Octokit.Reactive/Clients/ObservableReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableReactionsClient.cs @@ -10,10 +10,13 @@ public ObservableReactionsClient(IGitHubClient client) CommitComment = new ObservableCommitCommentReactionsClient(client); Issue = new ObservableIssueReactionsClient(client); + IssueComment = new ObservableIssueCommentReactionsClient(client); } public IObservableCommitCommentReactionsClient CommitComment { get; private set; } public IObservableIssueReactionsClient Issue { get; private set; } + + public IObservableIssueCommentReactionsClient IssueComment { get; private set; } } } From 2611af5b01c2aec213c1c33f62451687004231d0 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 1 Jun 2016 10:40:54 +0200 Subject: [PATCH 34/65] fix broken links for reaction clients --- .../Clients/IObservableCommitCommentReactionsClient.cs | 4 ++-- .../Clients/IObservableIssueCommentReactionsClient.cs | 8 ++++---- .../Clients/IObservableIssueReactionsClient.cs | 4 ++-- .../Clients/ObservableCommitCommentReactionsClient.cs | 4 ++-- .../Clients/ObservableIssueCommentReactionsClient.cs | 8 ++++---- .../Clients/ObservableIssueReactionsClient.cs | 8 ++++---- Octokit/Clients/CommitCommentReactionsClient.cs | 4 ++-- Octokit/Clients/ICommitCommentReactionsClient.cs | 4 ++-- Octokit/Clients/IIssueCommentReactionsClient.cs | 6 +++--- Octokit/Clients/IIssueReactionsClient.cs | 4 ++-- Octokit/Clients/IssueCommentReactionsClient.cs | 6 +++--- Octokit/Clients/IssueReactionsClient.cs | 4 ++-- 12 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs b/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs index 0db4442c96..8a0f799be6 100644 --- a/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs @@ -7,7 +7,7 @@ public interface IObservableCommitCommentReactionsClient /// /// Creates a reaction for an specified Commit Comment /// - /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment + /// https://developer.github.com/v3/reactions/#create-reaction-for-a-commit-comment /// The owner of the repository /// The name of the repository /// The comment id @@ -18,7 +18,7 @@ public interface IObservableCommitCommentReactionsClient /// /// List reactions for a specified Commit Comment /// - /// http://developer.github.com/v3/repos/comments/#list-reactions-for-a-commit-comment + /// https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment /// The owner of the repository /// The name of the repository /// The comment id diff --git a/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs b/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs index a04bd9edd0..6e41be81d1 100644 --- a/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs @@ -5,9 +5,9 @@ namespace Octokit.Reactive public interface IObservableIssueCommentReactionsClient { /// - /// Creates a reaction for an specified Commit Comment + /// Creates a reaction for an specified Issue Comment /// - /// http://developer.github.com/v3/repos/comments/#create-reaction-for-an-issue-comment + /// https://developer.github.com/v3/reactions/#create-reaction-for-an-issue-comment /// The owner of the repository /// The name of the repository /// The comment id @@ -16,9 +16,9 @@ public interface IObservableIssueCommentReactionsClient IObservable Create(string owner, string name, int number, NewReaction reaction); /// - /// List reactions for a specified Commit Comment + /// List reactions for a specified Issue Comment /// - /// http://developer.github.com/v3/repos/comments/#list-reactions-for-an-issue-comment + /// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment /// The owner of the repository /// The name of the repository /// The comment id diff --git a/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs b/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs index 45488f5f95..ac59227e9d 100644 --- a/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs @@ -7,7 +7,7 @@ public interface IObservableIssueReactionsClient /// /// Creates a reaction for an specified Commit Comment /// - /// http://developer.github.com/v3/repos/comments/#create-reaction-for-an-issue + /// https://developer.github.com/v3/reactions/#create-reaction-for-an-issue /// The owner of the repository /// The name of the repository /// The issue id @@ -18,7 +18,7 @@ public interface IObservableIssueReactionsClient /// /// List reactions for a specified Commit Comment /// - /// http://developer.github.com/v3/repos/comments/#list-reactions-for-an-issue + /// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue /// The owner of the repository /// The name of the repository /// The issue id diff --git a/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs index 270c6d1093..e3d172ee92 100644 --- a/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs @@ -20,7 +20,7 @@ public ObservableCommitCommentReactionsClient(IGitHubClient client) /// /// Creates a reaction for a specified Commit Comment /// - /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment + /// https://developer.github.com/v3/reactions/#create-reaction-for-a-commit-comment /// The owner of the repository /// The name of the repository /// The comment id @@ -38,7 +38,7 @@ public IObservable Create(string owner, string name, int number, NewRe /// /// List reactions for a specified Commit Comment /// - /// http://developer.github.com/v3/repos/comments/#list-reactions-for-a-commit-comment + /// https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment /// The owner of the repository /// The name of the repository /// The comment id diff --git a/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs index fef2c3c808..c218a12c8b 100644 --- a/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs @@ -18,9 +18,9 @@ public ObservableIssueCommentReactionsClient(IGitHubClient client) } /// - /// Creates a reaction for an specified Commit Comment + /// Creates a reaction for an specified Issue Comment /// - /// http://developer.github.com/v3/repos/comments/#create-reaction-for-an-issue-comment + /// https://developer.github.com/v3/reactions/#create-reaction-for-an-issue-comment /// The owner of the repository /// The name of the repository /// The comment id @@ -36,9 +36,9 @@ public IObservable Create(string owner, string name, int number, NewRe } /// - /// List reactions for a specified Commit Comment + /// List reactions for an specified Issue Comment /// - /// http://developer.github.com/v3/repos/comments/#list-reactions-for-an-issue-comment + /// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment /// The owner of the repository /// The name of the repository /// The comment id diff --git a/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs b/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs index ef93a5d20e..305e2408fd 100644 --- a/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssueReactionsClient.cs @@ -20,7 +20,7 @@ public ObservableIssueReactionsClient(IGitHubClient client) /// /// Creates a reaction for a specified Issue /// - /// http://developer.github.com/v3/repos/comments/#create-reaction-for-an-issue + /// https://developer.github.com/v3/reactions/#create-reaction-for-an-issue /// The owner of the repository /// The name of the repository /// The issue id @@ -36,12 +36,12 @@ public IObservable Create(string owner, string name, int number, NewRe } /// - /// List reactions for a specified Commit Comment + /// List reactions for a specified Issue /// - /// http://developer.github.com/v3/repos/comments/#list-reactions-for-a-commit-comment + /// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue /// The owner of the repository /// The name of the repository - /// The comment id + /// The issue id /// public IObservable GetAll(string owner, string name, int number) { diff --git a/Octokit/Clients/CommitCommentReactionsClient.cs b/Octokit/Clients/CommitCommentReactionsClient.cs index da4ddc07ad..000cddb532 100644 --- a/Octokit/Clients/CommitCommentReactionsClient.cs +++ b/Octokit/Clients/CommitCommentReactionsClient.cs @@ -13,7 +13,7 @@ public CommitCommentReactionsClient(IApiConnection apiConnection) /// /// Creates a reaction for a specified Commit Comment /// - /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment + /// https://developer.github.com/v3/reactions/#create-reaction-for-a-commit-comment /// The owner of the repository /// The name of the repository /// The comment id @@ -31,7 +31,7 @@ public Task Create(string owner, string name, int number, NewReaction /// /// Get all reactions for a specified Commit Comment /// - /// http://developer.github.com/v3/repos/comments/#list-reactions-for-a-commit-comment + /// https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment /// The owner of the repository /// The name of the repository /// The comment id diff --git a/Octokit/Clients/ICommitCommentReactionsClient.cs b/Octokit/Clients/ICommitCommentReactionsClient.cs index d4664ecc20..269c9644e8 100644 --- a/Octokit/Clients/ICommitCommentReactionsClient.cs +++ b/Octokit/Clients/ICommitCommentReactionsClient.cs @@ -8,7 +8,7 @@ public interface ICommitCommentReactionsClient /// /// Creates a reaction for an specified Commit Comment /// - /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment + /// https://developer.github.com/v3/reactions/#create-reaction-for-a-commit-comment /// The owner of the repository /// The name of the repository /// The comment id @@ -19,7 +19,7 @@ public interface ICommitCommentReactionsClient /// /// Get all reactions for a specified Commit Comment /// - /// http://developer.github.com/v3/repos/comments/#list-reactions-for-a-commit-comment + /// https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment /// The owner of the repository /// The name of the repository /// The comment id diff --git a/Octokit/Clients/IIssueCommentReactionsClient.cs b/Octokit/Clients/IIssueCommentReactionsClient.cs index 298e9046a2..e524f6b9e5 100644 --- a/Octokit/Clients/IIssueCommentReactionsClient.cs +++ b/Octokit/Clients/IIssueCommentReactionsClient.cs @@ -8,7 +8,7 @@ public interface IIssueCommentReactionsClient /// /// Creates a reaction for an specified Issue Comment /// - /// http://developer.github.com/v3/repos/comments/#create-reaction-for-an-issue-comment + /// https://developer.github.com/v3/reactions/#create-reaction-for-an-issue-comment /// The owner of the repository /// The name of the repository /// The comment id @@ -17,9 +17,9 @@ public interface IIssueCommentReactionsClient Task Create(string owner, string name, int number, NewReaction reaction); /// - /// Get all reactions for a specified Commit Comment + /// Get all reactions for an specified Issue Comment /// - /// http://developer.github.com/v3/repos/comments/#list-reactions-for-an-issue-comment + /// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment /// The owner of the repository /// The name of the repository /// The comment id diff --git a/Octokit/Clients/IIssueReactionsClient.cs b/Octokit/Clients/IIssueReactionsClient.cs index 208503bfd1..f30c93c943 100644 --- a/Octokit/Clients/IIssueReactionsClient.cs +++ b/Octokit/Clients/IIssueReactionsClient.cs @@ -8,7 +8,7 @@ public interface IIssueReactionsClient /// /// Get all reactions for an specified Issue /// - /// http://developer.github.com/v3/repos/comments/#list-reactions-for-an-issue + /// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue /// The owner of the repository /// The name of the repository /// The issue id @@ -18,7 +18,7 @@ public interface IIssueReactionsClient /// /// Creates a reaction for an specified Issue /// - /// http://developer.github.com/v3/repos/comments/#create-reaction-for-an-issue + /// https://developer.github.com/v3/reactions/#create-reaction-for-an-issue /// The owner of the repository /// The name of the repository /// The issue id diff --git a/Octokit/Clients/IssueCommentReactionsClient.cs b/Octokit/Clients/IssueCommentReactionsClient.cs index 4ee050892d..950159baf8 100644 --- a/Octokit/Clients/IssueCommentReactionsClient.cs +++ b/Octokit/Clients/IssueCommentReactionsClient.cs @@ -14,7 +14,7 @@ public IssueCommentReactionsClient(IApiConnection apiConnection) /// /// Creates a reaction for an specified Issue Comment /// - /// http://developer.github.com/v3/repos/comments/#create-reaction-for-an-issue-comment + /// https://developer.github.com/v3/reactions/#create-reactions-for-an-issue-comment /// The owner of the repository /// The name of the repository /// The comment id @@ -30,9 +30,9 @@ public Task Create(string owner, string name, int number, NewReaction } /// - /// Get all reactions for a specified Commit Comment + /// Get all reactions for an specified Issue Comment /// - /// http://developer.github.com/v3/repos/comments/#list-reactions-for-an-issue-comment + /// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment /// The owner of the repository /// The name of the repository /// The comment id diff --git a/Octokit/Clients/IssueReactionsClient.cs b/Octokit/Clients/IssueReactionsClient.cs index f4e07714c4..0ddd8ffcf5 100644 --- a/Octokit/Clients/IssueReactionsClient.cs +++ b/Octokit/Clients/IssueReactionsClient.cs @@ -14,7 +14,7 @@ public IssueReactionsClient(IApiConnection apiConnection) /// /// Creates a reaction for an specified Issue /// - /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment + /// https://developer.github.com/v3/reactions/#create-reactions-for-an-issue /// The owner of the repository /// The name of the repository /// The issue id @@ -32,7 +32,7 @@ public Task Create(string owner, string name, int number, NewReaction /// /// Get all reactions for an specified Issue /// - /// http://developer.github.com/v3/repos/comments/#list-reactions-for-a-commit-comment + /// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue /// The owner of the repository /// The name of the repository /// The issue id From 3a4031fb9b0bcad78748e7c4b49f167ac9847579 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 1 Jun 2016 11:24:49 +0200 Subject: [PATCH 35/65] add PullRequestReviewCommentReactionClient --- ...PullRequestReviewCommentReactionsClient.cs | 29 ++++++++++ .../Clients/IObservableReactionsClient.cs | 2 + .../ObservableIssueCommentReactionsClient.cs | 5 +- ...PullRequestReviewCommentReactionsClient.cs | 55 +++++++++++++++++++ .../Clients/ObservableReactionsClient.cs | 7 ++- Octokit.Reactive/Octokit.Reactive-Mono.csproj | 2 + .../Octokit.Reactive-MonoAndroid.csproj | 2 + .../Octokit.Reactive-Monotouch.csproj | 2 + Octokit.Reactive/Octokit.Reactive.csproj | 2 + ...PullRequestReviewCommentReactionsClient.cs | 29 ++++++++++ Octokit/Clients/IReactionsClient.cs | 8 +++ ...PullRequestReviewCommentReactionsClient.cs | 48 ++++++++++++++++ Octokit/Clients/ReactionsClient.cs | 10 ++++ Octokit/Octokit-Mono.csproj | 2 + Octokit/Octokit-MonoAndroid.csproj | 2 + Octokit/Octokit-Monotouch.csproj | 2 + Octokit/Octokit-Portable.csproj | 2 + Octokit/Octokit-netcore45.csproj | 2 + Octokit/Octokit.csproj | 2 + 19 files changed, 208 insertions(+), 5 deletions(-) create mode 100644 Octokit.Reactive/Clients/IObservablePullRequestReviewCommentReactionsClient.cs create mode 100644 Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs create mode 100644 Octokit/Clients/IPullRequestReviewCommentReactionsClient.cs create mode 100644 Octokit/Clients/PullRequestReviewCommentReactionsClient.cs diff --git a/Octokit.Reactive/Clients/IObservablePullRequestReviewCommentReactionsClient.cs b/Octokit.Reactive/Clients/IObservablePullRequestReviewCommentReactionsClient.cs new file mode 100644 index 0000000000..75cc0a8886 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservablePullRequestReviewCommentReactionsClient.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; + +namespace Octokit.Reactive +{ + public interface IObservablePullRequestReviewCommentReactionsClient + { + /// + /// Creates a reaction for a specified Pull Request Review Comment. + /// + /// https://developer.github.com/v3/reactions/#create-reaction-for-a-pull-request-review-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction to create + /// + IObservable Create(string owner, string name, int number, NewReaction reaction); + + /// + /// Get all reactions for a specified Pull Request Review Comment. + /// + /// https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// + IObservable GetAll(string owner, string name, int number); + } +} diff --git a/Octokit.Reactive/Clients/IObservableReactionsClient.cs b/Octokit.Reactive/Clients/IObservableReactionsClient.cs index c6ce811100..534ed3db2e 100644 --- a/Octokit.Reactive/Clients/IObservableReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableReactionsClient.cs @@ -7,5 +7,7 @@ public interface IObservableReactionsClient IObservableIssueReactionsClient Issue { get; } IObservableIssueCommentReactionsClient IssueComment { get; } + + IObservablePullRequestReviewCommentReactionsClient PullRequestReviewComment { get; } } } diff --git a/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs index c218a12c8b..a7c64ecf3a 100644 --- a/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs @@ -1,19 +1,20 @@ using Octokit.Reactive.Internal; using System; +using System.Reactive.Linq; using System.Reactive.Threading.Tasks; namespace Octokit.Reactive { public class ObservableIssueCommentReactionsClient : IObservableIssueCommentReactionsClient { - readonly ICommitCommentReactionsClient _client; + readonly IIssueCommentReactionsClient _client; readonly IConnection _connection; public ObservableIssueCommentReactionsClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); - _client = client.Reaction.CommitComment; + _client = client.Reaction.IssueComment; _connection = client.Connection; } diff --git a/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs new file mode 100644 index 0000000000..331b721dfa --- /dev/null +++ b/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs @@ -0,0 +1,55 @@ +using Octokit.Reactive.Internal; +using System; +using System.Collections.Generic; +using System.Reactive.Threading.Tasks; + +namespace Octokit.Reactive +{ + class ObservablePullRequestReviewCommentReactionsClient : IObservablePullRequestReviewCommentReactionsClient + { + readonly IPullRequestReviewCommentReactionsClient _client; + readonly IConnection _connection; + + public ObservablePullRequestReviewCommentReactionsClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, "client"); + + _client = client.Reaction.PullRequestReviewComment; + _connection = client.Connection; + } + + /// + /// Creates a reaction for a specified Pull Request Review Comment. + /// + /// https://developer.github.com/v3/reactions/#create-reaction-for-a-pull-request-review-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction to create + /// + public IObservable Create(string owner, string name, int number, NewReaction reaction) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(reaction, "reaction"); + + return _client.Create(owner, name, number, reaction).ToObservable(); + } + + /// + /// Get all reactions for a specified Pull Request Review Comment. + /// + /// https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// + public IObservable GetAll(string owner, string name, int number) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return _connection.GetAndFlattenAllPages(ApiUrls.PullRequestReviewCommentReaction(owner, name, number), null, AcceptHeaders.ReactionsPreview); + } + } +} diff --git a/Octokit.Reactive/Clients/ObservableReactionsClient.cs b/Octokit.Reactive/Clients/ObservableReactionsClient.cs index dfb34007a4..d8fe56bf72 100644 --- a/Octokit.Reactive/Clients/ObservableReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableReactionsClient.cs @@ -1,6 +1,4 @@ -using System; - -namespace Octokit.Reactive +namespace Octokit.Reactive { public class ObservableReactionsClient : IObservableReactionsClient { @@ -11,6 +9,7 @@ public ObservableReactionsClient(IGitHubClient client) CommitComment = new ObservableCommitCommentReactionsClient(client); Issue = new ObservableIssueReactionsClient(client); IssueComment = new ObservableIssueCommentReactionsClient(client); + PullRequestReviewComment = new ObservablePullRequestReviewCommentReactionsClient(client); } public IObservableCommitCommentReactionsClient CommitComment { get; private set; } @@ -18,5 +17,7 @@ public ObservableReactionsClient(IGitHubClient client) public IObservableIssueReactionsClient Issue { get; private set; } public IObservableIssueCommentReactionsClient IssueComment { get; private set; } + + public IObservablePullRequestReviewCommentReactionsClient PullRequestReviewComment { get; private set; } } } diff --git a/Octokit.Reactive/Octokit.Reactive-Mono.csproj b/Octokit.Reactive/Octokit.Reactive-Mono.csproj index 8996d64c15..d037693979 100644 --- a/Octokit.Reactive/Octokit.Reactive-Mono.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Mono.csproj @@ -196,6 +196,8 @@ + + diff --git a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj index 38d89c8f6a..57562b4c87 100644 --- a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj +++ b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj @@ -204,6 +204,8 @@ + + diff --git a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj index bb68d1f02b..7222794656 100644 --- a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj @@ -200,6 +200,8 @@ + + diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index a63f8014d4..d7614575f6 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -97,6 +97,7 @@ + @@ -109,6 +110,7 @@ + diff --git a/Octokit/Clients/IPullRequestReviewCommentReactionsClient.cs b/Octokit/Clients/IPullRequestReviewCommentReactionsClient.cs new file mode 100644 index 0000000000..5c2c4dba2f --- /dev/null +++ b/Octokit/Clients/IPullRequestReviewCommentReactionsClient.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + public interface IPullRequestReviewCommentReactionsClient + { + /// + /// Creates a reaction for a specified Pull Request Review Comment. + /// + /// https://developer.github.com/v3/reactions/#create-reaction-for-a-pull-request-review-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction to create + /// + Task Create(string owner, string name, int number, NewReaction reaction); + + /// + /// Get all reactions for a specified Pull Request Review Comment. + /// + /// https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// + Task> GetAll(string owner, string name, int number); + } +} diff --git a/Octokit/Clients/IReactionsClient.cs b/Octokit/Clients/IReactionsClient.cs index d22b83e1d0..08f14c443b 100644 --- a/Octokit/Clients/IReactionsClient.cs +++ b/Octokit/Clients/IReactionsClient.cs @@ -31,5 +31,13 @@ public interface IReactionsClient /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// IIssueCommentReactionsClient IssueComment { get; } + + /// + /// Access GitHub's Reactions API for Issue Comments. + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ + /// + IPullRequestReviewCommentReactionsClient PullRequestReviewComment { get; } } } diff --git a/Octokit/Clients/PullRequestReviewCommentReactionsClient.cs b/Octokit/Clients/PullRequestReviewCommentReactionsClient.cs new file mode 100644 index 0000000000..4c07dffa39 --- /dev/null +++ b/Octokit/Clients/PullRequestReviewCommentReactionsClient.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Octokit +{ + public class PullRequestReviewCommentReactionsClient : ApiClient, IPullRequestReviewCommentReactionsClient + { + public PullRequestReviewCommentReactionsClient(IApiConnection apiConnection) + : base(apiConnection) + { + } + + /// + /// Creates a reaction for a specified Pull Request Review Comment. + /// + /// https://developer.github.com/v3/reactions/#create-reaction-for-a-pull-request-review-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// The reaction to create + /// + public Task Create(string owner, string name, int number, NewReaction reaction) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(reaction, "reaction"); + + return ApiConnection.Post(ApiUrls.PullRequestReviewCommentReaction(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); + } + + /// + /// Get all reactions for a specified Pull Request Review Comment. + /// + /// https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// + public Task> GetAll(string owner, string name, int number) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return ApiConnection.GetAll(ApiUrls.PullRequestReviewCommentReaction(owner, name, number), AcceptHeaders.ReactionsPreview); + } + } +} diff --git a/Octokit/Clients/ReactionsClient.cs b/Octokit/Clients/ReactionsClient.cs index 533642124a..9c1d110bbc 100644 --- a/Octokit/Clients/ReactionsClient.cs +++ b/Octokit/Clients/ReactionsClient.cs @@ -13,6 +13,8 @@ public ReactionsClient(IApiConnection apiConnection) { CommitComment = new CommitCommentReactionsClient(apiConnection); Issue = new IssueReactionsClient(apiConnection); + IssueComment = new IssueCommentReactionsClient(apiConnection); + PullRequestReviewComment = new PullRequestReviewCommentReactionsClient(apiConnection); } /// @@ -38,5 +40,13 @@ public ReactionsClient(IApiConnection apiConnection) /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// public IIssueCommentReactionsClient IssueComment { get; private set; } + + /// + /// Access GitHub's Reactions API for Pull Request Review Comments. + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ + /// + public IPullRequestReviewCommentReactionsClient PullRequestReviewComment { get; private set; } } } diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index 5e46e53ced..fc19394401 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -476,6 +476,8 @@ + + \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index d9d8efbef3..33d012e3d0 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -487,6 +487,8 @@ + + \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index 3858e96f87..5dd8eacfc3 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -483,6 +483,8 @@ + + diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj index 1e93e924bb..3207c985b1 100644 --- a/Octokit/Octokit-Portable.csproj +++ b/Octokit/Octokit-Portable.csproj @@ -473,6 +473,8 @@ + + diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index 43aa1886c7..d7c46ceee7 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -480,6 +480,8 @@ + + diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 3d3ca2fbd3..53108b0cb8 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -61,6 +61,7 @@ + @@ -91,6 +92,7 @@ + From 7e4b42b0dbfa52cd1bd1a012ff0a53575603bba0 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 1 Jun 2016 11:32:03 +0200 Subject: [PATCH 36/65] add unit tests for reaction clients --- ...equestReviewCommentReactionsClientTests.cs | 62 +++++++++++++++++++ Octokit.Tests/Octokit.Tests.csproj | 2 + ...ervableCommitCommentReactionClientTests.cs | 14 ++--- ...equestReviewCommentReactionsClientTests.cs | 56 +++++++++++++++++ 4 files changed, 127 insertions(+), 7 deletions(-) create mode 100644 Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs create mode 100644 Octokit.Tests/Reactive/ObservablePullRequestReviewCommentReactionsClientTests.cs diff --git a/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs b/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs new file mode 100644 index 0000000000..669b3a9401 --- /dev/null +++ b/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs @@ -0,0 +1,62 @@ +using NSubstitute; +using System; +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class PullRequestReviewCommentReactionsClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new PullRequestReviewCommentReactionsClient(null)); + } + } + + public class TheGetAllMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ReactionsClient(connection); + + client.PullRequestReviewComment.GetAll("fake", "repo", 42); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/pulls/comments/1/reactions"), "application/vnd.github.squirrel-girl-preview"); + } + + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var connection = Substitute.For(); + var client = new ReactionsClient(connection); + + await Assert.ThrowsAsync(() => client.PullRequestReviewComment.Create(null, "name", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.PullRequestReviewComment.Create("", "name", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.PullRequestReviewComment.Create("owner", null, 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.PullRequestReviewComment.Create("owner", "", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.PullRequestReviewComment.Create("owner", "name", 1, null)); + } + } + + public class TheCreateMethod + { + [Fact] + public void RequestsCorrectUrl() + { + NewReaction newReaction = new NewReaction(ReactionType.Heart); + + var connection = Substitute.For(); + var client = new ReactionsClient(connection); + + client.PullRequestReviewComment.Create("fake", "repo", 1, newReaction); + + connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/pulls/comments/1/reactions"), Arg.Any(), "application/vnd.github.squirrel-girl-preview"); + } + } + } +} diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 05562f78db..058d15a02b 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -96,6 +96,7 @@ + @@ -212,6 +213,7 @@ + diff --git a/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs b/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs index cd23ef1555..794dae4e70 100644 --- a/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs @@ -31,11 +31,11 @@ public void RequestsCorrectUrl() public void EnsuresArgumentsNotNull() { - Assert.Throws(() => _client.CommitComment.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => _client.CommitComment.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => _client.CommitComment.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => _client.CommitComment.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => _client.CommitComment.CreateReaction("owner", "name", 1, null)); + Assert.Throws(() => _client.CommitComment.Create(null, "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.CommitComment.Create("", "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.CommitComment.Create("owner", null, 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.CommitComment.Create("owner", "", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.CommitComment.Create("owner", "name", 1, null)); } } @@ -48,8 +48,8 @@ public void RequestsCorrectUrl() var client = new ObservableReactionsClient(githubClient); var newReaction = new NewReaction(ReactionType.Confused); - client.CommitComment.CreateReaction("fake", "repo", 1, newReaction); - githubClient.Received().Reaction.CommitComment.CreateReaction("fake", "repo", 1, newReaction); + client.CommitComment.Create("fake", "repo", 1, newReaction); + githubClient.Received().Reaction.CommitComment.Create("fake", "repo", 1, newReaction); } } } diff --git a/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentReactionsClientTests.cs b/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentReactionsClientTests.cs new file mode 100644 index 0000000000..cd85f61259 --- /dev/null +++ b/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentReactionsClientTests.cs @@ -0,0 +1,56 @@ +using NSubstitute; +using Octokit.Reactive; +using System; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservablePullRequestReviewCommentReactionsClientTests + { + public class TheGetAllMethod + { + private readonly IGitHubClient _githubClient; + private readonly IObservableReactionsClient _client; + private const string owner = "owner"; + private const string name = "name"; + + public TheGetAllMethod() + { + _githubClient = Substitute.For(); + _client = new ObservableReactionsClient(_githubClient); + } + + [Fact] + public void RequestsCorrectUrl() + { + _client.PullRequestReviewComment.GetAll("fake", "repo", 42); + _githubClient.Received().Reaction.PullRequestReviewComment.GetAll("fake", "repo", 42); + } + + [Fact] + public void EnsuresArgumentsNotNull() + { + + Assert.Throws(() => _client.PullRequestReviewComment.Create(null, "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.PullRequestReviewComment.Create("", "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.PullRequestReviewComment.Create("owner", null, 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.PullRequestReviewComment.Create("owner", "", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.PullRequestReviewComment.Create("owner", "name", 1, null)); + } + } + + public class TheCreateMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var githubClient = Substitute.For(); + var client = new ObservableReactionsClient(githubClient); + var newReaction = new NewReaction(ReactionType.Confused); + + client.PullRequestReviewComment.Create("fake", "repo", 1, newReaction); + githubClient.Received().Reaction.PullRequestReviewComment.Create("fake", "repo", 1, newReaction); + } + } + } +} From 28f454a7bb60b2689a92c1eb32990c1d3499b8c8 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 1 Jun 2016 11:34:37 +0200 Subject: [PATCH 37/65] add descriptions for observable reactions client --- .../Clients/IObservableReactionsClient.cs | 24 +++++++++++++++++++ .../Clients/ObservableReactionsClient.cs | 24 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/Octokit.Reactive/Clients/IObservableReactionsClient.cs b/Octokit.Reactive/Clients/IObservableReactionsClient.cs index 534ed3db2e..8ba0e87bb4 100644 --- a/Octokit.Reactive/Clients/IObservableReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableReactionsClient.cs @@ -2,12 +2,36 @@ { public interface IObservableReactionsClient { + /// + /// Access GitHub's Reactions API for Commit Comments. + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ + /// IObservableCommitCommentReactionsClient CommitComment { get; } + /// + /// Access GitHub's Reactions API for Issues. + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ + /// IObservableIssueReactionsClient Issue { get; } + /// + /// Access GitHub's Reactions API for Issue Comments. + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ + /// IObservableIssueCommentReactionsClient IssueComment { get; } + /// + /// Access GitHub's Reactions API for Pull Request Review Comments. + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ + /// IObservablePullRequestReviewCommentReactionsClient PullRequestReviewComment { get; } } } diff --git a/Octokit.Reactive/Clients/ObservableReactionsClient.cs b/Octokit.Reactive/Clients/ObservableReactionsClient.cs index d8fe56bf72..f2f44ae877 100644 --- a/Octokit.Reactive/Clients/ObservableReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableReactionsClient.cs @@ -12,12 +12,36 @@ public ObservableReactionsClient(IGitHubClient client) PullRequestReviewComment = new ObservablePullRequestReviewCommentReactionsClient(client); } + /// + /// Access GitHub's Reactions API for Commit Comments. + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ + /// public IObservableCommitCommentReactionsClient CommitComment { get; private set; } + /// + /// Access GitHub's Reactions API for Issues. + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ + /// public IObservableIssueReactionsClient Issue { get; private set; } + /// + /// Access GitHub's Reactions API for Issue Comments. + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ + /// public IObservableIssueCommentReactionsClient IssueComment { get; private set; } + /// + /// Access GitHub's Reactions API for Pull Request Review Comments. + /// + /// + /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ + /// public IObservablePullRequestReviewCommentReactionsClient PullRequestReviewComment { get; private set; } } } From c4c374c532536fd041ecc157bb88ce1f984be7db Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 1 Jun 2016 11:54:20 +0200 Subject: [PATCH 38/65] add delete method for reaction client --- .../Clients/IObservableReactionsClient.cs | 13 +++++++++++- .../Clients/ObservableReactionsClient.cs | 21 ++++++++++++++++++- Octokit/Clients/IReactionsClient.cs | 12 ++++++++++- Octokit/Clients/ReactionsClient.cs | 14 ++++++++++++- Octokit/Helpers/ApiUrls.cs | 10 +++++++++ 5 files changed, 66 insertions(+), 4 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableReactionsClient.cs b/Octokit.Reactive/Clients/IObservableReactionsClient.cs index 8ba0e87bb4..2cedf69afd 100644 --- a/Octokit.Reactive/Clients/IObservableReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableReactionsClient.cs @@ -1,4 +1,7 @@ -namespace Octokit.Reactive +using System; +using System.Reactive; + +namespace Octokit.Reactive { public interface IObservableReactionsClient { @@ -33,5 +36,13 @@ public interface IObservableReactionsClient /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// IObservablePullRequestReviewCommentReactionsClient PullRequestReviewComment { get; } + + /// + /// Delete a reaction. + /// + /// https://developer.github.com/v3/reactions/#delete-a-reaction + /// The reaction id + /// + IObservable Delete(int number); } } diff --git a/Octokit.Reactive/Clients/ObservableReactionsClient.cs b/Octokit.Reactive/Clients/ObservableReactionsClient.cs index f2f44ae877..3cd3e9b3b7 100644 --- a/Octokit.Reactive/Clients/ObservableReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableReactionsClient.cs @@ -1,11 +1,19 @@ -namespace Octokit.Reactive +using System; +using System.Reactive; +using System.Reactive.Threading.Tasks; + +namespace Octokit.Reactive { public class ObservableReactionsClient : IObservableReactionsClient { + readonly IReactionsClient _client; + public ObservableReactionsClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); + _client = client.Reaction; + CommitComment = new ObservableCommitCommentReactionsClient(client); Issue = new ObservableIssueReactionsClient(client); IssueComment = new ObservableIssueCommentReactionsClient(client); @@ -43,5 +51,16 @@ public ObservableReactionsClient(IGitHubClient client) /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// public IObservablePullRequestReviewCommentReactionsClient PullRequestReviewComment { get; private set; } + + /// + /// Delete a reaction. + /// + /// https://developer.github.com/v3/reactions/#delete-a-reaction + /// The reaction id + /// + public IObservable Delete(int number) + { + return _client.Delete(number).ToObservable(); + } } } diff --git a/Octokit/Clients/IReactionsClient.cs b/Octokit/Clients/IReactionsClient.cs index 08f14c443b..fbf765691a 100644 --- a/Octokit/Clients/IReactionsClient.cs +++ b/Octokit/Clients/IReactionsClient.cs @@ -1,4 +1,6 @@ -namespace Octokit +using System.Threading.Tasks; + +namespace Octokit { /// /// A client for GitHub's Reactions Events API. @@ -39,5 +41,13 @@ public interface IReactionsClient /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// IPullRequestReviewCommentReactionsClient PullRequestReviewComment { get; } + + /// + /// Delete a reaction. + /// + /// https://developer.github.com/v3/reactions/#delete-a-reaction + /// The reaction id + /// + Task Delete(int number); } } diff --git a/Octokit/Clients/ReactionsClient.cs b/Octokit/Clients/ReactionsClient.cs index 9c1d110bbc..deb8033a00 100644 --- a/Octokit/Clients/ReactionsClient.cs +++ b/Octokit/Clients/ReactionsClient.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; namespace Octokit { @@ -47,6 +48,17 @@ public ReactionsClient(IApiConnection apiConnection) /// /// Refer to the API documentation for more information: https://developer.github.com/v3/reactions/ /// - public IPullRequestReviewCommentReactionsClient PullRequestReviewComment { get; private set; } + public IPullRequestReviewCommentReactionsClient PullRequestReviewComment { get; private set; } + + /// + /// Delete a reaction. + /// + /// https://developer.github.com/v3/reactions/#delete-a-reaction + /// The reaction id + /// + public Task Delete(int number) + { + return ApiConnection.Delete(ApiUrls.Reactions(number)); + } } } diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 2a9c168b1f..1ad8dc8140 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -2926,5 +2926,15 @@ public static Uri Watchers(int repositoryId) { return "repositories/{0}/subscribers".FormatUri(repositoryId); } + + /// + /// Returns the for deleting a reaction. + /// + /// The reaction number + /// The that lists the watched repositories for the authenticated user. + public static Uri Reactions(int number) + { + return "reactions/{0}".FormatUri(number); + } } } From 2ebe0eed8959232d24f2fc9b7468dce511f66f55 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 1 Jun 2016 11:58:02 +0200 Subject: [PATCH 39/65] add unit test for reaction client --- Octokit.Tests/Clients/ReactionsClientTests.cs | 33 +++++++++++++++++++ Octokit.Tests/Octokit.Tests.csproj | 1 + 2 files changed, 34 insertions(+) create mode 100644 Octokit.Tests/Clients/ReactionsClientTests.cs diff --git a/Octokit.Tests/Clients/ReactionsClientTests.cs b/Octokit.Tests/Clients/ReactionsClientTests.cs new file mode 100644 index 0000000000..81d5e97e22 --- /dev/null +++ b/Octokit.Tests/Clients/ReactionsClientTests.cs @@ -0,0 +1,33 @@ +using NSubstitute; +using System; +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class ReactionsClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new ReactionsClient(null)); + } + } + + public class TheDeleteMethod + { + [Fact] + public async Task DeletesCorrectUrl() + { + var connection = Substitute.For(); + var client = new ReactionsClient(connection); + + await client.Delete(42); + + connection.Received().Delete(Arg.Is(u => u.ToString() == "reactions/42")); + } + } + } +} diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 058d15a02b..9413da5a2e 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -97,6 +97,7 @@ + From 1a974e0a257b0e7633671a85960e66afcb8da49d Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 1 Jun 2016 12:08:47 +0200 Subject: [PATCH 40/65] fix unit tests for reaction clients --- .../Clients/IObservableIssueReactionsClient.cs | 4 ++-- .../Clients/CommitCommentReactionsClientTests.cs | 2 +- Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs | 2 +- Octokit.Tests/Clients/IssueReactionsClientTests.cs | 2 +- .../PullRequestReviewCommentReactionsClientTests.cs | 2 +- .../ObservableCommitCommentReactionClientTests.cs | 2 +- ...ervablePullRequestReviewCommentReactionsClientTests.cs | 2 +- Octokit/Clients/IssueReactionsClient.cs | 8 ++++---- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs b/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs index ac59227e9d..829c699742 100644 --- a/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs @@ -5,7 +5,7 @@ namespace Octokit.Reactive public interface IObservableIssueReactionsClient { /// - /// Creates a reaction for an specified Commit Comment + /// Creates a reaction for an specified Issue. /// /// https://developer.github.com/v3/reactions/#create-reaction-for-an-issue /// The owner of the repository @@ -16,7 +16,7 @@ public interface IObservableIssueReactionsClient IObservable Create(string owner, string name, int number, NewReaction reaction); /// - /// List reactions for a specified Commit Comment + /// List reactions for an specified Issue. /// /// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue /// The owner of the repository diff --git a/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs b/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs index 67750a3ef3..caffd2fa5c 100644 --- a/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs +++ b/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs @@ -39,7 +39,7 @@ public async Task EnsuresArgumentsNotNull() await Assert.ThrowsAsync(() => client.CommitComment.Create("", "name", 1, new NewReaction(ReactionType.Heart))); await Assert.ThrowsAsync(() => client.CommitComment.Create("owner", null, 1, new NewReaction(ReactionType.Heart))); await Assert.ThrowsAsync(() => client.CommitComment.Create("owner", "", 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.CommitComment.Create("owner", "name", 1, null)); + await Assert.ThrowsAsync(() => client.CommitComment.Create("owner", "name", 1, null)); } } diff --git a/Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs b/Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs index 027d3dfe18..cc0139e28f 100644 --- a/Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs +++ b/Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs @@ -39,7 +39,7 @@ public async Task EnsuresArgumentsNotNull() await Assert.ThrowsAsync(() => client.IssueComment.Create("", "name", 1, new NewReaction(ReactionType.Heart))); await Assert.ThrowsAsync(() => client.IssueComment.Create("owner", null, 1, new NewReaction(ReactionType.Heart))); await Assert.ThrowsAsync(() => client.IssueComment.Create("owner", "", 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.IssueComment.Create("owner", "name", 1, null)); + await Assert.ThrowsAsync(() => client.IssueComment.Create("owner", "name", 1, null)); } } diff --git a/Octokit.Tests/Clients/IssueReactionsClientTests.cs b/Octokit.Tests/Clients/IssueReactionsClientTests.cs index d0565b907c..fb5c23e789 100644 --- a/Octokit.Tests/Clients/IssueReactionsClientTests.cs +++ b/Octokit.Tests/Clients/IssueReactionsClientTests.cs @@ -39,7 +39,7 @@ public async Task EnsuresArgumentsNotNull() await Assert.ThrowsAsync(() => client.Issue.Create("", "name", 1, new NewReaction(ReactionType.Heart))); await Assert.ThrowsAsync(() => client.Issue.Create("owner", null, 1, new NewReaction(ReactionType.Heart))); await Assert.ThrowsAsync(() => client.Issue.Create("owner", "", 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.Issue.Create("owner", "name", 1, null)); + await Assert.ThrowsAsync(() => client.Issue.Create("owner", "name", 1, null)); } } diff --git a/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs b/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs index 669b3a9401..b2dfc1208a 100644 --- a/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs +++ b/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs @@ -39,7 +39,7 @@ public async Task EnsuresArgumentsNotNull() await Assert.ThrowsAsync(() => client.PullRequestReviewComment.Create("", "name", 1, new NewReaction(ReactionType.Heart))); await Assert.ThrowsAsync(() => client.PullRequestReviewComment.Create("owner", null, 1, new NewReaction(ReactionType.Heart))); await Assert.ThrowsAsync(() => client.PullRequestReviewComment.Create("owner", "", 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.PullRequestReviewComment.Create("owner", "name", 1, null)); + await Assert.ThrowsAsync(() => client.PullRequestReviewComment.Create("owner", "name", 1, null)); } } diff --git a/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs b/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs index 794dae4e70..2daf811fa1 100644 --- a/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs @@ -35,7 +35,7 @@ public void EnsuresArgumentsNotNull() Assert.Throws(() => _client.CommitComment.Create("", "name", 1, new NewReaction(ReactionType.Heart))); Assert.Throws(() => _client.CommitComment.Create("owner", null, 1, new NewReaction(ReactionType.Heart))); Assert.Throws(() => _client.CommitComment.Create("owner", "", 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => _client.CommitComment.Create("owner", "name", 1, null)); + Assert.Throws(() => _client.CommitComment.Create("owner", "name", 1, null)); } } diff --git a/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentReactionsClientTests.cs b/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentReactionsClientTests.cs index cd85f61259..65c0c369f3 100644 --- a/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentReactionsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentReactionsClientTests.cs @@ -35,7 +35,7 @@ public void EnsuresArgumentsNotNull() Assert.Throws(() => _client.PullRequestReviewComment.Create("", "name", 1, new NewReaction(ReactionType.Heart))); Assert.Throws(() => _client.PullRequestReviewComment.Create("owner", null, 1, new NewReaction(ReactionType.Heart))); Assert.Throws(() => _client.PullRequestReviewComment.Create("owner", "", 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => _client.PullRequestReviewComment.Create("owner", "name", 1, null)); + Assert.Throws(() => _client.PullRequestReviewComment.Create("owner", "name", 1, null)); } } diff --git a/Octokit/Clients/IssueReactionsClient.cs b/Octokit/Clients/IssueReactionsClient.cs index 0ddd8ffcf5..ecb96c0a27 100644 --- a/Octokit/Clients/IssueReactionsClient.cs +++ b/Octokit/Clients/IssueReactionsClient.cs @@ -22,8 +22,8 @@ public IssueReactionsClient(IApiConnection apiConnection) /// public Task Create(string owner, string name, int number, NewReaction reaction) { - Ensure.ArgumentNotNull(owner, "owner"); - Ensure.ArgumentNotNull(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(reaction, "reaction"); return ApiConnection.Post(ApiUrls.IssueReactions(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); @@ -39,8 +39,8 @@ public Task Create(string owner, string name, int number, NewReaction /// public Task> GetAll(string owner, string name, int number) { - Ensure.ArgumentNotNull(owner, "owner"); - Ensure.ArgumentNotNull(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); return ApiConnection.GetAll(ApiUrls.IssueReactions(owner, name, number), AcceptHeaders.ReactionsPreview); } From 56434f29f69da46394fa8b439d04ca22aa4d9786 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 1 Jun 2016 13:51:07 +0200 Subject: [PATCH 41/65] fixed unit tests for reaction clients --- Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs | 2 +- Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs | 2 +- Octokit.Tests/Clients/IssueReactionsClientTests.cs | 2 +- .../Clients/PullRequestReviewCommentReactionsClientTests.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs b/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs index caffd2fa5c..aba818ca4b 100644 --- a/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs +++ b/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs @@ -26,7 +26,7 @@ public async Task RequestsCorrectUrl() client.CommitComment.GetAll("fake", "repo", 42); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), "application/vnd.github.squirrel-girl-preview"); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/comments/42/reactions"), "application/vnd.github.squirrel-girl-preview"); } [Fact] diff --git a/Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs b/Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs index cc0139e28f..fc53857677 100644 --- a/Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs +++ b/Octokit.Tests/Clients/IssueCommentReactionsClientTests.cs @@ -26,7 +26,7 @@ public async Task RequestsCorrectUrl() client.IssueComment.GetAll("fake", "repo", 42); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/1/reactions"), "application/vnd.github.squirrel-girl-preview"); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/42/reactions"), "application/vnd.github.squirrel-girl-preview"); } [Fact] diff --git a/Octokit.Tests/Clients/IssueReactionsClientTests.cs b/Octokit.Tests/Clients/IssueReactionsClientTests.cs index fb5c23e789..43c86aa397 100644 --- a/Octokit.Tests/Clients/IssueReactionsClientTests.cs +++ b/Octokit.Tests/Clients/IssueReactionsClientTests.cs @@ -26,7 +26,7 @@ public async Task RequestsCorrectUrl() client.Issue.GetAll("fake", "repo", 42); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/1/reactions"), "application/vnd.github.squirrel-girl-preview"); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/42/reactions"), "application/vnd.github.squirrel-girl-preview"); } [Fact] diff --git a/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs b/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs index b2dfc1208a..66bec075b6 100644 --- a/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs +++ b/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs @@ -26,7 +26,7 @@ public async Task RequestsCorrectUrl() client.PullRequestReviewComment.GetAll("fake", "repo", 42); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/pulls/comments/1/reactions"), "application/vnd.github.squirrel-girl-preview"); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/pulls/comments/42/reactions"), "application/vnd.github.squirrel-girl-preview"); } [Fact] From 65f481fcf4b92461b1869eaed855590f78f65775 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 1 Jun 2016 16:45:56 +0200 Subject: [PATCH 42/65] fix constructur for unit tests --- ...bservablePullRequestReviewCommentReactionsClient.cs | 2 +- .../ObservableCommitCommentReactionClientTests.cs | 9 +++++++++ ...ablePullRequestReviewCommentReactionsClientTests.cs | 10 ++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs index 331b721dfa..e917ef5a31 100644 --- a/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs @@ -5,7 +5,7 @@ namespace Octokit.Reactive { - class ObservablePullRequestReviewCommentReactionsClient : IObservablePullRequestReviewCommentReactionsClient + public class ObservablePullRequestReviewCommentReactionsClient : IObservablePullRequestReviewCommentReactionsClient { readonly IPullRequestReviewCommentReactionsClient _client; readonly IConnection _connection; diff --git a/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs b/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs index 2daf811fa1..6b22a6c6e1 100644 --- a/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs @@ -7,6 +7,15 @@ namespace Octokit.Tests.Reactive { public class ObservableCommitCommentReactionClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new ObservableCommitCommentReactionsClient(null)); + } + } + public class TheGetAllMethod { private readonly IGitHubClient _githubClient; diff --git a/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentReactionsClientTests.cs b/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentReactionsClientTests.cs index 65c0c369f3..f0037c4a60 100644 --- a/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentReactionsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentReactionsClientTests.cs @@ -7,6 +7,16 @@ namespace Octokit.Tests.Reactive { public class ObservablePullRequestReviewCommentReactionsClientTests { + + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new ObservablePullRequestReviewCommentReactionsClient(null)); + } + } + public class TheGetAllMethod { private readonly IGitHubClient _githubClient; From d7d54c7c672abc81fc22786c0d3a0d1a15b208fa Mon Sep 17 00:00:00 2001 From: lrz-hal Date: Wed, 1 Jun 2016 20:57:24 +0200 Subject: [PATCH 43/65] remove project reference --- Octokit.Tests/OctoKit.Tests-NetCore45.csproj | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj b/Octokit.Tests/OctoKit.Tests-NetCore45.csproj index 206f9b23ed..773cd7f842 100644 --- a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj +++ b/Octokit.Tests/OctoKit.Tests-NetCore45.csproj @@ -179,11 +179,7 @@ - - - {49EF16A2-5ED1-480F-80A1-D1D05D6C1BE4} - Octokit-Mono - + {c8bc13b6-3fa3-4716-827d-e7706f976fe1} Octokit-NetCore45 From 5fcc30d068fa0c90033838fdd9150848d4975b59 Mon Sep 17 00:00:00 2001 From: lrz-hal Date: Wed, 1 Jun 2016 22:21:54 +0200 Subject: [PATCH 44/65] added missing unit tests for observable reaction clients --- Octokit.Tests/Octokit.Tests.csproj | 3 + ...ervableIssueCommentReactionsClientTests.cs | 65 +++++++++++++++++++ .../ObservableIssueReactionsClientTests.cs | 65 +++++++++++++++++++ .../ObservableReactionsClientTests.cs | 35 ++++++++++ 4 files changed, 168 insertions(+) create mode 100644 Octokit.Tests/Reactive/ObservableIssueCommentReactionsClientTests.cs create mode 100644 Octokit.Tests/Reactive/ObservableIssueReactionsClientTests.cs create mode 100644 Octokit.Tests/Reactive/ObservableReactionsClientTests.cs diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index f82e598e38..67d9bfc228 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -213,9 +213,12 @@ + + + diff --git a/Octokit.Tests/Reactive/ObservableIssueCommentReactionsClientTests.cs b/Octokit.Tests/Reactive/ObservableIssueCommentReactionsClientTests.cs new file mode 100644 index 0000000000..1ae5f48b02 --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableIssueCommentReactionsClientTests.cs @@ -0,0 +1,65 @@ +using NSubstitute; +using Octokit.Reactive; +using System; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableIssueCommentReactionsClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new ObservableIssueCommentReactionsClient(null)); + } + } + + public class TheGetAllMethod + { + private readonly IGitHubClient _githubClient; + private readonly IObservableReactionsClient _client; + private const string owner = "owner"; + private const string name = "name"; + + public TheGetAllMethod() + { + _githubClient = Substitute.For(); + _client = new ObservableReactionsClient(_githubClient); + } + + [Fact] + public void RequestsCorrectUrl() + { + _client.IssueComment.GetAll("fake", "repo", 42); + _githubClient.Received().Reaction.IssueComment.GetAll("fake", "repo", 42); + } + + [Fact] + public void EnsuresArgumentsNotNull() + { + + Assert.Throws(() => _client.IssueComment.Create(null, "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.IssueComment.Create("", "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.IssueComment.Create("owner", null, 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.IssueComment.Create("owner", "", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.IssueComment.Create("owner", "name", 1, null)); + } + } + + public class TheCreateMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var githubClient = Substitute.For(); + var client = new ObservableReactionsClient(githubClient); + var newReaction = new NewReaction(ReactionType.Confused); + + client.IssueComment.Create("fake", "repo", 1, newReaction); + githubClient.Received().Reaction.IssueComment.Create("fake", "repo", 1, newReaction); + } + } + } +} diff --git a/Octokit.Tests/Reactive/ObservableIssueReactionsClientTests.cs b/Octokit.Tests/Reactive/ObservableIssueReactionsClientTests.cs new file mode 100644 index 0000000000..08d519941c --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableIssueReactionsClientTests.cs @@ -0,0 +1,65 @@ +using NSubstitute; +using Octokit.Reactive; +using System; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableIssueReactionsClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new ObservableIssueReactionsClient(null)); + } + } + + public class TheGetAllMethod + { + private readonly IGitHubClient _githubClient; + private readonly IObservableReactionsClient _client; + private const string owner = "owner"; + private const string name = "name"; + + public TheGetAllMethod() + { + _githubClient = Substitute.For(); + _client = new ObservableReactionsClient(_githubClient); + } + + [Fact] + public void RequestsCorrectUrl() + { + _client.Issue.GetAll("fake", "repo", 42); + _githubClient.Received().Reaction.Issue.GetAll("fake", "repo", 42); + } + + [Fact] + public void EnsuresArgumentsNotNull() + { + + Assert.Throws(() => _client.Issue.Create(null, "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.Issue.Create("", "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.Issue.Create("owner", null, 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.Issue.Create("owner", "", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.Issue.Create("owner", "name", 1, null)); + } + } + + public class TheCreateMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var githubClient = Substitute.For(); + var client = new ObservableReactionsClient(githubClient); + var newReaction = new NewReaction(ReactionType.Confused); + + client.Issue.Create("fake", "repo", 1, newReaction); + githubClient.Received().Reaction.Issue.Create("fake", "repo", 1, newReaction); + } + } + } +} diff --git a/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs b/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs new file mode 100644 index 0000000000..054fe574dc --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs @@ -0,0 +1,35 @@ +using NSubstitute; +using Octokit.Reactive; +using System; +using System.Reactive.Threading.Tasks; +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableReactionsClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new ObservableReactionsClient(null)); + } + } + + public class TheDeleteMethod + { + [Fact] + public void PostsToCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableReactionsClient(gitHubClient); + + client.Delete(13); + + gitHubClient.Reaction.Received().Delete(13); + } + } + } +} From 7794aaf421148618418dafe4d3398d1a8a61ddd2 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Thu, 2 Jun 2016 08:49:40 +0200 Subject: [PATCH 45/65] add integration test for CommitCommentReactionsClient --- .../CommitCommentReactionsClientTests.cs | 74 +++++++++++++++++++ .../Clients/RepositoryCommentsClientTests.cs | 65 ---------------- .../Octokit.Tests.Integration.csproj | 1 + 3 files changed, 75 insertions(+), 65 deletions(-) create mode 100644 Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs diff --git a/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs new file mode 100644 index 0000000000..f50d9ed04e --- /dev/null +++ b/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs @@ -0,0 +1,74 @@ +using Octokit; +using Octokit.Tests.Integration; +using Octokit.Tests.Integration.Helpers; +using System; +using System.Threading.Tasks; +using Xunit; + +public class CommitCommentReactionsClientTests +{ + public class TheCreateReactionMethod : IDisposable + { + private readonly IGitHubClient _github; + private readonly RepositoryContext _context; + + public TheCreateReactionMethod() + { + _github = Helper.GetAuthenticatedClient(); + + _context = _github.CreateRepositoryContext("public-repo").Result; + } + + private async Task SetupCommitForRepository(IGitHubClient client) + { + var blob = new NewBlob + { + Content = "Hello World!", + Encoding = EncodingType.Utf8 + }; + var blobResult = await client.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob); + + var newTree = new NewTree(); + newTree.Tree.Add(new NewTreeItem + { + Type = TreeType.Blob, + Mode = FileMode.File, + Path = "README.md", + Sha = blobResult.Sha + }); + + var treeResult = await client.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree); + + var newCommit = new NewCommit("test-commit", treeResult.Sha); + + return await client.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit); + } + + [IntegrationTest] + public async Task CanCreateReaction() + { + var commit = await SetupCommitForRepository(_github); + + var comment = new NewCommitComment("test"); + + var result = await _github.Repository.Comment.Create(_context.RepositoryOwner, _context.RepositoryName, + commit.Sha, comment); + + Assert.NotNull(result); + + var newReaction = new NewReaction(ReactionType.Confused); + var reaction = await _github.Reaction.CommitComment.Create(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReaction); + + Assert.IsType(reaction); + + Assert.Equal(ReactionType.Confused, reaction.Content); + + Assert.Equal(result.User.Id, reaction.UserId); + } + + public void Dispose() + { + _context.Dispose(); + } + } +} diff --git a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs index c6a81129a1..dad6ab1a5b 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs @@ -376,69 +376,4 @@ public void Dispose() _context.Dispose(); } } - - //public class TheCreateReactionMethod : IDisposable - //{ - // private readonly IGitHubClient _github; - // private readonly RepositoryContext _context; - - // public TheCreateReactionMethod() - // { - // _github = Helper.GetAuthenticatedClient(); - - // _context = _github.CreateRepositoryContext("public-repo").Result; - // } - - // private async Task SetupCommitForRepository(IGitHubClient client) - // { - // var blob = new NewBlob - // { - // Content = "Hello World!", - // Encoding = EncodingType.Utf8 - // }; - // var blobResult = await client.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob); - - // var newTree = new NewTree(); - // newTree.Tree.Add(new NewTreeItem - // { - // Type = TreeType.Blob, - // Mode = FileMode.File, - // Path = "README.md", - // Sha = blobResult.Sha - // }); - - // var treeResult = await client.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree); - - // var newCommit = new NewCommit("test-commit", treeResult.Sha); - - // return await client.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit); - // } - - // [IntegrationTest] - // public async Task CanCreateReaction() - // { - // var commit = await SetupCommitForRepository(_github); - - // var comment = new NewCommitComment("test"); - - // var result = await _github.Repository.Comment.Create(_context.RepositoryOwner, _context.RepositoryName, - // commit.Sha, comment); - - // Assert.NotNull(result); - - // var newReaction = new NewReaction(ReactionType.Confused); - // var reaction = await _github.Repository.Comment.CreateReaction(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReaction); - - // Assert.IsType(reaction); - - // Assert.Equal(ReactionType.Confused, reaction.Content); - - // Assert.Equal(result.User.Id, reaction.UserId); - // } - - // public void Dispose() - // { - // _context.Dispose(); - // } - //} } diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index be61279eb1..a2a98af762 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -77,6 +77,7 @@ + From c8be91900b345cba0fd7906714587463857beaf2 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Thu, 2 Jun 2016 13:54:56 +0200 Subject: [PATCH 46/65] fix projectreference --- Octokit.Tests/OctoKit.Tests-NetCore45.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj b/Octokit.Tests/OctoKit.Tests-NetCore45.csproj index 773cd7f842..f2aaa20ee7 100644 --- a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj +++ b/Octokit.Tests/OctoKit.Tests-NetCore45.csproj @@ -179,7 +179,7 @@ - + {c8bc13b6-3fa3-4716-827d-e7706f976fe1} Octokit-NetCore45 From 07f34b8e669f935db5b22ec2eed5cb692a2f648a Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Thu, 2 Jun 2016 15:28:05 +0200 Subject: [PATCH 47/65] clean up missing files --- Octokit.Reactive/Octokit.Reactive-Mono.csproj | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Octokit.Reactive/Octokit.Reactive-Mono.csproj b/Octokit.Reactive/Octokit.Reactive-Mono.csproj index d037693979..8ae7c07fb8 100644 --- a/Octokit.Reactive/Octokit.Reactive-Mono.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Mono.csproj @@ -180,16 +180,8 @@ - - - - - - - - From 93f9ecb433f3930070f16646bbd6b093434a3d5e Mon Sep 17 00:00:00 2001 From: Daniel Plaisted Date: Fri, 3 Jun 2016 00:39:55 -0700 Subject: [PATCH 48/65] Add support for code searches without a search term (#1338) --- .../Clients/SearchClientTests.cs | 14 ++++++++++++++ Octokit/Models/Request/BaseSearchRequest.cs | 9 ++++++++- Octokit/Models/Request/SearchCodeRequest.cs | 8 ++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Octokit.Tests.Integration/Clients/SearchClientTests.cs b/Octokit.Tests.Integration/Clients/SearchClientTests.cs index 8ae982509e..b1267410cc 100644 --- a/Octokit.Tests.Integration/Clients/SearchClientTests.cs +++ b/Octokit.Tests.Integration/Clients/SearchClientTests.cs @@ -57,6 +57,20 @@ public async Task SearchForFileNameInCode() Assert.NotEmpty(repos.Items); } + [IntegrationTest] + public async Task SearchForFileNameInCodeWithoutTerm() + { + var request = new SearchCodeRequest() + { + FileName = "readme.md", + Repos = new RepositoryCollection { "octokit/octokit.net" } + }; + + var repos = await _gitHubClient.Search.SearchCode(request); + + Assert.NotEmpty(repos.Items); + } + [IntegrationTest] public async Task SearchForWordInCode() { diff --git a/Octokit/Models/Request/BaseSearchRequest.cs b/Octokit/Models/Request/BaseSearchRequest.cs index d3cff73d0c..7ff689def8 100644 --- a/Octokit/Models/Request/BaseSearchRequest.cs +++ b/Octokit/Models/Request/BaseSearchRequest.cs @@ -85,7 +85,14 @@ private string TermAndQualifiers get { var mergedParameters = string.Join("+", MergedQualifiers()); - return Term + (mergedParameters.IsNotBlank() ? "+" + mergedParameters : ""); + if (string.IsNullOrEmpty(Term)) + { + return mergedParameters; + } + else + { + return Term + (mergedParameters.IsNotBlank() ? "+" + mergedParameters : ""); + } } } diff --git a/Octokit/Models/Request/SearchCodeRequest.cs b/Octokit/Models/Request/SearchCodeRequest.cs index f5c8693dc9..4e4142310f 100644 --- a/Octokit/Models/Request/SearchCodeRequest.cs +++ b/Octokit/Models/Request/SearchCodeRequest.cs @@ -15,6 +15,14 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class SearchCodeRequest : BaseSearchRequest { + /// + /// Initializes a new instance of the class. + /// + public SearchCodeRequest() : base() + { + Repos = new RepositoryCollection(); + } + /// /// Initializes a new instance of the class. /// From 96cc2d6e065ee7d9f4317989293006686c81a56a Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Fri, 3 Jun 2016 11:02:29 +0200 Subject: [PATCH 49/65] fix name of observable commit comment reaction client test --- Octokit.Tests/Octokit.Tests.csproj | 2 +- ...tTests.cs => ObservableCommitCommentReactionsClientTests.cs} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename Octokit.Tests/Reactive/{ObservableCommitCommentReactionClientTests.cs => ObservableCommitCommentReactionsClientTests.cs} (97%) diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 12cd9d515e..04ea095c68 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -211,7 +211,7 @@ - + diff --git a/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs b/Octokit.Tests/Reactive/ObservableCommitCommentReactionsClientTests.cs similarity index 97% rename from Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs rename to Octokit.Tests/Reactive/ObservableCommitCommentReactionsClientTests.cs index 6b22a6c6e1..221d950fd8 100644 --- a/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableCommitCommentReactionsClientTests.cs @@ -5,7 +5,7 @@ namespace Octokit.Tests.Reactive { - public class ObservableCommitCommentReactionClientTests + public class ObservableCommitCommentReactionsClientTests { public class TheCtor { From df3a7c4df829e5bfdfa21c500998d232fef250df Mon Sep 17 00:00:00 2001 From: lrz-hal Date: Sat, 4 Jun 2016 15:02:08 +0200 Subject: [PATCH 50/65] add AcceptHeader for delete reactions method --- Octokit/Clients/ReactionsClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Octokit/Clients/ReactionsClient.cs b/Octokit/Clients/ReactionsClient.cs index deb8033a00..6de2a2cdb0 100644 --- a/Octokit/Clients/ReactionsClient.cs +++ b/Octokit/Clients/ReactionsClient.cs @@ -58,7 +58,7 @@ public ReactionsClient(IApiConnection apiConnection) /// public Task Delete(int number) { - return ApiConnection.Delete(ApiUrls.Reactions(number)); + return ApiConnection.Delete(ApiUrls.Reactions(number),null, AcceptHeaders.ReactionsPreview); } } } From ee2f78feaec171aaabddf9a7d4ad0a49e1ad1246 Mon Sep 17 00:00:00 2001 From: lrz-hal Date: Sat, 4 Jun 2016 15:25:22 +0200 Subject: [PATCH 51/65] fix delete reactions method --- Octokit.Tests/Clients/ReactionsClientTests.cs | 2 +- Octokit/Clients/ReactionsClient.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit.Tests/Clients/ReactionsClientTests.cs b/Octokit.Tests/Clients/ReactionsClientTests.cs index 81d5e97e22..ddc6d72ab5 100644 --- a/Octokit.Tests/Clients/ReactionsClientTests.cs +++ b/Octokit.Tests/Clients/ReactionsClientTests.cs @@ -26,7 +26,7 @@ public async Task DeletesCorrectUrl() await client.Delete(42); - connection.Received().Delete(Arg.Is(u => u.ToString() == "reactions/42")); + connection.Received().Delete(Arg.Is(u => u.ToString() == "reactions/42"), Arg.Any(), "application/vnd.github.squirrel-girl-preview"); } } } diff --git a/Octokit/Clients/ReactionsClient.cs b/Octokit/Clients/ReactionsClient.cs index 6de2a2cdb0..f958176152 100644 --- a/Octokit/Clients/ReactionsClient.cs +++ b/Octokit/Clients/ReactionsClient.cs @@ -58,7 +58,7 @@ public ReactionsClient(IApiConnection apiConnection) /// public Task Delete(int number) { - return ApiConnection.Delete(ApiUrls.Reactions(number),null, AcceptHeaders.ReactionsPreview); + return ApiConnection.Delete(ApiUrls.Reactions(number), new object(), AcceptHeaders.ReactionsPreview); } } } From 894498836902042b9e7518b8aac1feacab95d339 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Mon, 6 Jun 2016 11:07:24 +0200 Subject: [PATCH 52/65] remove whitepaces --- Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs | 2 +- Octokit.Tests/OctoKit.Tests-NetCore45.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs index 24f01ff7c1..1a8ed9b9a5 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs @@ -88,6 +88,6 @@ public interface IObservableRepositoryCommentsClient /// The name of the repository /// The comment id /// - IObservable Delete(string owner, string name, int number); + IObservable Delete(string owner, string name, int number); } } diff --git a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj b/Octokit.Tests/OctoKit.Tests-NetCore45.csproj index f2aaa20ee7..c6f5566f49 100644 --- a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj +++ b/Octokit.Tests/OctoKit.Tests-NetCore45.csproj @@ -179,7 +179,7 @@ - + {c8bc13b6-3fa3-4716-827d-e7706f976fe1} Octokit-NetCore45 From 9a68de156d54241dbccc60bd954dc78250a22675 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Mon, 6 Jun 2016 14:16:50 +0200 Subject: [PATCH 53/65] remove parameter values fom reaction enum --- Octokit/Models/Response/Reaction.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Octokit/Models/Response/Reaction.cs b/Octokit/Models/Response/Reaction.cs index 6ad8e4c15c..6174a77b30 100644 --- a/Octokit/Models/Response/Reaction.cs +++ b/Octokit/Models/Response/Reaction.cs @@ -11,13 +11,9 @@ public enum ReactionType Plus1, [Parameter(Value = "-1")] Minus1, - [Parameter(Value = "laugh")] Laugh, - [Parameter(Value = "confused")] Confused, - [Parameter(Value = "heart")] Heart, - [Parameter(Value = "hooray")] Hooray } From eff9ef4a563a2a26cae9cdd5417432f594b97605 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Tue, 7 Jun 2016 09:16:25 +0200 Subject: [PATCH 54/65] add integration tests for reaction clients --- .../IssueCommentReactionsClientTests.cs | 52 ++++++ .../Clients/IssueReactionsClientTests.cs | 49 ++++++ ...equestReviewCommentReactionsClientTests.cs | 151 ++++++++++++++++++ .../Octokit.Tests.Integration.csproj | 3 + 4 files changed, 255 insertions(+) create mode 100644 Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs create mode 100644 Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs create mode 100644 Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs diff --git a/Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs new file mode 100644 index 0000000000..d3b420f9f9 --- /dev/null +++ b/Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs @@ -0,0 +1,52 @@ +using Octokit; +using Octokit.Tests.Integration; +using Octokit.Tests.Integration.Helpers; +using System; +using System.Threading.Tasks; +using Xunit; + +public class IssueCommentReactionsClientTests +{ + public class TheCreateReactionMethod : IDisposable + { + private readonly RepositoryContext _context; + private readonly IIssuesClient _issuesClient; + private readonly IGitHubClient _github; + + public TheCreateReactionMethod() + { + _github = Helper.GetAuthenticatedClient(); + var repoName = Helper.MakeNameWithTimestamp("public-repo"); + _issuesClient = _github.Issue; + _context = _github.CreateRepositoryContext(new NewRepository(repoName)).Result; + } + + [IntegrationTest] + public async Task CanCreateReaction() + { + var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; + var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); + + Assert.NotNull(issue); + + var issueComment = await _issuesClient.Comment.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Id, "A test comment"); + + Assert.NotNull(issueComment); + + var issueCommentReaction = await _github.Reaction.IssueComment.Create(_context.RepositoryOwner, _context.RepositoryName, issueComment.Id, new NewReaction(ReactionType.Heart)); + + Assert.NotNull(issueCommentReaction); + + Assert.IsType(issueCommentReaction); + + Assert.Equal(ReactionType.Heart, issueCommentReaction.Content); + + Assert.Equal(issueComment.User.Id, issueCommentReaction.UserId); + } + + public void Dispose() + { + _context.Dispose(); + } + } +} diff --git a/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs new file mode 100644 index 0000000000..d01de5a347 --- /dev/null +++ b/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs @@ -0,0 +1,49 @@ +using Octokit; +using Octokit.Tests.Integration; +using Octokit.Tests.Integration.Helpers; +using System; +using System.Threading.Tasks; +using Xunit; + +public class IssueReactionsClientTests +{ + public class TheCreateReactionMethod : IDisposable + { + private readonly RepositoryContext _context; + private readonly IIssuesClient _issuesClient; + private readonly IGitHubClient _github; + + public TheCreateReactionMethod() + { + _github = Helper.GetAuthenticatedClient(); + var repoName = Helper.MakeNameWithTimestamp("public-repo"); + _issuesClient = _github.Issue; + _context = _github.CreateRepositoryContext(new NewRepository(repoName)).Result; + } + + [IntegrationTest] + public async Task CanCreateReaction() + { + var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" }; + var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); + + Assert.NotNull(issue); + + var issueReaction = await _github.Reaction.Issue.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Id, new NewReaction(ReactionType.Heart)); + + Assert.NotNull(issueReaction); + + Assert.IsType(issueReaction); + + Assert.Equal(ReactionType.Heart, issueReaction.Content); + + Assert.Equal(issue.User.Id, issueReaction.UserId); + } + + public void Dispose() + { + _context.Dispose(); + } + } +} + diff --git a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs new file mode 100644 index 0000000000..745fd5f0a8 --- /dev/null +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs @@ -0,0 +1,151 @@ +using Octokit; +using Octokit.Tests.Integration; +using Octokit.Tests.Integration.Helpers; +using System.Threading.Tasks; +using Xunit; + +public class PullRequestReviewCommentReactionsClientTests +{ + private readonly IGitHubClient _github; + private readonly IPullRequestReviewCommentsClient _client; + private readonly RepositoryContext _context; + + const string branchName = "new-branch"; + const string branchHead = "heads/" + branchName; + const string branchRef = "refs/" + branchHead; + const string path = "CONTRIBUTING.md"; + + public PullRequestReviewCommentReactionsClientTests() + { + _github = Helper.GetAuthenticatedClient(); + + _client = _github.PullRequest.Comment; + + // We'll create a pull request that can be used by most tests + _context = _github.CreateRepositoryContext("test-repo").Result; + } + + [IntegrationTest] + public async Task CanCreateReaction() + { + var pullRequest = await CreatePullRequest(_context); + + const string body = "A review comment message"; + const int position = 1; + + var createdComment = await CreateComment(body, position, pullRequest.Sha, pullRequest.Number); + + var commentFromGitHub = await _client.GetComment(Helper.UserName, _context.RepositoryName, createdComment.Id); + + AssertComment(commentFromGitHub, body, position); + + var pullRequestReviewCommentReaction = await _github.Reaction.PullRequestReviewComment.Create(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id, new NewReaction(ReactionType.Heart)); + + Assert.NotNull(pullRequestReviewCommentReaction); + + Assert.IsType(pullRequestReviewCommentReaction); + + Assert.Equal(ReactionType.Heart, pullRequestReviewCommentReaction.Content); + + Assert.Equal(commentFromGitHub.User.Id, pullRequestReviewCommentReaction.UserId); + } + + /// + /// Creates the base state for testing (creates a repo, a commit in master, a branch, a commit in the branch and a pull request) + /// + /// + async Task CreatePullRequest(RepositoryContext context) + { + var repoName = context.RepositoryName; + + // Creating a commit in master + + var createdCommitInMaster = await CreateCommit(repoName, "Hello World!", "README.md", "heads/master", "A master commit message"); + + // Creating a branch + + var newBranch = new NewReference(branchRef, createdCommitInMaster.Sha); + await _github.Git.Reference.Create(Helper.UserName, repoName, newBranch); + + // Creating a commit in the branch + + var createdCommitInBranch = await CreateCommit(repoName, "Hello from the fork!", path, branchHead, "A branch commit message"); + + // Creating a pull request + + var pullRequest = new NewPullRequest("Nice title for the pull request", branchName, "master"); + var createdPullRequest = await _github.PullRequest.Create(Helper.UserName, repoName, pullRequest); + + var data = new PullRequestData + { + Sha = createdCommitInBranch.Sha, + Number = createdPullRequest.Number + }; + + return data; + } + + async Task CreateCommit(string repoName, string blobContent, string treePath, string reference, string commitMessage) + { + // Creating a blob + var blob = new NewBlob + { + Content = blobContent, + Encoding = EncodingType.Utf8 + }; + + var createdBlob = await _github.Git.Blob.Create(Helper.UserName, repoName, blob); + + // Creating a tree + var newTree = new NewTree(); + newTree.Tree.Add(new NewTreeItem + { + Type = TreeType.Blob, + Mode = FileMode.File, + Path = treePath, + Sha = createdBlob.Sha + }); + + var createdTree = await _github.Git.Tree.Create(Helper.UserName, repoName, newTree); + var treeSha = createdTree.Sha; + + // Creating a commit + var parent = await _github.Git.Reference.Get(Helper.UserName, repoName, reference); + var commit = new NewCommit(commitMessage, treeSha, parent.Object.Sha); + + var createdCommit = await _github.Git.Commit.Create(Helper.UserName, repoName, commit); + await _github.Git.Reference.Update(Helper.UserName, repoName, reference, new ReferenceUpdate(createdCommit.Sha)); + + return createdCommit; + } + + async Task CreateComment(string body, int position, string commitId, int number) + { + return await CreateComment(body, position, _context.RepositoryName, commitId, number); + } + + async Task CreateComment(string body, int position, string repoName, string pullRequestCommitId, int pullRequestNumber) + { + var comment = new PullRequestReviewCommentCreate(body, pullRequestCommitId, path, position); + + var createdComment = await _client.Create(Helper.UserName, repoName, pullRequestNumber, comment); + + AssertComment(createdComment, body, position); + + return createdComment; + } + + static void AssertComment(PullRequestReviewComment comment, string body, int position) + { + Assert.NotNull(comment); + Assert.Equal(body, comment.Body); + Assert.Equal(position, comment.Position); + } + + class PullRequestData + { + public int Number { get; set; } + public string Sha { get; set; } + } +} + diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index a2a98af762..9f208c788b 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -84,6 +84,8 @@ + + @@ -97,6 +99,7 @@ + From 190abff982e2dbaf7a678a9fe7dbe1cb13dc6640 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 8 Jun 2016 15:06:39 +0200 Subject: [PATCH 55/65] change UserId key to User See https://developer.github.com/changes/2016-06-07-reactions-api-update/ for more information --- Octokit/Models/Response/Reaction.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Octokit/Models/Response/Reaction.cs b/Octokit/Models/Response/Reaction.cs index 6174a77b30..b646a16931 100644 --- a/Octokit/Models/Response/Reaction.cs +++ b/Octokit/Models/Response/Reaction.cs @@ -22,10 +22,10 @@ public class Reaction { public Reaction() { } - public Reaction(int id, int userId, ReactionType content) + public Reaction(int id, User user, ReactionType content) { Id = id; - UserId = userId; + User = user; Content = content; } @@ -35,9 +35,9 @@ public Reaction(int id, int userId, ReactionType content) public int Id { get; protected set; } /// - /// The UserId. + /// Information about the user. /// - public int UserId { get; protected set; } + public User User { get; protected set; } /// /// The reaction type for this commit comment. From 69b164052c386e88566ad6b85e8dd02d01b300be Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Wed, 8 Jun 2016 15:35:56 +0200 Subject: [PATCH 56/65] merge conflicts --- Octokit/Helpers/AcceptHeaders.cs | 6 ++---- Octokit/Octokit-Mono.csproj | 3 --- Octokit/Octokit-MonoAndroid.csproj | 3 --- Octokit/Octokit-Monotouch.csproj | 3 --- Octokit/Octokit-Portable.csproj | 3 --- Octokit/Octokit-netcore45.csproj | 3 --- 6 files changed, 2 insertions(+), 19 deletions(-) diff --git a/Octokit/Helpers/AcceptHeaders.cs b/Octokit/Helpers/AcceptHeaders.cs index 8bcd888b9f..36fcf4962e 100644 --- a/Octokit/Helpers/AcceptHeaders.cs +++ b/Octokit/Helpers/AcceptHeaders.cs @@ -20,12 +20,10 @@ public static class AcceptHeaders public const string SquashCommitPreview = "application/vnd.github.polaris-preview+json"; - public const string MigrationsApiPreview = " application/vnd.github.wyandotte-preview+json"; + public const string MigrationsApiPreview = "application/vnd.github.wyandotte-preview+json"; -<<<<<<< HEAD public const string ReactionsPreview = "application/vnd.github.squirrel-girl-preview"; -======= + public const string OrganizationPermissionsPreview = "application/vnd.github.ironman-preview+json"; ->>>>>>> refs/remotes/octokit/master } } diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index 133d63e31e..1fef019223 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -466,7 +466,6 @@ -<<<<<<< HEAD @@ -479,9 +478,7 @@ -======= ->>>>>>> refs/remotes/octokit/master \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index 4b16ea80fe..c7bb23c25b 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -477,7 +477,6 @@ -<<<<<<< HEAD @@ -490,9 +489,7 @@ -======= ->>>>>>> refs/remotes/octokit/master \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index 4d86ad9a6e..7c3802b016 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -473,7 +473,6 @@ -<<<<<<< HEAD @@ -486,9 +485,7 @@ -======= ->>>>>>> refs/remotes/octokit/master diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj index 0561f6a8f3..1431a1bcb1 100644 --- a/Octokit/Octokit-Portable.csproj +++ b/Octokit/Octokit-Portable.csproj @@ -463,7 +463,6 @@ -<<<<<<< HEAD @@ -476,9 +475,7 @@ -======= ->>>>>>> refs/remotes/octokit/master diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index 30639d2760..bbdadece15 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -470,7 +470,6 @@ -<<<<<<< HEAD @@ -483,9 +482,7 @@ -======= ->>>>>>> refs/remotes/octokit/master From e93ac2dcd4ea16b29cfe6122d41a53d749025ec7 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Thu, 9 Jun 2016 07:46:11 +0200 Subject: [PATCH 57/65] resolve conflicts --- Octokit.Reactive/Octokit.Reactive-Mono.csproj | 3 --- Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj | 3 --- Octokit.Reactive/Octokit.Reactive-Monotouch.csproj | 3 --- Octokit/Helpers/AcceptHeaders.cs | 5 +---- Octokit/Octokit.csproj | 6 ------ 5 files changed, 1 insertion(+), 19 deletions(-) diff --git a/Octokit.Reactive/Octokit.Reactive-Mono.csproj b/Octokit.Reactive/Octokit.Reactive-Mono.csproj index 7d4e1d1577..8d12e95177 100644 --- a/Octokit.Reactive/Octokit.Reactive-Mono.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Mono.csproj @@ -180,7 +180,6 @@ -<<<<<<< HEAD @@ -191,10 +190,8 @@ -======= ->>>>>>> refs/remotes/octokit/master diff --git a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj index de223baaf1..67daf9d4bb 100644 --- a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj +++ b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj @@ -188,7 +188,6 @@ -<<<<<<< HEAD @@ -207,10 +206,8 @@ -======= ->>>>>>> refs/remotes/octokit/master diff --git a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj index cb1b437355..52fc933fe4 100644 --- a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj +++ b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj @@ -184,7 +184,6 @@ -<<<<<<< HEAD @@ -203,10 +202,8 @@ -======= ->>>>>>> refs/remotes/octokit/master diff --git a/Octokit/Helpers/AcceptHeaders.cs b/Octokit/Helpers/AcceptHeaders.cs index 90d454824c..0002896ac7 100644 --- a/Octokit/Helpers/AcceptHeaders.cs +++ b/Octokit/Helpers/AcceptHeaders.cs @@ -25,12 +25,9 @@ public static class AcceptHeaders public const string SquashCommitPreview = "application/vnd.github.polaris-preview+json"; public const string MigrationsApiPreview = "application/vnd.github.wyandotte-preview+json"; -<<<<<<< HEAD public const string ReactionsPreview = "application/vnd.github.squirrel-girl-preview"; -======= ->>>>>>> refs/remotes/octokit/master - + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Gpg")] public const string GpgKeysPreview = "application/vnd.github.cryptographer-preview"; } diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index daaaaa821a..da4fe33ebb 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -58,16 +58,13 @@ Properties\SolutionInfo.cs -<<<<<<< HEAD -======= ->>>>>>> refs/remotes/octokit/master @@ -135,11 +132,8 @@ -<<<<<<< HEAD -======= ->>>>>>> refs/remotes/octokit/master From af2894364f4952103ae364328d303aee9d4e3472 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Thu, 9 Jun 2016 08:51:48 +0200 Subject: [PATCH 58/65] Fix unit tests --- .../Enterprise/IObservableEnterpriseAdminStatsClient.cs | 3 ++- .../Clients/CommitCommentReactionsClientTests.cs | 2 +- .../Clients/IssueCommentReactionsClientTests.cs | 2 +- Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs | 2 +- .../Clients/PullRequestReviewCommentReactionsClientTests.cs | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs index 62dccdb073..282a221930 100644 --- a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs +++ b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs @@ -1,4 +1,5 @@ -using System; +using Octokit; +using System; using System.Diagnostics.CodeAnalysis; namespace Octokit.Reactive diff --git a/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs index f50d9ed04e..14e749b6f9 100644 --- a/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs @@ -63,7 +63,7 @@ public async Task CanCreateReaction() Assert.Equal(ReactionType.Confused, reaction.Content); - Assert.Equal(result.User.Id, reaction.UserId); + Assert.Equal(result.User.Id, reaction.User.Id); } public void Dispose() diff --git a/Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs index d3b420f9f9..d6193bde62 100644 --- a/Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs @@ -41,7 +41,7 @@ public async Task CanCreateReaction() Assert.Equal(ReactionType.Heart, issueCommentReaction.Content); - Assert.Equal(issueComment.User.Id, issueCommentReaction.UserId); + Assert.Equal(issueComment.User.Id, issueCommentReaction.User.Id); } public void Dispose() diff --git a/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs index d01de5a347..a7e20fad65 100644 --- a/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs @@ -37,7 +37,7 @@ public async Task CanCreateReaction() Assert.Equal(ReactionType.Heart, issueReaction.Content); - Assert.Equal(issue.User.Id, issueReaction.UserId); + Assert.Equal(issue.User.Id, issueReaction.User.Id); } public void Dispose() diff --git a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs index 745fd5f0a8..cc74c04b75 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs @@ -47,7 +47,7 @@ public async Task CanCreateReaction() Assert.Equal(ReactionType.Heart, pullRequestReviewCommentReaction.Content); - Assert.Equal(commentFromGitHub.User.Id, pullRequestReviewCommentReaction.UserId); + Assert.Equal(commentFromGitHub.User.Id, pullRequestReviewCommentReaction.User.Id); } /// From c1115f548ca6c3295f4aea596409123b4dc8fdf9 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Wed, 8 Jun 2016 22:23:56 +0700 Subject: [PATCH 59/65] added new overloads on clients --- .../IObservableRepositoryForksClient.cs | 21 ++++++++ .../ObservableRepositoryForksClient.cs | 48 +++++++++++++++++-- .../Clients/RepositoryForksClientTests.cs | 2 +- .../Clients/RepositoryForksClientTests.cs | 6 +-- Octokit/Clients/IRepositoryForksClient.cs | 21 ++++++++ Octokit/Clients/RepositoryForksClient.cs | 47 ++++++++++++++++-- 6 files changed, 135 insertions(+), 10 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs index bac871d54a..212d582bbd 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs @@ -4,12 +4,33 @@ namespace Octokit.Reactive { public interface IObservableRepositoryForksClient { + /// + /// Gets the list of forks defined for a repository + /// + /// See API documentation for more information. + /// + IObservable GetAll(string owner, string repositoryName); + + /// + /// Gets the list of forks defined for a repository + /// + /// See API documentation for more information. + /// + IObservable GetAll(string owner, string repositoryName, ApiOptions options); + /// /// Gets the list of forks defined for a repository /// /// See API documentation for more information. /// IObservable GetAll(string owner, string repositoryName, RepositoryForksListRequest request); + + /// + /// Gets the list of forks defined for a repository + /// + /// See API documentation for more information. + /// + IObservable GetAll(string owner, string repositoryName, RepositoryForksListRequest request, ApiOptions options); /// /// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization. diff --git a/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs index 3238cd6c8c..d011bc19ba 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs @@ -16,10 +16,38 @@ public class ObservableRepositoryForksClient : IObservableRepositoryForksClient public ObservableRepositoryForksClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); + _client = client.Repository.Forks; _connection = client.Connection; } + /// + /// Gets the list of forks defined for a repository + /// + /// See API documentation for more information. + /// + public IObservable GetAll(string owner, string repositoryName) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + + return GetAll(owner, repositoryName, ApiOptions.None); + } + + /// + /// Gets the list of forks defined for a repository + /// + /// See API documentation for more information. + /// + 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.RepositoryForks(owner, repositoryName), options); + } + /// /// Gets the list of forks defined for a repository /// @@ -29,10 +57,24 @@ public IObservable GetAll(string owner, string repositoryName, Repos { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNull(request, "request"); + + return GetAll(owner, repositoryName, request, ApiOptions.None); + } + + /// + /// Gets the list of forks defined for a repository + /// + /// See API documentation for more information. + /// + public IObservable GetAll(string owner, string repositoryName, RepositoryForksListRequest request, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNull(request, "request"); + Ensure.ArgumentNotNull(options, "options"); - return request == null - ? _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, repositoryName)) - : _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, repositoryName), request.ToParametersDictionary()); + return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, repositoryName), request.ToParametersDictionary(), options); } /// diff --git a/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs index c1b64c6b88..8acc1fecd7 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs @@ -13,7 +13,7 @@ public async Task ReturnsForksForRepository() { var github = Helper.GetAuthenticatedClient(); - var forks = await github.Repository.Forks.GetAll("octokit", "octokit.net", null); + var forks = await github.Repository.Forks.GetAll("octokit", "octokit.net"); var masterFork = forks.FirstOrDefault(fork => fork.FullName == "TeamBinary/octokit.net"); Assert.NotNull(masterFork); diff --git a/Octokit.Tests/Clients/RepositoryForksClientTests.cs b/Octokit.Tests/Clients/RepositoryForksClientTests.cs index acc0f47a0c..28474a7b8e 100644 --- a/Octokit.Tests/Clients/RepositoryForksClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryForksClientTests.cs @@ -26,7 +26,7 @@ public void RequestsCorrectUrl() var connection = Substitute.For(); var client = new RepositoriesClient(connection); - client.Forks.GetAll("fake", "repo", null); + client.Forks.GetAll("fake", "repo"); connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/forks")); } @@ -49,8 +49,8 @@ public async Task EnsuresNonNullArguments() { var client = new RepositoriesClient(Substitute.For()); - await Assert.ThrowsAsync(() => client.Forks.GetAll(null, "name", null)); - await Assert.ThrowsAsync(() => client.Forks.GetAll("owner", null, null)); + await Assert.ThrowsAsync(() => client.Forks.GetAll(null, "name")); + await Assert.ThrowsAsync(() => client.Forks.GetAll("owner", null)); } } diff --git a/Octokit/Clients/IRepositoryForksClient.cs b/Octokit/Clients/IRepositoryForksClient.cs index 8d02624444..76ac2864d3 100644 --- a/Octokit/Clients/IRepositoryForksClient.cs +++ b/Octokit/Clients/IRepositoryForksClient.cs @@ -5,12 +5,33 @@ namespace Octokit { public interface IRepositoryForksClient { + /// + /// Gets the list of forks defined for a repository + /// + /// See API documentation for more information. + /// + Task> GetAll(string owner, string repositoryName); + + /// + /// Gets the list of forks defined for a repository + /// + /// See API documentation for more information. + /// + Task> GetAll(string owner, string repositoryName, ApiOptions options); + /// /// Gets the list of forks defined for a repository /// /// See API documentation for more information. /// Task> GetAll(string owner, string repositoryName, RepositoryForksListRequest request); + + /// + /// Gets the list of forks defined for a repository + /// + /// See API documentation for more information. + /// + Task> GetAll(string owner, string repositoryName, RepositoryForksListRequest request, ApiOptions options); /// /// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization. diff --git a/Octokit/Clients/RepositoryForksClient.cs b/Octokit/Clients/RepositoryForksClient.cs index c45a634bf7..9192040311 100644 --- a/Octokit/Clients/RepositoryForksClient.cs +++ b/Octokit/Clients/RepositoryForksClient.cs @@ -14,6 +14,33 @@ public RepositoryForksClient(IApiConnection apiConnection) { } + /// + /// Gets the list of forks defined for a repository + /// + /// See API documentation for more information. + /// + public Task> GetAll(string owner, string repositoryName) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + + return GetAll(owner, repositoryName, ApiOptions.None); + } + + /// + /// Gets the list of forks defined for a repository + /// + /// See API documentation for more information. + /// + 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.RepositoryForks(owner, repositoryName), options); + } + /// /// Gets the list of forks defined for a repository /// @@ -23,10 +50,24 @@ public Task> GetAll(string owner, string repositoryNam { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNull(request, "request"); + + return GetAll(owner, repositoryName, request, ApiOptions.None); + } + + /// + /// Gets the list of forks defined for a repository + /// + /// See API documentation for more information. + /// + public Task> GetAll(string owner, string repositoryName, RepositoryForksListRequest request, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNull(request, "request"); + Ensure.ArgumentNotNull(options, "options"); - return request == null - ? ApiConnection.GetAll(ApiUrls.RepositoryForks(owner, repositoryName)) - : ApiConnection.GetAll(ApiUrls.RepositoryForks(owner, repositoryName), request.ToParametersDictionary()); + return ApiConnection.GetAll(ApiUrls.RepositoryForks(owner, repositoryName), request.ToParametersDictionary(), options); } /// From 4ca64d457dd15e22b9bd23a739fa80ed4ec3c5f3 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Wed, 8 Jun 2016 23:10:59 +0700 Subject: [PATCH 60/65] added integration tests --- .../Clients/RepositoryForksClientTests.cs | 170 ++++++++++++++++++ .../Clients/RepositoryForksClientTests.cs | 99 +++++++--- Octokit.Tests/Octokit.Tests.csproj | 1 + .../ObservableRepositoryForksClientTests.cs | 143 +++++++++++++++ 4 files changed, 388 insertions(+), 25 deletions(-) create mode 100644 Octokit.Tests/Reactive/ObservableRepositoryForksClientTests.cs diff --git a/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs index 8acc1fecd7..1898f397de 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryForksClientTests.cs @@ -20,6 +20,176 @@ public async Task ReturnsForksForRepository() Assert.Equal("TeamBinary", masterFork.Owner.Login); } + [IntegrationTest] + public async Task ReturnsCorrectCountOfForksWithoutStart() + { + var github = Helper.GetAuthenticatedClient(); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 1 + }; + + var forks = await github.Repository.Forks.GetAll("octokit", "octokit.net", options); + + Assert.Equal(1, forks.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfForksWithStart() + { + var github = Helper.GetAuthenticatedClient(); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + + var forks = await github.Repository.Forks.GetAll("octokit", "octokit.net", options); + + Assert.Equal(1, forks.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctForksBasedOnStartPage() + { + var github = Helper.GetAuthenticatedClient(); + + var startOptions = new ApiOptions + { + PageCount = 1, + PageSize = 3, + StartPage = 1 + }; + + var firstPage = await github.Repository.Forks.GetAll("octokit", "octokit.net", startOptions); + + var skipStartOptions = new ApiOptions + { + PageCount = 1, + PageSize = 3, + StartPage = 2 + }; + + var secondPage = await github.Repository.Forks.GetAll("octokit", "octokit.net", skipStartOptions); + + Assert.Equal(3, firstPage.Count); + Assert.Equal(3, secondPage.Count); + Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); + Assert.NotEqual(firstPage[1].Id, secondPage[1].Id); + Assert.NotEqual(firstPage[2].Id, secondPage[2].Id); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfForksWithoutStartParameterized() + { + var github = Helper.GetAuthenticatedClient(); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 1 + }; + + var repositoryForksListRequest = new RepositoryForksListRequest { Sort = Sort.Newest }; + + var forks = await github.Repository.Forks.GetAll("octokit", "octokit.net", repositoryForksListRequest, options); + + Assert.Equal(1, forks.Count); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfForksWithStartParameterized() + { + var github = Helper.GetAuthenticatedClient(); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 1, + StartPage = 1 + }; + + var repositoryForksListRequest = new RepositoryForksListRequest { Sort = Sort.Newest }; + + var forks = await github.Repository.Forks.GetAll("octokit", "octokit.net", repositoryForksListRequest, options); + + Assert.Equal(1, forks.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctForksBasedOnStartPageParameterized() + { + var github = Helper.GetAuthenticatedClient(); + + var repositoryForksListRequest = new RepositoryForksListRequest { Sort = Sort.Newest }; + + var startOptions = new ApiOptions + { + PageCount = 1, + PageSize = 3, + StartPage = 1 + }; + + var firstPage = await github.Repository.Forks.GetAll("octokit", "octokit.net", repositoryForksListRequest, startOptions); + + var skipStartOptions = new ApiOptions + { + PageCount = 1, + PageSize = 3, + StartPage = 2 + }; + + var secondPage = await github.Repository.Forks.GetAll("octokit", "octokit.net", repositoryForksListRequest, skipStartOptions); + + Assert.Equal(3, firstPage.Count); + Assert.Equal(3, secondPage.Count); + Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); + Assert.NotEqual(firstPage[1].Id, secondPage[1].Id); + Assert.NotEqual(firstPage[2].Id, secondPage[2].Id); + } + + [IntegrationTest] + public async Task ReturnsForksForRepositorySortingTheResultWithOldestFirstWithApiOptions() + { + var github = Helper.GetAuthenticatedClient(); + + var repositoryForksListRequest = new RepositoryForksListRequest { Sort = Sort.Oldest }; + + var startOptions = new ApiOptions + { + PageCount = 1, + PageSize = 3, + StartPage = 1 + }; + + var firstPage = await github.Repository.Forks.GetAll("octokit", "octokit.net", repositoryForksListRequest, startOptions); + var firstPageOrdered = firstPage.OrderBy(r => r.CreatedAt).ToList(); + + var skipStartOptions = new ApiOptions + { + PageCount = 1, + PageSize = 3, + StartPage = 1 + }; + + var secondPage = await github.Repository.Forks.GetAll("octokit", "octokit.net", repositoryForksListRequest, skipStartOptions); + var secondPageOrdered = secondPage.OrderBy(r => r.CreatedAt).ToList(); + + for (var index = 0; index < firstPage.Count; index++) + { + Assert.Equal(firstPageOrdered[index].FullName, firstPage[index].FullName); + } + + for (var index = 0; index < firstPage.Count; index++) + { + Assert.Equal(secondPageOrdered[index].FullName, secondPage[index].FullName); + } + } + [IntegrationTest] public async Task ReturnsForksForRepositorySortingTheResultWithOldestFirst() { diff --git a/Octokit.Tests/Clients/RepositoryForksClientTests.cs b/Octokit.Tests/Clients/RepositoryForksClientTests.cs index 28474a7b8e..a5f436e012 100644 --- a/Octokit.Tests/Clients/RepositoryForksClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryForksClientTests.cs @@ -21,36 +21,93 @@ public void EnsuresNonNullArguments() public class TheGetAllMethod { [Fact] - public void RequestsCorrectUrl() + public async Task RequestsCorrectUrl() { var connection = Substitute.For(); var client = new RepositoriesClient(connection); - client.Forks.GetAll("fake", "repo"); + await client.Forks.GetAll("fake", "repo"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/forks")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/forks"), Args.ApiOptions); } [Fact] - public void RequestsCorrectUrlWithRequestParameters() + public async Task RequestsCorrectUrlWithApiOptions() { var connection = Substitute.For(); var client = new RepositoriesClient(connection); - client.Forks.GetAll("fake", "repo", new RepositoryForksListRequest { Sort = Sort.Stargazers }); + var options = new ApiOptions + { + PageCount = 1, + StartPage = 1, + PageSize = 1 + }; + + await client.Forks.GetAll("fake", "repo", options); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/forks"), options); + } + + [Fact] + public async Task RequestsCorrectUrlWithRequestParameters() + { + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + + await client.Forks.GetAll("fake", "repo", new RepositoryForksListRequest { Sort = Sort.Stargazers }); connection.Received().GetAll( Arg.Is(u => u.ToString() == "repos/fake/repo/forks"), - Arg.Is>(d => d["sort"] == "stargazers")); + Arg.Is>(d => d["sort"] == "stargazers"), Args.ApiOptions); } [Fact] - public async Task EnsuresNonNullArguments() + public async Task RequestsCorrectUrlWithRequestParametersWithApiOptions() { - var client = new RepositoriesClient(Substitute.For()); + var connection = Substitute.For(); + var client = new RepositoriesClient(connection); + + var options = new ApiOptions + { + PageCount = 1, + StartPage = 1, + PageSize = 1 + }; + + await client.Forks.GetAll("fake", "repo", new RepositoryForksListRequest { Sort = Sort.Stargazers }, options); - await Assert.ThrowsAsync(() => client.Forks.GetAll(null, "name")); - await Assert.ThrowsAsync(() => client.Forks.GetAll("owner", null)); + connection.Received().GetAll( + Arg.Is(u => u.ToString() == "repos/fake/repo/forks"), + Arg.Is>(d => d["sort"] == "stargazers"), options); + } + + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new RepositoryForksClient(Substitute.For()); + + await Assert.ThrowsAsync(() => client.GetAll(null, "name")); + await Assert.ThrowsAsync(() => client.GetAll("owner", null)); + await Assert.ThrowsAsync(() => client.GetAll(null, "name", ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAll("owner", null, ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAll("owner", "name", (ApiOptions)null)); + await Assert.ThrowsAsync(() => client.GetAll(null, "name", new RepositoryForksListRequest())); + await Assert.ThrowsAsync(() => client.GetAll("owner", null, new RepositoryForksListRequest())); + await Assert.ThrowsAsync(() => client.GetAll("owner", "name", (RepositoryForksListRequest)null)); + await Assert.ThrowsAsync(() => client.GetAll(null, "name", new RepositoryForksListRequest(), ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAll("owner", null, new RepositoryForksListRequest(), ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAll("owner", "name", null, ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAll("owner", "name", new RepositoryForksListRequest(), null)); + + await Assert.ThrowsAsync(() => client.GetAll("", "name")); + await Assert.ThrowsAsync(() => client.GetAll("owner", "")); + await Assert.ThrowsAsync(() => client.GetAll("", "name", ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAll("owner", "", ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAll("", "name", new RepositoryForksListRequest())); + await Assert.ThrowsAsync(() => client.GetAll("owner", "", new RepositoryForksListRequest())); + await Assert.ThrowsAsync(() => client.GetAll("", "name", new RepositoryForksListRequest(), ApiOptions.None)); + await Assert.ThrowsAsync(() => client.GetAll("owner", "", new RepositoryForksListRequest(), ApiOptions.None)); } } @@ -61,6 +118,7 @@ public void RequestsCorrectUrl() { var connection = Substitute.For(); var client = new RepositoriesClient(connection); + var newRepositoryFork = new NewRepositoryFork(); client.Forks.Create("fake", "repo", newRepositoryFork); @@ -71,23 +129,14 @@ public void RequestsCorrectUrl() [Fact] public async Task EnsuresNonNullArguments() { - var client = new RepositoriesClient(Substitute.For()); - - await Assert.ThrowsAsync(() => client.Forks.Create(null, "name", new NewRepositoryFork())); - await Assert.ThrowsAsync(() => client.Forks.Create("owner", null, new NewRepositoryFork())); - await Assert.ThrowsAsync(() => client.Forks.Create("owner", "name", null)); - } - - [Fact] - public void UsesTheSuppliedHook() - { - var connection = Substitute.For(); - var client = new RepositoriesClient(connection); - var newRepositoryFork = new NewRepositoryFork { Organization = "aName" }; + var client = new RepositoryForksClient(Substitute.For()); - client.Forks.Create("owner", "repo", newRepositoryFork); + await Assert.ThrowsAsync(() => client.Create(null, "name", new NewRepositoryFork())); + await Assert.ThrowsAsync(() => client.Create("owner", null, new NewRepositoryFork())); + await Assert.ThrowsAsync(() => client.Create("owner", "name", null)); - connection.Received().Post(Arg.Any(), newRepositoryFork); + await Assert.ThrowsAsync(() => client.Create("", "name", new NewRepositoryFork())); + await Assert.ThrowsAsync(() => client.Create("owner", "", new NewRepositoryFork())); } } } diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index e84eb3cf5a..81bf38c134 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -239,6 +239,7 @@ + diff --git a/Octokit.Tests/Reactive/ObservableRepositoryForksClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryForksClientTests.cs new file mode 100644 index 0000000000..20f2756c99 --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableRepositoryForksClientTests.cs @@ -0,0 +1,143 @@ +using System; +using NSubstitute; +using Octokit.Reactive; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableRepositoryForksClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws( + () => new ObservableRepositoryForksClient(null)); + } + } + + public class TheGetAllMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableRepositoryForksClient(gitHubClient); + + client.GetAll("fake", "repo"); + + gitHubClient.Received().Repository.Forks.GetAll("fake", "repo"); + } + + [Fact] + public void RequestsCorrectUrlWithApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableRepositoryForksClient(gitHubClient); + + var options = new ApiOptions + { + PageCount = 1, + StartPage = 1, + PageSize = 1 + }; + + client.GetAll("fake", "repo", options); + + gitHubClient.Received().Repository.Forks.GetAll("fake", "repo", options); + } + + [Fact] + public void RequestsCorrectUrlWithRequestParameters() + { + var gitHubClient = Substitute.For(); + var client = new ObservableRepositoryForksClient(gitHubClient); + + var repositoryForksListRequest = new RepositoryForksListRequest { Sort = Sort.Stargazers }; + + client.GetAll("fake", "repo", repositoryForksListRequest); + + gitHubClient.Received().Repository.Forks.GetAll( + "fake", "repo", repositoryForksListRequest); + } + + [Fact] + public void RequestsCorrectUrlWithRequestParametersWithApiOptions() + { + var gitHubClient = Substitute.For(); + var client = new ObservableRepositoryForksClient(gitHubClient); + + var options = new ApiOptions + { + PageCount = 1, + StartPage = 1, + PageSize = 1 + }; + + var repositoryForksListRequest = new RepositoryForksListRequest { Sort = Sort.Stargazers }; + + client.GetAll("fake", "repo", repositoryForksListRequest, options); + + gitHubClient.Received().Repository.Forks.GetAll("fake", "name", repositoryForksListRequest, options); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservableRepositoryForksClient(Substitute.For()); + + Assert.Throws(() => client.GetAll(null, "name")); + Assert.Throws(() => client.GetAll("owner", null)); + Assert.Throws(() => client.GetAll(null, "name", ApiOptions.None)); + Assert.Throws(() => client.GetAll("owner", null, ApiOptions.None)); + Assert.Throws(() => client.GetAll("owner", "name", (ApiOptions)null)); + Assert.Throws(() => client.GetAll(null, "name", new RepositoryForksListRequest())); + Assert.Throws(() => client.GetAll("owner", null, new RepositoryForksListRequest())); + Assert.Throws(() => client.GetAll("owner", "name", (RepositoryForksListRequest)null)); + Assert.Throws(() => client.GetAll(null, "name", new RepositoryForksListRequest(), ApiOptions.None)); + Assert.Throws(() => client.GetAll("owner", null, new RepositoryForksListRequest(), ApiOptions.None)); + Assert.Throws(() => client.GetAll("owner", "name", null, ApiOptions.None)); + Assert.Throws(() => client.GetAll("owner", "name", new RepositoryForksListRequest(), null)); + + Assert.Throws(() => client.GetAll("", "name")); + Assert.Throws(() => client.GetAll("owner", "")); + Assert.Throws(() => client.GetAll("", "name", ApiOptions.None)); + Assert.Throws(() => client.GetAll("owner", "", ApiOptions.None)); + Assert.Throws(() => client.GetAll("", "name", new RepositoryForksListRequest())); + Assert.Throws(() => client.GetAll("owner", "", new RepositoryForksListRequest())); + Assert.Throws(() => client.GetAll("", "name", new RepositoryForksListRequest(), ApiOptions.None)); + Assert.Throws(() => client.GetAll("owner", "", new RepositoryForksListRequest(), ApiOptions.None)); + } + } + + public class TheCreateMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var gitHubClient = Substitute.For(); + var client = new ObservableRepositoryForksClient(gitHubClient); + + var newRepositoryFork = new NewRepositoryFork(); + + client.Create("fake", "repo", newRepositoryFork); + + gitHubClient.Received().Repository.Forks.Create("fake", "repo", newRepositoryFork); + } + + [Fact] + public void EnsuresNonNullArguments() + { + var client = new ObservableRepositoryForksClient(Substitute.For()); + + Assert.Throws(() => client.Create(null, "name", new NewRepositoryFork())); + Assert.Throws(() => client.Create("owner", null, new NewRepositoryFork())); + Assert.Throws(() => client.Create("owner", "name", null)); + + Assert.Throws(() => client.Create("", "name", new NewRepositoryFork())); + Assert.Throws(() => client.Create("owner", "", new NewRepositoryFork())); + } + } + } +} From 118bc319f697ec6c6ba87c00384e28fba420d505 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Thu, 9 Jun 2016 14:43:42 +0700 Subject: [PATCH 61/65] fixed remarks --- Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs | 5 ++--- Octokit/Clients/RepositoryForksClient.cs | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs index d011bc19ba..f4c2a0f322 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs @@ -57,7 +57,6 @@ public IObservable GetAll(string owner, string repositoryName, Repos { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - Ensure.ArgumentNotNull(request, "request"); return GetAll(owner, repositoryName, request, ApiOptions.None); } @@ -71,10 +70,10 @@ public IObservable GetAll(string owner, string repositoryName, Repos { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - Ensure.ArgumentNotNull(request, "request"); Ensure.ArgumentNotNull(options, "options"); - return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, repositoryName), request.ToParametersDictionary(), options); + return request == null ? _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, repositoryName), options) : + _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, repositoryName), request.ToParametersDictionary(), options); } /// diff --git a/Octokit/Clients/RepositoryForksClient.cs b/Octokit/Clients/RepositoryForksClient.cs index 9192040311..749a9418cb 100644 --- a/Octokit/Clients/RepositoryForksClient.cs +++ b/Octokit/Clients/RepositoryForksClient.cs @@ -50,7 +50,6 @@ public Task> GetAll(string owner, string repositoryNam { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - Ensure.ArgumentNotNull(request, "request"); return GetAll(owner, repositoryName, request, ApiOptions.None); } @@ -64,10 +63,11 @@ public Task> GetAll(string owner, string repositoryNam { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - Ensure.ArgumentNotNull(request, "request"); Ensure.ArgumentNotNull(options, "options"); - return ApiConnection.GetAll(ApiUrls.RepositoryForks(owner, repositoryName), request.ToParametersDictionary(), options); + return request == null + ? ApiConnection.GetAll(ApiUrls.RepositoryForks(owner, repositoryName), options) : + ApiConnection.GetAll(ApiUrls.RepositoryForks(owner, repositoryName), request.ToParametersDictionary(), options); } /// From 988a6490d6499f78d45154367241b946d0c7e717 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Thu, 9 Jun 2016 14:47:55 +0700 Subject: [PATCH 62/65] fixed unut tests --- .../Clients/RepositoryForksClientTests.cs | 30 +++++++++---------- .../ObservableRepositoryForksClientTests.cs | 2 -- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/Octokit.Tests/Clients/RepositoryForksClientTests.cs b/Octokit.Tests/Clients/RepositoryForksClientTests.cs index a5f436e012..32d8bccbaf 100644 --- a/Octokit.Tests/Clients/RepositoryForksClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryForksClientTests.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 @@ -14,7 +14,7 @@ public class TheCtor public void EnsuresNonNullArguments() { Assert.Throws( - () => new RepositoryForksClient(null)); + () => new RepositoryForksClient(null)); } } @@ -24,9 +24,9 @@ public class TheGetAllMethod public async Task RequestsCorrectUrl() { var connection = Substitute.For(); - var client = new RepositoriesClient(connection); + var client = new RepositoryForksClient(connection); - await client.Forks.GetAll("fake", "repo"); + await client.GetAll("fake", "repo"); connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/forks"), Args.ApiOptions); } @@ -35,7 +35,7 @@ public async Task RequestsCorrectUrl() public async Task RequestsCorrectUrlWithApiOptions() { var connection = Substitute.For(); - var client = new RepositoriesClient(connection); + var client = new RepositoryForksClient(connection); var options = new ApiOptions { @@ -44,7 +44,7 @@ public async Task RequestsCorrectUrlWithApiOptions() PageSize = 1 }; - await client.Forks.GetAll("fake", "repo", options); + await client.GetAll("fake", "repo", options); connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/forks"), options); } @@ -53,9 +53,9 @@ public async Task RequestsCorrectUrlWithApiOptions() public async Task RequestsCorrectUrlWithRequestParameters() { var connection = Substitute.For(); - var client = new RepositoriesClient(connection); + var client = new RepositoryForksClient(connection); - await client.Forks.GetAll("fake", "repo", new RepositoryForksListRequest { Sort = Sort.Stargazers }); + await client.GetAll("fake", "repo", new RepositoryForksListRequest { Sort = Sort.Stargazers }); connection.Received().GetAll( Arg.Is(u => u.ToString() == "repos/fake/repo/forks"), @@ -66,7 +66,7 @@ public async Task RequestsCorrectUrlWithRequestParameters() public async Task RequestsCorrectUrlWithRequestParametersWithApiOptions() { var connection = Substitute.For(); - var client = new RepositoriesClient(connection); + var client = new RepositoryForksClient(connection); var options = new ApiOptions { @@ -75,7 +75,7 @@ public async Task RequestsCorrectUrlWithRequestParametersWithApiOptions() PageSize = 1 }; - await client.Forks.GetAll("fake", "repo", new RepositoryForksListRequest { Sort = Sort.Stargazers }, options); + await client.GetAll("fake", "repo", new RepositoryForksListRequest { Sort = Sort.Stargazers }, options); connection.Received().GetAll( Arg.Is(u => u.ToString() == "repos/fake/repo/forks"), @@ -94,10 +94,8 @@ public async Task EnsuresNonNullArguments() await Assert.ThrowsAsync(() => client.GetAll("owner", "name", (ApiOptions)null)); await Assert.ThrowsAsync(() => client.GetAll(null, "name", new RepositoryForksListRequest())); await Assert.ThrowsAsync(() => client.GetAll("owner", null, new RepositoryForksListRequest())); - await Assert.ThrowsAsync(() => client.GetAll("owner", "name", (RepositoryForksListRequest)null)); await Assert.ThrowsAsync(() => client.GetAll(null, "name", new RepositoryForksListRequest(), ApiOptions.None)); await Assert.ThrowsAsync(() => client.GetAll("owner", null, new RepositoryForksListRequest(), ApiOptions.None)); - await Assert.ThrowsAsync(() => client.GetAll("owner", "name", null, ApiOptions.None)); await Assert.ThrowsAsync(() => client.GetAll("owner", "name", new RepositoryForksListRequest(), null)); await Assert.ThrowsAsync(() => client.GetAll("", "name")); @@ -117,11 +115,11 @@ public class TheCreateMethod public void RequestsCorrectUrl() { var connection = Substitute.For(); - var client = new RepositoriesClient(connection); + var client = new RepositoryForksClient(connection); var newRepositoryFork = new NewRepositoryFork(); - client.Forks.Create("fake", "repo", newRepositoryFork); + client.Create("fake", "repo", newRepositoryFork); connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/forks"), newRepositoryFork); } @@ -140,4 +138,4 @@ public async Task EnsuresNonNullArguments() } } } -} \ No newline at end of file +} diff --git a/Octokit.Tests/Reactive/ObservableRepositoryForksClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryForksClientTests.cs index 20f2756c99..77acb6603e 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryForksClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryForksClientTests.cs @@ -94,10 +94,8 @@ public void EnsuresNonNullArguments() Assert.Throws(() => client.GetAll("owner", "name", (ApiOptions)null)); Assert.Throws(() => client.GetAll(null, "name", new RepositoryForksListRequest())); Assert.Throws(() => client.GetAll("owner", null, new RepositoryForksListRequest())); - Assert.Throws(() => client.GetAll("owner", "name", (RepositoryForksListRequest)null)); Assert.Throws(() => client.GetAll(null, "name", new RepositoryForksListRequest(), ApiOptions.None)); Assert.Throws(() => client.GetAll("owner", null, new RepositoryForksListRequest(), ApiOptions.None)); - Assert.Throws(() => client.GetAll("owner", "name", null, ApiOptions.None)); Assert.Throws(() => client.GetAll("owner", "name", new RepositoryForksListRequest(), null)); Assert.Throws(() => client.GetAll("", "name")); From 02a13df93bc33463e3582635361054652cfc5aa8 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Thu, 9 Jun 2016 16:27:49 +0700 Subject: [PATCH 63/65] modified xml docs --- .../IObservableRepositoryForksClient.cs | 67 ++++++++++---- .../ObservableRepositoryForksClient.cs | 83 ++++++++++++------ Octokit/Clients/IRepositoryForksClient.cs | 67 ++++++++++---- Octokit/Clients/RepositoryForksClient.cs | 87 +++++++++++++------ 4 files changed, 214 insertions(+), 90 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs index 212d582bbd..ccc58d70ab 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryForksClient.cs @@ -2,41 +2,72 @@ namespace Octokit.Reactive { + /// + /// A client for GitHub's Repository Forks API. + /// + /// + /// See the Forks API documentation for more information. + /// public interface IObservableRepositoryForksClient { /// /// Gets the list of forks defined for a repository /// - /// See API documentation for more information. - /// - IObservable GetAll(string owner, string repositoryName); - + /// + /// See API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// A of s representing forks of specified repository. + IObservable GetAll(string owner, string name); + /// /// Gets the list of forks defined for a repository /// - /// See API documentation for more information. - /// - IObservable GetAll(string owner, string repositoryName, ApiOptions options); - + /// + /// See API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// A of s representing forks of specified repository. + IObservable GetAll(string owner, string name, ApiOptions options); + /// /// Gets the list of forks defined for a repository /// - /// See API documentation for more information. - /// - IObservable GetAll(string owner, string repositoryName, RepositoryForksListRequest request); - + /// + /// See API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Used to request and filter a list of repository forks + /// A of s representing forks of specified repository. + IObservable GetAll(string owner, string name, RepositoryForksListRequest request); + /// /// Gets the list of forks defined for a repository /// - /// See API documentation for more information. - /// - IObservable GetAll(string owner, string repositoryName, RepositoryForksListRequest request, ApiOptions options); + /// + /// See API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Used to request and filter a list of repository forks + /// Options for changing the API response + /// A of s representing forks of specified repository. + IObservable GetAll(string owner, string name, RepositoryForksListRequest request, ApiOptions options); /// /// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization. /// - /// See API documentation for more information. - /// - IObservable Create(string owner, string repositoryName, NewRepositoryFork fork); + /// + /// See API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Used to fork a repository + /// A of representing the created fork of specified repository. + IObservable Create(string owner, string name, NewRepositoryFork fork); } } diff --git a/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs index f4c2a0f322..25b0b3257d 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryForksClient.cs @@ -4,6 +4,12 @@ namespace Octokit.Reactive { + /// + /// A client for GitHub's Repository Forks API. + /// + /// + /// See the Forks API documentation for more information. + /// public class ObservableRepositoryForksClient : IObservableRepositoryForksClient { readonly IRepositoryForksClient _client; @@ -24,70 +30,95 @@ public ObservableRepositoryForksClient(IGitHubClient client) /// /// Gets the list of forks defined for a repository /// - /// See API documentation for more information. - /// - public IObservable GetAll(string owner, string repositoryName) + /// + /// See API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// A of s representing forks of specified repository. + public IObservable GetAll(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return GetAll(owner, repositoryName, ApiOptions.None); + return GetAll(owner, name, ApiOptions.None); } /// /// Gets the list of forks defined for a repository /// - /// See API documentation for more information. - /// - public IObservable GetAll(string owner, string repositoryName, ApiOptions options) + /// + /// See API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// A of s representing forks of specified repository. + public IObservable GetAll(string owner, string name, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(options, "options"); - return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, repositoryName), options); + return _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, name), options); } /// /// Gets the list of forks defined for a repository /// - /// See API documentation for more information. - /// - public IObservable GetAll(string owner, string repositoryName, RepositoryForksListRequest request) + /// + /// See API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Used to request and filter a list of repository forks + /// A of s representing forks of specified repository. + public IObservable GetAll(string owner, string name, RepositoryForksListRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return GetAll(owner, repositoryName, request, ApiOptions.None); + return GetAll(owner, name, request, ApiOptions.None); } /// /// Gets the list of forks defined for a repository /// - /// See API documentation for more information. - /// - public IObservable GetAll(string owner, string repositoryName, RepositoryForksListRequest request, ApiOptions options) + /// + /// See API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Used to request and filter a list of repository forks + /// Options for changing the API response + /// A of s representing forks of specified repository. + public IObservable GetAll(string owner, string name, RepositoryForksListRequest request, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(options, "options"); - return request == null ? _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, repositoryName), options) : - _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, repositoryName), request.ToParametersDictionary(), options); + return request == null ? _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, name), options) : + _connection.GetAndFlattenAllPages(ApiUrls.RepositoryForks(owner, name), request.ToParametersDictionary(), options); } /// /// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization. /// - /// See API documentation for more information. - /// - public IObservable Create(string owner, string repositoryName, NewRepositoryFork fork) + /// + /// See API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Used to fork a repository + /// A of representing the created fork of specified repository. + public IObservable Create(string owner, string name, NewRepositoryFork fork) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(fork, "fork"); - return _client.Create(owner, repositoryName, fork).ToObservable(); + return _client.Create(owner, name, fork).ToObservable(); } } } \ No newline at end of file diff --git a/Octokit/Clients/IRepositoryForksClient.cs b/Octokit/Clients/IRepositoryForksClient.cs index 76ac2864d3..742b38d0b1 100644 --- a/Octokit/Clients/IRepositoryForksClient.cs +++ b/Octokit/Clients/IRepositoryForksClient.cs @@ -3,41 +3,72 @@ namespace Octokit { + /// + /// A client for GitHub's Repository Forks API. + /// + /// + /// See the Forks API documentation for more information. + /// public interface IRepositoryForksClient { /// /// Gets the list of forks defined for a repository /// - /// See API documentation for more information. - /// - Task> GetAll(string owner, string repositoryName); - + /// + /// See API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// A of s representing forks of specified repository. + Task> GetAll(string owner, string name); + /// /// Gets the list of forks defined for a repository /// - /// See API documentation for more information. - /// - Task> GetAll(string owner, string repositoryName, ApiOptions options); - + /// + /// See API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// A of s representing forks of specified repository. + Task> GetAll(string owner, string name, ApiOptions options); + /// /// Gets the list of forks defined for a repository /// - /// See API documentation for more information. - /// - Task> GetAll(string owner, string repositoryName, RepositoryForksListRequest request); - + /// + /// See API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Used to request and filter a list of repository forks + /// A of s representing forks of specified repository. + Task> GetAll(string owner, string name, RepositoryForksListRequest request); + /// /// Gets the list of forks defined for a repository /// - /// See API documentation for more information. - /// - Task> GetAll(string owner, string repositoryName, RepositoryForksListRequest request, ApiOptions options); + /// + /// See API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Used to request and filter a list of repository forks + /// Options for changing the API response + /// A of s representing forks of specified repository. + Task> GetAll(string owner, string name, RepositoryForksListRequest request, ApiOptions options); /// /// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization. /// - /// See API documentation for more information. - /// - Task Create(string owner, string repositoryName, NewRepositoryFork fork); + /// + /// See API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Used to fork a repository + /// A representing the created fork of specified repository. + Task Create(string owner, string name, NewRepositoryFork fork); } } diff --git a/Octokit/Clients/RepositoryForksClient.cs b/Octokit/Clients/RepositoryForksClient.cs index 749a9418cb..0915cde32e 100644 --- a/Octokit/Clients/RepositoryForksClient.cs +++ b/Octokit/Clients/RepositoryForksClient.cs @@ -3,6 +3,12 @@ namespace Octokit { + /// + /// A client for GitHub's Repository Forks API. + /// + /// + /// See the Forks API documentation for more information. + /// public class RepositoryForksClient : ApiClient, IRepositoryForksClient { /// @@ -17,71 +23,96 @@ public RepositoryForksClient(IApiConnection apiConnection) /// /// Gets the list of forks defined for a repository /// - /// See API documentation for more information. - /// - public Task> GetAll(string owner, string repositoryName) + /// + /// See API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// A of s representing forks of specified repository. + public Task> GetAll(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return GetAll(owner, repositoryName, ApiOptions.None); + return GetAll(owner, name, ApiOptions.None); } /// /// Gets the list of forks defined for a repository /// - /// See API documentation for more information. - /// - public Task> GetAll(string owner, string repositoryName, ApiOptions options) + /// + /// See API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// A of s representing forks of specified repository. + public Task> GetAll(string owner, string name, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(options, "options"); - return ApiConnection.GetAll(ApiUrls.RepositoryForks(owner, repositoryName), options); + return ApiConnection.GetAll(ApiUrls.RepositoryForks(owner, name), options); } /// /// Gets the list of forks defined for a repository /// - /// See API documentation for more information. - /// - public Task> GetAll(string owner, string repositoryName, RepositoryForksListRequest request) + /// + /// See API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Used to request and filter a list of repository forks + /// A of s representing forks of specified repository. + public Task> GetAll(string owner, string name, RepositoryForksListRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return GetAll(owner, repositoryName, request, ApiOptions.None); + return GetAll(owner, name, request, ApiOptions.None); } /// /// Gets the list of forks defined for a repository /// - /// See API documentation for more information. - /// - public Task> GetAll(string owner, string repositoryName, RepositoryForksListRequest request, ApiOptions options) + /// + /// See API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Used to request and filter a list of repository forks + /// Options for changing the API response + /// A of s representing forks of specified repository. + public Task> GetAll(string owner, string name, RepositoryForksListRequest request, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(options, "options"); - return request == null - ? ApiConnection.GetAll(ApiUrls.RepositoryForks(owner, repositoryName), options) : - ApiConnection.GetAll(ApiUrls.RepositoryForks(owner, repositoryName), request.ToParametersDictionary(), options); + return request == null + ? ApiConnection.GetAll(ApiUrls.RepositoryForks(owner, name), options) : + ApiConnection.GetAll(ApiUrls.RepositoryForks(owner, name), request.ToParametersDictionary(), options); } /// /// Creates a fork for a repository. Specify organization in the fork parameter to create for an organization. /// - /// See API documentation for more information. - /// - public Task Create(string owner, string repositoryName, NewRepositoryFork fork) + /// + /// See API documentation for more information. + /// + /// The owner of the repository + /// The name of the repository + /// Used to fork a repository + /// A representing the created fork of specified repository. + public Task Create(string owner, string name, NewRepositoryFork fork) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(fork, "fork"); - return ApiConnection.Post(ApiUrls.RepositoryForks(owner, repositoryName), fork); + return ApiConnection.Post(ApiUrls.RepositoryForks(owner, name), fork); } } -} \ No newline at end of file +} From ccd9654727a849f102e1eae81266626b671467f5 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Thu, 9 Jun 2016 15:06:02 +0200 Subject: [PATCH 64/65] fix some grammar and tests --- .../Enterprise/IObservableEnterpriseAdminStatsClient.cs | 3 +-- .../Clients/IObservableCommitCommentReactionsClient.cs | 2 +- .../Clients/IObservableIssueCommentReactionsClient.cs | 2 +- .../Clients/IObservableIssueReactionsClient.cs | 2 +- .../Clients/ObservableIssueCommentReactionsClient.cs | 4 ++-- .../Clients/IssueCommentReactionsClientTests.cs | 2 +- .../Clients/IssueReactionsClientTests.cs | 2 +- .../PullRequestReviewCommentReactionsClientTests.cs | 8 +++++++- 8 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs index 282a221930..62dccdb073 100644 --- a/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs +++ b/Octokit.Reactive/Clients/Enterprise/IObservableEnterpriseAdminStatsClient.cs @@ -1,5 +1,4 @@ -using Octokit; -using System; +using System; using System.Diagnostics.CodeAnalysis; namespace Octokit.Reactive diff --git a/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs b/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs index 8a0f799be6..174863fa62 100644 --- a/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs @@ -5,7 +5,7 @@ namespace Octokit.Reactive public interface IObservableCommitCommentReactionsClient { /// - /// Creates a reaction for an specified Commit Comment + /// Creates a reaction for a specified Commit Comment /// /// https://developer.github.com/v3/reactions/#create-reaction-for-a-commit-comment /// The owner of the repository diff --git a/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs b/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs index 6e41be81d1..6ee2e35f13 100644 --- a/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssueCommentReactionsClient.cs @@ -5,7 +5,7 @@ namespace Octokit.Reactive public interface IObservableIssueCommentReactionsClient { /// - /// Creates a reaction for an specified Issue Comment + /// Creates a reaction for a specified Issue Comment /// /// https://developer.github.com/v3/reactions/#create-reaction-for-an-issue-comment /// The owner of the repository diff --git a/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs b/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs index 829c699742..2a12a9049a 100644 --- a/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs @@ -5,7 +5,7 @@ namespace Octokit.Reactive public interface IObservableIssueReactionsClient { /// - /// Creates a reaction for an specified Issue. + /// Creates a reaction for a specified Issue. /// /// https://developer.github.com/v3/reactions/#create-reaction-for-an-issue /// The owner of the repository diff --git a/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs index a7c64ecf3a..3bb42d9f7a 100644 --- a/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssueCommentReactionsClient.cs @@ -19,7 +19,7 @@ public ObservableIssueCommentReactionsClient(IGitHubClient client) } /// - /// Creates a reaction for an specified Issue Comment + /// Creates a reaction for a specified Issue Comment /// /// https://developer.github.com/v3/reactions/#create-reaction-for-an-issue-comment /// The owner of the repository @@ -37,7 +37,7 @@ public IObservable Create(string owner, string name, int number, NewRe } /// - /// List reactions for an specified Issue Comment + /// List reactions for a specified Issue Comment /// /// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment /// The owner of the repository diff --git a/Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs index d6193bde62..210a551e83 100644 --- a/Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs @@ -29,7 +29,7 @@ public async Task CanCreateReaction() Assert.NotNull(issue); - var issueComment = await _issuesClient.Comment.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Id, "A test comment"); + var issueComment = await _issuesClient.Comment.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, "A test comment"); Assert.NotNull(issueComment); diff --git a/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs index a7e20fad65..32f263fa20 100644 --- a/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs @@ -29,7 +29,7 @@ public async Task CanCreateReaction() Assert.NotNull(issue); - var issueReaction = await _github.Reaction.Issue.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Id, new NewReaction(ReactionType.Heart)); + var issueReaction = await _github.Reaction.Issue.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new NewReaction(ReactionType.Heart)); Assert.NotNull(issueReaction); diff --git a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs index cc74c04b75..b705bfa847 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs @@ -1,10 +1,11 @@ using Octokit; using Octokit.Tests.Integration; using Octokit.Tests.Integration.Helpers; +using System; using System.Threading.Tasks; using Xunit; -public class PullRequestReviewCommentReactionsClientTests +public class PullRequestReviewCommentReactionsClientTests : IDisposable { private readonly IGitHubClient _github; private readonly IPullRequestReviewCommentsClient _client; @@ -142,6 +143,11 @@ static void AssertComment(PullRequestReviewComment comment, string body, int pos Assert.Equal(position, comment.Position); } + public void Dispose() + { + _context.Dispose(); + } + class PullRequestData { public int Number { get; set; } From ff0c9dd2c281a27ca530856b2a44388b5f6481e1 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Fri, 10 Jun 2016 07:35:56 +1000 Subject: [PATCH 65/65] Fix grammar --- Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs | 2 +- Octokit/Clients/ICommitCommentReactionsClient.cs | 2 +- Octokit/Clients/IIssueCommentReactionsClient.cs | 4 ++-- Octokit/Clients/IIssueReactionsClient.cs | 4 ++-- Octokit/Clients/IssueCommentReactionsClient.cs | 4 ++-- Octokit/Clients/IssueReactionsClient.cs | 4 ++-- Octokit/Helpers/ApiUrls.cs | 6 +++--- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs b/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs index 2a12a9049a..3cfc109bb1 100644 --- a/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssueReactionsClient.cs @@ -16,7 +16,7 @@ public interface IObservableIssueReactionsClient IObservable Create(string owner, string name, int number, NewReaction reaction); /// - /// List reactions for an specified Issue. + /// List reactions for a specified Issue. /// /// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue /// The owner of the repository diff --git a/Octokit/Clients/ICommitCommentReactionsClient.cs b/Octokit/Clients/ICommitCommentReactionsClient.cs index 269c9644e8..7e1c73bfd0 100644 --- a/Octokit/Clients/ICommitCommentReactionsClient.cs +++ b/Octokit/Clients/ICommitCommentReactionsClient.cs @@ -6,7 +6,7 @@ namespace Octokit public interface ICommitCommentReactionsClient { /// - /// Creates a reaction for an specified Commit Comment + /// Creates a reaction for a specified Commit Comment /// /// https://developer.github.com/v3/reactions/#create-reaction-for-a-commit-comment /// The owner of the repository diff --git a/Octokit/Clients/IIssueCommentReactionsClient.cs b/Octokit/Clients/IIssueCommentReactionsClient.cs index e524f6b9e5..6576201dd1 100644 --- a/Octokit/Clients/IIssueCommentReactionsClient.cs +++ b/Octokit/Clients/IIssueCommentReactionsClient.cs @@ -6,7 +6,7 @@ namespace Octokit public interface IIssueCommentReactionsClient { /// - /// Creates a reaction for an specified Issue Comment + /// Creates a reaction for a specified Issue Comment /// /// https://developer.github.com/v3/reactions/#create-reaction-for-an-issue-comment /// The owner of the repository @@ -17,7 +17,7 @@ public interface IIssueCommentReactionsClient Task Create(string owner, string name, int number, NewReaction reaction); /// - /// Get all reactions for an specified Issue Comment + /// Get all reactions for a specified Issue Comment /// /// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment /// The owner of the repository diff --git a/Octokit/Clients/IIssueReactionsClient.cs b/Octokit/Clients/IIssueReactionsClient.cs index f30c93c943..478e0b2b8a 100644 --- a/Octokit/Clients/IIssueReactionsClient.cs +++ b/Octokit/Clients/IIssueReactionsClient.cs @@ -6,7 +6,7 @@ namespace Octokit public interface IIssueReactionsClient { /// - /// Get all reactions for an specified Issue + /// Get all reactions for a specified Issue /// /// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue /// The owner of the repository @@ -16,7 +16,7 @@ public interface IIssueReactionsClient Task> GetAll(string owner, string name, int number); /// - /// Creates a reaction for an specified Issue + /// Creates a reaction for a specified Issue /// /// https://developer.github.com/v3/reactions/#create-reaction-for-an-issue /// The owner of the repository diff --git a/Octokit/Clients/IssueCommentReactionsClient.cs b/Octokit/Clients/IssueCommentReactionsClient.cs index 950159baf8..352475d59c 100644 --- a/Octokit/Clients/IssueCommentReactionsClient.cs +++ b/Octokit/Clients/IssueCommentReactionsClient.cs @@ -12,7 +12,7 @@ public IssueCommentReactionsClient(IApiConnection apiConnection) } /// - /// Creates a reaction for an specified Issue Comment + /// Creates a reaction for a specified Issue Comment /// /// https://developer.github.com/v3/reactions/#create-reactions-for-an-issue-comment /// The owner of the repository @@ -30,7 +30,7 @@ public Task Create(string owner, string name, int number, NewReaction } /// - /// Get all reactions for an specified Issue Comment + /// Get all reactions for a specified Issue Comment /// /// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment /// The owner of the repository diff --git a/Octokit/Clients/IssueReactionsClient.cs b/Octokit/Clients/IssueReactionsClient.cs index ecb96c0a27..d630bfcee9 100644 --- a/Octokit/Clients/IssueReactionsClient.cs +++ b/Octokit/Clients/IssueReactionsClient.cs @@ -12,7 +12,7 @@ public IssueReactionsClient(IApiConnection apiConnection) } /// - /// Creates a reaction for an specified Issue + /// Creates a reaction for a specified Issue /// /// https://developer.github.com/v3/reactions/#create-reactions-for-an-issue /// The owner of the repository @@ -30,7 +30,7 @@ public Task Create(string owner, string name, int number, NewReaction } /// - /// Get all reactions for an specified Issue + /// Get all reactions for a specified Issue /// /// https://developer.github.com/v3/reactions/#list-reactions-for-an-issue /// The owner of the repository diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 7b0d2c2073..ca28659dff 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -319,7 +319,7 @@ public static Uri IssueLock(string owner, string name, int number) } /// - /// Returns the for the reaction of an specified issue. + /// Returns the for the reaction of a specified issue. /// /// The owner of the repository /// The name of the repository @@ -366,7 +366,7 @@ public static Uri IssueComment(string owner, string name, int id) } /// - /// Returns the for the reaction of an specified issue comment. + /// Returns the for the reaction of a specified issue comment. /// /// The owner of the repository /// The name of the repository @@ -1208,7 +1208,7 @@ public static Uri PullRequestReviewComment(string owner, string name, int number } /// - /// Returns the for the reaction of an specified pull request review comment. + /// Returns the for the reaction of a specified pull request review comment. /// /// The owner of the repository /// The name of the repository