/// <summary> /// Creates a reaction for a specified Pull Request Review Comment. /// </summary> /// <remarks>https://developer.github.com/v3/reactions/#create-reaction-for-a-pull-request-review-comment</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The comment id</param> /// <param name="reaction">The reaction to create</param> public Task <Reaction> Create(string owner, string name, int number, NewReaction reaction) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(reaction, nameof(reaction)); return(ApiConnection.Post <Reaction>(ApiUrls.PullRequestReviewCommentReaction(owner, name, number), reaction, AcceptHeaders.ReactionsPreview)); }
/// <summary> /// Creates a reaction for a specified Issue Comment /// </summary> /// <remarks>https://developer.github.com/v3/reactions/#create-reactions-for-an-issue-comment</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The comment id</param> /// <param name="reaction">The reaction to create</param> public Task <Reaction> Create(string owner, string name, int number, NewReaction reaction) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(reaction, "reaction"); return(ApiConnection.Post <Reaction>(ApiUrls.IssueCommentReactions(owner, name, number), reaction, AcceptHeaders.ReactionsPreview)); }
/// <summary> /// Creates a reaction for a specified Pull Request Review Comment. /// </summary> /// <remarks>https://developer.github.com/v3/reactions/#create-reaction-for-a-pull-request-review-comment</remarks> /// <param name="owner">The owner of the repository</param> /// <param name="name">The name of the repository</param> /// <param name="number">The comment id</param> /// <param name="reaction">The reaction to create</param> public Task<Reaction> Create(string owner, string name, int number, NewReaction reaction) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(reaction, "reaction"); return ApiConnection.Post<Reaction>(ApiUrls.PullRequestReviewCommentReaction(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); }
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); foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) { var newReaction = new NewReaction(reactionType); var reaction = await _github.Reaction.CommitComment.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Id, newReaction); Assert.IsType<Reaction>(reaction); Assert.Equal(reactionType, reaction.Content); Assert.Equal(issue.User.Id, reaction.User.Id); } }
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>(reaction); Assert.Equal(ReactionType.Confused, reaction.Content); Assert.Equal(result.User.Id, reaction.User.Id); }
public async Task CanListReactionsWithRepositoryId() { 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.Repository.Id, result.Id, newReaction); var reactions = await _github.Reaction.CommitComment.GetAll(_context.Repository.Id, result.Id); Assert.NotEmpty(reactions); Assert.Equal(reaction.Id, reactions[0].Id); Assert.Equal(reaction.Content, reactions[0].Content); }
/// <summary> /// Creates a reaction for a specified Issue Comment /// </summary> /// <remarks>https://developer.github.com/v3/reactions/#create-reaction-for-an-issue-comment</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The comment id</param> /// <param name="reaction">The reaction to create</param> public Task <Reaction> Create(int repositoryId, int number, NewReaction reaction) { Ensure.ArgumentNotNull(reaction, "reaction"); return(ApiConnection.Post <Reaction>(ApiUrls.IssueCommentReactions(repositoryId, number), reaction, AcceptHeaders.ReactionsPreview)); }
/// <summary> /// Creates a reaction for a specified Pull Request Review Comment. /// </summary> /// <remarks>https://developer.github.com/v3/reactions/#create-reaction-for-a-pull-request-review-comment</remarks> /// <param name="repositoryId">The ID of the repository</param> /// <param name="number">The comment id</param> /// <param name="reaction">The reaction to create</param> public Task<Reaction> Create(int repositoryId, int number, NewReaction reaction) { Ensure.ArgumentNotNull(reaction, "reaction"); return ApiConnection.Post<Reaction>(ApiUrls.PullRequestReviewCommentReaction(repositoryId, number), reaction, AcceptHeaders.ReactionsPreview); }
async static Task<int> HelperCreateIssueCommentWithReactions(string owner, string repo, int number) { var github = Helper.GetAuthenticatedClient(); var issueComment = await github.Issue.Comment.Create(owner, repo, number, "A test issue comment"); Assert.NotNull(issueComment); foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) { var newReaction = new NewReaction(reactionType); var reaction = await github.Reaction.IssueComment.Create(owner, repo, issueComment.Id, newReaction); Assert.IsType<Reaction>(reaction); Assert.Equal(reactionType, reaction.Content); Assert.Equal(issueComment.User.Id, reaction.User.Id); } return issueComment.Id; }
async static Task<int> HelperCreateCommitCommentWithReactions(string owner, string repo, string sha) { var github = Helper.GetAuthenticatedClient(); var commitComment = await github.Repository.Comment.Create(owner, repo, sha, new NewCommitComment("A test comment")); Assert.NotNull(commitComment); foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) { var newReaction = new NewReaction(reactionType); var reaction = await github.Reaction.CommitComment.Create(owner, repo, commitComment.Id, newReaction); Assert.IsType<Reaction>(reaction); Assert.Equal(reactionType, reaction.Content); Assert.Equal(commitComment.User.Id, reaction.User.Id); } return commitComment.Id; }
public async Task CanGetReactionPayload() { var commit = await SetupCommitForRepository(_github); var comment = new NewCommitComment("test"); var result = await _github.Repository.Comment.Create(_context.Repository.Id, commit.Sha, comment); foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) { var newReaction = new NewReaction(reactionType); var reaction = await _github.Reaction.Issue.Create(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReaction); Assert.IsType<Reaction>(reaction); Assert.Equal(reactionType, reaction.Content); Assert.Equal(result.User.Id, reaction.User.Id); } var retrieved = await _github.Repository.Comment.Get(_context.RepositoryOwner, _context.RepositoryName, result.Id); Assert.True(retrieved.Id > 0); Assert.Equal(6, retrieved.Reactions.TotalCount); Assert.Equal(1, retrieved.Reactions.Plus1); Assert.Equal(1, retrieved.Reactions.Hooray); Assert.Equal(1, retrieved.Reactions.Heart); Assert.Equal(1, retrieved.Reactions.Laugh); Assert.Equal(1, retrieved.Reactions.Confused); Assert.Equal(1, retrieved.Reactions.Minus1); }
async Task<int> HelperCreatePullRequestReviewCommentWithReactions(string owner, string repo, PullRequestData pullRequest) { var github = Helper.GetAuthenticatedClient(); const string body = "A review comment message"; const int position = 1; var reviewComment = await CreateComment(body, position, repo, pullRequest.Sha, pullRequest.Number); foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) { var newReaction = new NewReaction(reactionType); var reaction = await github.Reaction.PullRequestReviewComment.Create(owner, repo, reviewComment.Id, newReaction); Assert.IsType<Reaction>(reaction); Assert.Equal(reactionType, reaction.Content); Assert.Equal(reviewComment.User.Id, reaction.User.Id); } return reviewComment.Id; }
/// <summary> /// Creates a reaction for a specified Pull Request Review Comment. /// </summary> /// <remarks>https://developer.github.com/v3/reactions/#create-reaction-for-a-pull-request-review-comment</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The comment id</param> /// <param name="reaction">The reaction to create</param> public Task <Reaction> Create(long repositoryId, int number, NewReaction reaction) { Ensure.ArgumentNotNull(reaction, nameof(reaction)); return(ApiConnection.Post <Reaction>(ApiUrls.PullRequestReviewCommentReaction(repositoryId, number), reaction, AcceptHeaders.ReactionsPreview)); }
async static Task<int> HelperCreateIssue(string owner, string repo) { var github = Helper.GetAuthenticatedClient(); var newIssue = new NewIssue("A test issue") { Body = "A new unassigned issue" }; var issue = await github.Issue.Create(owner, repo, newIssue); Assert.NotNull(issue); foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) { var newReaction = new NewReaction(reactionType); var reaction = await github.Reaction.Issue.Create(owner, repo, issue.Number, newReaction); Assert.IsType<Reaction>(reaction); Assert.Equal(reactionType, reaction.Content); Assert.Equal(issue.User.Id, reaction.User.Id); } return issue.Number; }
/// <summary> /// Creates a reaction for a specified Issue /// </summary> /// <remarks>https://developer.github.com/v3/reactions/#create-reaction-for-an-issue</remarks> /// <param name="repositoryId">The Id of the repository</param> /// <param name="number">The issue id</param> /// <param name="reaction">The reaction to create</param> public Task<Reaction> Create(long repositoryId, int number, NewReaction reaction) { Ensure.ArgumentNotNull(reaction, "reaction"); return ApiConnection.Post<Reaction>(ApiUrls.IssueReactions(repositoryId, number), reaction, AcceptHeaders.ReactionsPreview); }
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); foreach (ReactionType reactionType in Enum.GetValues(typeof(ReactionType))) { var newReaction = new NewReaction(reactionType); var reaction = await _github.Reaction.PullRequestReviewComment.Create(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id, newReaction); Assert.IsType<Reaction>(reaction); Assert.Equal(reactionType, reaction.Content); Assert.Equal(commentFromGitHub.User.Id, reaction.User.Id); } }