From 7794aaf421148618418dafe4d3398d1a8a61ddd2 Mon Sep 17 00:00:00 2001 From: maddin2016 Date: Thu, 2 Jun 2016 08:49:40 +0200 Subject: [PATCH] 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 00000000..f50d9ed0 --- /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 c6a81129..dad6ab1a 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs @@ -376,69 +376,4 @@ public class RepositoryCommentsClientTests _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 be61279e..a2a98af7 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -77,6 +77,7 @@ +