From f7a464cc3aba781ee0b246c38dfe3d80302f9dce Mon Sep 17 00:00:00 2001 From: Martin Scholz Date: Thu, 23 Jun 2016 08:35:04 +0200 Subject: [PATCH] foreach loop for reaction types in integration tests --- .../CommitCommentReactionsClientTests.cs | 42 ++++--------------- .../IssueCommentReactionsClientTests.cs | 42 ++++--------------- .../Clients/IssueReactionsClientTests.cs | 42 ++++--------------- ...equestReviewCommentReactionsClientTests.cs | 42 ++++--------------- 4 files changed, 32 insertions(+), 136 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs index 38e66eb4..679070a6 100644 --- a/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs @@ -56,42 +56,16 @@ public class CommitCommentReactionsClientTests Assert.NotNull(result); - var newReactionConfused = new NewReaction(ReactionType.Confused); - var newReactionHeart = new NewReaction(ReactionType.Heart); - var newReactionHooray = new NewReaction(ReactionType.Hooray); - var newReactionLaugh = new NewReaction(ReactionType.Laugh); - var newReactionMinus1 = new NewReaction(ReactionType.Minus1); - var newReactionPlus1 = new NewReaction(ReactionType.Plus1); - var reactionConfused = await _github.Reaction.CommitComment.Create(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReactionConfused); - var reactionHeart = await _github.Reaction.CommitComment.Create(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReactionHeart); - var reactionHooray = await _github.Reaction.CommitComment.Create(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReactionHooray); - var reactionLaugh = await _github.Reaction.CommitComment.Create(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReactionLaugh); - var reactionMinus1 = await _github.Reaction.CommitComment.Create(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReactionMinus1); - var reactionPlus1 = await _github.Reaction.CommitComment.Create(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReactionPlus1); + foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) + { + var newReaction = new NewReaction(reactionType); - Assert.IsType(reactionConfused); - Assert.Equal(ReactionType.Confused, reactionConfused.Content); - Assert.Equal(result.User.Id, reactionConfused.User.Id); + var reaction = await _github.Reaction.CommitComment.Create(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReaction); - Assert.IsType(reactionHeart); - Assert.Equal(ReactionType.Heart, reactionHeart.Content); - Assert.Equal(result.User.Id, reactionHeart.User.Id); - - Assert.IsType(reactionHooray); - Assert.Equal(ReactionType.Hooray, reactionHooray.Content); - Assert.Equal(result.User.Id, reactionHooray.User.Id); - - Assert.IsType(reactionLaugh); - Assert.Equal(ReactionType.Laugh, reactionLaugh.Content); - Assert.Equal(result.User.Id, reactionLaugh.User.Id); - - Assert.IsType(reactionMinus1); - Assert.Equal(ReactionType.Minus1, reactionMinus1.Content); - Assert.Equal(result.User.Id, reactionMinus1.User.Id); - - Assert.IsType(reactionPlus1); - Assert.Equal(ReactionType.Plus1, reactionPlus1.Content); - Assert.Equal(result.User.Id, reactionPlus1.User.Id); + Assert.IsType(reaction); + Assert.Equal(reactionType, reaction.Content); + 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 c896af91..6502e867 100644 --- a/Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssueCommentReactionsClientTests.cs @@ -33,42 +33,16 @@ public class IssueCommentReactionsClientTests Assert.NotNull(issueComment); - var newReactionConfused = new NewReaction(ReactionType.Confused); - var newReactionHeart = new NewReaction(ReactionType.Heart); - var newReactionHooray = new NewReaction(ReactionType.Hooray); - var newReactionLaugh = new NewReaction(ReactionType.Laugh); - var newReactionMinus1 = new NewReaction(ReactionType.Minus1); - var newReactionPlus1 = new NewReaction(ReactionType.Plus1); - var reactionConfused = await _github.Reaction.IssueComment.Create(_context.RepositoryOwner, _context.RepositoryName, issueComment.Id, newReactionConfused); - var reactionHeart = await _github.Reaction.IssueComment.Create(_context.RepositoryOwner, _context.RepositoryName, issueComment.Id, newReactionHeart); - var reactionHooray = await _github.Reaction.IssueComment.Create(_context.RepositoryOwner, _context.RepositoryName, issueComment.Id, newReactionHooray); - var reactionLaugh = await _github.Reaction.IssueComment.Create(_context.RepositoryOwner, _context.RepositoryName, issueComment.Id, newReactionLaugh); - var reactionMinus1 = await _github.Reaction.IssueComment.Create(_context.RepositoryOwner, _context.RepositoryName, issueComment.Id, newReactionMinus1); - var reactionPlus1 = await _github.Reaction.IssueComment.Create(_context.RepositoryOwner, _context.RepositoryName, issueComment.Id, newReactionPlus1); + foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) + { + var newReaction = new NewReaction(reactionType); - Assert.IsType(reactionConfused); - Assert.Equal(ReactionType.Confused, reactionConfused.Content); - Assert.Equal(issueComment.User.Id, reactionConfused.User.Id); + var reaction = await _github.Reaction.CommitComment.Create(_context.RepositoryOwner, _context.RepositoryName, issueComment.Id, newReaction); - Assert.IsType(reactionHeart); - Assert.Equal(ReactionType.Heart, reactionHeart.Content); - Assert.Equal(issueComment.User.Id, reactionHeart.User.Id); - - Assert.IsType(reactionHooray); - Assert.Equal(ReactionType.Hooray, reactionHooray.Content); - Assert.Equal(issueComment.User.Id, reactionHooray.User.Id); - - Assert.IsType(reactionLaugh); - Assert.Equal(ReactionType.Laugh, reactionLaugh.Content); - Assert.Equal(issueComment.User.Id, reactionLaugh.User.Id); - - Assert.IsType(reactionMinus1); - Assert.Equal(ReactionType.Minus1, reactionMinus1.Content); - Assert.Equal(issueComment.User.Id, reactionMinus1.User.Id); - - Assert.IsType(reactionPlus1); - Assert.Equal(ReactionType.Plus1, reactionPlus1.Content); - Assert.Equal(issueComment.User.Id, reactionPlus1.User.Id); + Assert.IsType(reaction); + Assert.Equal(reactionType, reaction.Content); + Assert.Equal(issueComment.User.Id, reaction.User.Id); + } } public void Dispose() diff --git a/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs index 9bce57af..e6b9b806 100644 --- a/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssueReactionsClientTests.cs @@ -29,42 +29,16 @@ public class IssueReactionsClientTests Assert.NotNull(issue); - var newReactionConfused = new NewReaction(ReactionType.Confused); - var newReactionHeart = new NewReaction(ReactionType.Heart); - var newReactionHooray = new NewReaction(ReactionType.Hooray); - var newReactionLaugh = new NewReaction(ReactionType.Laugh); - var newReactionMinus1 = new NewReaction(ReactionType.Minus1); - var newReactionPlus1 = new NewReaction(ReactionType.Plus1); - var reactionConfused = await _github.Reaction.Issue.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, newReactionConfused); - var reactionHeart = await _github.Reaction.Issue.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, newReactionHeart); - var reactionHooray = await _github.Reaction.Issue.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, newReactionHooray); - var reactionLaugh = await _github.Reaction.Issue.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, newReactionLaugh); - var reactionMinus1 = await _github.Reaction.Issue.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, newReactionMinus1); - var reactionPlus1 = await _github.Reaction.Issue.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, newReactionPlus1); + foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) + { + var newReaction = new NewReaction(reactionType); - Assert.IsType(reactionConfused); - Assert.Equal(ReactionType.Confused, reactionConfused.Content); - Assert.Equal(issue.User.Id, reactionConfused.User.Id); + var reaction = await _github.Reaction.CommitComment.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Id, newReaction); - Assert.IsType(reactionHeart); - Assert.Equal(ReactionType.Heart, reactionHeart.Content); - Assert.Equal(issue.User.Id, reactionHeart.User.Id); - - Assert.IsType(reactionHooray); - Assert.Equal(ReactionType.Hooray, reactionHooray.Content); - Assert.Equal(issue.User.Id, reactionHooray.User.Id); - - Assert.IsType(reactionLaugh); - Assert.Equal(ReactionType.Laugh, reactionLaugh.Content); - Assert.Equal(issue.User.Id, reactionLaugh.User.Id); - - Assert.IsType(reactionMinus1); - Assert.Equal(ReactionType.Minus1, reactionMinus1.Content); - Assert.Equal(issue.User.Id, reactionMinus1.User.Id); - - Assert.IsType(reactionPlus1); - Assert.Equal(ReactionType.Plus1, reactionPlus1.Content); - Assert.Equal(issue.User.Id, reactionPlus1.User.Id); + Assert.IsType(reaction); + Assert.Equal(reactionType, reaction.Content); + Assert.Equal(issue.User.Id, reaction.User.Id); + } } public void Dispose() diff --git a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs index ea073a2e..84afbcda 100644 --- a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs @@ -40,42 +40,16 @@ public class PullRequestReviewCommentReactionsClientTests : IDisposable AssertComment(commentFromGitHub, body, position); - var newReactionConfused = new NewReaction(ReactionType.Confused); - var newReactionHeart = new NewReaction(ReactionType.Heart); - var newReactionHooray = new NewReaction(ReactionType.Hooray); - var newReactionLaugh = new NewReaction(ReactionType.Laugh); - var newReactionMinus1 = new NewReaction(ReactionType.Minus1); - var newReactionPlus1 = new NewReaction(ReactionType.Plus1); - var reactionConfused = await _github.Reaction.PullRequestReviewComment.Create(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id, newReactionConfused); - var reactionHeart = await _github.Reaction.PullRequestReviewComment.Create(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id, newReactionHeart); - var reactionHooray = await _github.Reaction.PullRequestReviewComment.Create(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id, newReactionHooray); - var reactionLaugh = await _github.Reaction.PullRequestReviewComment.Create(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id, newReactionLaugh); - var reactionMinus1 = await _github.Reaction.PullRequestReviewComment.Create(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id, newReactionMinus1); - var reactionPlus1 = await _github.Reaction.PullRequestReviewComment.Create(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id, newReactionPlus1); + foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) + { + var newReaction = new NewReaction(reactionType); - Assert.IsType(reactionConfused); - Assert.Equal(ReactionType.Confused, reactionConfused.Content); - Assert.Equal(commentFromGitHub.User.Id, reactionConfused.User.Id); + var reaction = await _github.Reaction.CommitComment.Create(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id, newReaction); - Assert.IsType(reactionHeart); - Assert.Equal(ReactionType.Heart, reactionHeart.Content); - Assert.Equal(commentFromGitHub.User.Id, reactionHeart.User.Id); - - Assert.IsType(reactionHooray); - Assert.Equal(ReactionType.Hooray, reactionHooray.Content); - Assert.Equal(commentFromGitHub.User.Id, reactionHooray.User.Id); - - Assert.IsType(reactionLaugh); - Assert.Equal(ReactionType.Laugh, reactionLaugh.Content); - Assert.Equal(commentFromGitHub.User.Id, reactionLaugh.User.Id); - - Assert.IsType(reactionMinus1); - Assert.Equal(ReactionType.Minus1, reactionMinus1.Content); - Assert.Equal(commentFromGitHub.User.Id, reactionMinus1.User.Id); - - Assert.IsType(reactionPlus1); - Assert.Equal(ReactionType.Plus1, reactionPlus1.Content); - Assert.Equal(commentFromGitHub.User.Id, reactionPlus1.User.Id); + Assert.IsType(reaction); + Assert.Equal(reactionType, reaction.Content); + Assert.Equal(commentFromGitHub.User.Id, reaction.User.Id); + } } ///