From 0aaf850f07b67fe35586fd9d63ec55e3f233b6c3 Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Wed, 15 Jun 2016 18:55:15 +0700 Subject: [PATCH] added new integration tests --- ...equestReviewCommentReactionsClientTests.cs | 78 ++++++++++++++++++- 1 file changed, 74 insertions(+), 4 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs index b705bfa8..9be26983 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs @@ -1,8 +1,8 @@ -using Octokit; +using System; +using System.Threading.Tasks; +using Octokit; using Octokit.Tests.Integration; using Octokit.Tests.Integration.Helpers; -using System; -using System.Threading.Tasks; using Xunit; public class PullRequestReviewCommentReactionsClientTests : IDisposable @@ -26,6 +26,52 @@ public class PullRequestReviewCommentReactionsClientTests : IDisposable _context = _github.CreateRepositoryContext("test-repo").Result; } + [IntegrationTest] + public async Task CanListReactions() + { + 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 reaction = await _github.Reaction.PullRequestReviewComment.Create(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id, new NewReaction(ReactionType.Heart)); + + var reactions = await _github.Reaction.PullRequestReviewComment.GetAll(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id); + + Assert.NotEmpty(reactions); + Assert.Equal(reaction.Id, reactions[0].Id); + Assert.Equal(reaction.Content, reactions[0].Content); + } + + [IntegrationTest] + public async Task CanListReactionsWithRepositoryId() + { + 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 reaction = await _github.Reaction.PullRequestReviewComment.Create(_context.Repository.Id, commentFromGitHub.Id, new NewReaction(ReactionType.Heart)); + + var reactions = await _github.Reaction.PullRequestReviewComment.GetAll(_context.Repository.Id, commentFromGitHub.Id); + + Assert.NotEmpty(reactions); + Assert.Equal(reaction.Id, reactions[0].Id); + Assert.Equal(reaction.Content, reactions[0].Content); + } + [IntegrationTest] public async Task CanCreateReaction() { @@ -51,6 +97,31 @@ public class PullRequestReviewCommentReactionsClientTests : IDisposable Assert.Equal(commentFromGitHub.User.Id, pullRequestReviewCommentReaction.User.Id); } + [IntegrationTest] + public async Task CanCreateReactionWithRepositoryId() + { + 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.Repository.Id, commentFromGitHub.Id, new NewReaction(ReactionType.Heart)); + + Assert.NotNull(pullRequestReviewCommentReaction); + + Assert.IsType(pullRequestReviewCommentReaction); + + Assert.Equal(ReactionType.Heart, pullRequestReviewCommentReaction.Content); + + Assert.Equal(commentFromGitHub.User.Id, pullRequestReviewCommentReaction.User.Id); + } + /// /// Creates the base state for testing (creates a repo, a commit in master, a branch, a commit in the branch and a pull request) /// @@ -154,4 +225,3 @@ public class PullRequestReviewCommentReactionsClientTests : IDisposable public string Sha { get; set; } } } -