示例#1
0
        public void PullRequestReviewCommentEditEnsuresArgumentsValue()
        {
            string body = "body";

            var comment = new PullRequestReviewCommentEdit(body);

            Assert.Equal(body, comment.Body);
        }
示例#2
0
 public IObservable<PullRequestReviewComment> EditPullRequestReviewComment(
     string owner,
     string name,
     int number,
     string body)
 {
     var pullRequestReviewCommentEdit = new PullRequestReviewCommentEdit(body);
     return gitHubClient.PullRequest.ReviewComment.Edit(owner, name, number, pullRequestReviewCommentEdit);
 }
            public void PostsToCorrectUrl()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservablePullRequestReviewCommentsClient(gitHubClient);

                var comment = new PullRequestReviewCommentEdit("New comment content");

                client.Edit("fakeOwner", "fakeRepoName", 13, comment);

                gitHubClient.PullRequest.Comment.Received().Edit("fakeOwner", "fakeRepoName", 13, comment);
            }
示例#4
0
        public void PostsToCorrectUrl()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new PullRequestReviewCommentsClient(connection);

            var comment = new PullRequestReviewCommentEdit("New comment content");

            client.Edit("fakeOwner", "fakeRepoName", 13, comment);

            connection.Received().Patch <PullRequestReviewComment>(Arg.Is <Uri>(u => u.ToString() == "repos/fakeOwner/fakeRepoName/pulls/comments/13"), comment);
        }
        public async Task PostsToCorrectUrlWithRepositoryId()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new PullRequestReviewCommentsClient(connection);

            var comment = new PullRequestReviewCommentEdit("New comment content");

            await client.Edit(1, 13, comment);

            connection.Received().Patch <PullRequestReviewComment>(Arg.Is <Uri>(u => u.ToString() == "repositories/1/pulls/comments/13"), comment);
        }
示例#6
0
    public async Task CanEditCommentWithRepositoryId()
    {
        var pullRequest = await CreatePullRequest(_context);

        const string body     = "A new review comment message";
        const int    position = 1;

        var createdComment = await CreateCommentWithRepositoryId(body, position, pullRequest.Sha, pullRequest.Number);

        var edit = new PullRequestReviewCommentEdit("Edited Comment");

        var editedComment = await _client.Edit(_context.Repository.Id, createdComment.Id, edit);

        var commentFromGitHub = await _client.GetComment(_context.Repository.Id, editedComment.Id);

        AssertComment(commentFromGitHub, edit.Body, position);
    }
示例#7
0
    public async Task TimestampsAreUpdated()
    {
        var pullRequest = await CreatePullRequest(_context);

        const string body     = "A new review comment message";
        const int    position = 1;

        var createdComment = await CreateComment(body, position, pullRequest.Sha, pullRequest.Number);

        Assert.Equal(createdComment.UpdatedAt, createdComment.CreatedAt);

        await Task.Delay(TimeSpan.FromSeconds(2));

        var edit = new PullRequestReviewCommentEdit("Edited Comment");

        var editedComment = await _client.Edit(Helper.UserName, _context.RepositoryName, createdComment.Id, edit);

        Assert.NotEqual(editedComment.UpdatedAt, editedComment.CreatedAt);
    }
            public async Task EnsuresArgumentsNotNull()
            {
                var gitHubClient = Substitute.For <IGitHubClient>();
                var client       = new ObservablePullRequestReviewCommentsClient(gitHubClient);

                var body = "New comment content";

                var comment = new PullRequestReviewCommentEdit(body);

                await AssertEx.Throws <ArgumentNullException>(async() => await client.Edit(null, "name", 1, comment));

                await AssertEx.Throws <ArgumentException>(async() => await client.Edit("", "name", 1, comment));

                await AssertEx.Throws <ArgumentNullException>(async() => await client.Edit("owner", null, 1, comment));

                await AssertEx.Throws <ArgumentException>(async() => await client.Edit("owner", "", 1, comment));

                await AssertEx.Throws <ArgumentNullException>(async() => await client.Edit("owner", "name", 1, null));
            }
示例#9
0
        public async Task EnsuresArgumentsNotNull()
        {
            var connection = Substitute.For <IApiConnection>();
            var client     = new PullRequestReviewCommentsClient(connection);

            var body = "New comment content";

            var comment = new PullRequestReviewCommentEdit(body);

            await Assert.ThrowsAsync <ArgumentNullException>(() => client.Edit(null, "fakeRepoName", 1, comment));

            await Assert.ThrowsAsync <ArgumentException>(() => client.Edit("", "fakeRepoName", 1, comment));

            await Assert.ThrowsAsync <ArgumentNullException>(() => client.Edit("fakeOwner", null, 1, comment));

            await Assert.ThrowsAsync <ArgumentException>(() => client.Edit("fakeOwner", "", 1, comment));

            await Assert.ThrowsAsync <ArgumentNullException>(() => client.Edit("fakeOwner", null, 1, null));
        }
            public async Task EnsuresNonNullArguments()
            {
                var gitHubClient = Substitute.For<IGitHubClient>();
                var client = new ObservablePullRequestReviewCommentsClient(gitHubClient);

                var body = "New comment content";

                var comment = new PullRequestReviewCommentEdit(body);

                Assert.Throws<ArgumentNullException>(() => client.Edit(null, "name", 1, comment));
                Assert.Throws<ArgumentNullException>(() => client.Edit("owner", null, 1, comment));
                Assert.Throws<ArgumentNullException>(() => client.Edit("owner", "name", 1, null));

                Assert.Throws<ArgumentNullException>(() => client.Edit(1, 1, null));

                Assert.Throws<ArgumentException>(() => client.Edit("", "name", 1, comment));
                Assert.Throws<ArgumentException>(() => client.Edit("owner", "", 1, comment));
            }
            public void PostsToCorrectUrlWithRepositoryId()
            {
                var gitHubClient = Substitute.For<IGitHubClient>();
                var client = new ObservablePullRequestReviewCommentsClient(gitHubClient);

                var comment = new PullRequestReviewCommentEdit("New comment content");

                client.Edit(1, 13, comment);

                gitHubClient.PullRequest.ReviewComment.Received().Edit(1, 13, comment);
            }
            public void PostsToCorrectUrl()
            {
                var gitHubClient = Substitute.For<IGitHubClient>();
                var client = new ObservablePullRequestReviewCommentsClient(gitHubClient);

                var comment = new PullRequestReviewCommentEdit("New comment content");

                client.Edit("fakeOwner", "fakeRepoName", 13, comment);

                gitHubClient.PullRequest.Comment.Received().Edit("fakeOwner", "fakeRepoName", 13, comment);
            }
        /// <summary>
        /// Edits a comment on a pull request review.
        /// </summary>
        /// <remarks>http://developer.github.com/v3/pulls/comments/#edit-a-comment</remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="number">The pull request review comment number</param>
        /// <param name="comment">The edited comment</param>
        /// <returns>The edited <see cref="PullRequestReviewComment"/></returns>
        public IObservable<PullRequestReviewComment> Edit(string owner, string name, int number, PullRequestReviewCommentEdit comment)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNull(comment, "comment");

            return _client.Edit(owner, name, number, comment).ToObservable();
        }
        /// <summary>
        /// Edits a comment on a pull request review.
        /// </summary>
        /// <remarks>http://developer.github.com/v3/pulls/comments/#edit-a-comment</remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="number">The pull request review comment number</param>
        /// <param name="comment">The edited comment</param>
        public IObservable <PullRequestReviewComment> Edit(int repositoryId, int number, PullRequestReviewCommentEdit comment)
        {
            Ensure.ArgumentNotNull(comment, "comment");

            return(_client.Edit(repositoryId, number, comment).ToObservable());
        }
        /// <summary>
        /// Edits a comment on a pull request review.
        /// </summary>
        /// <remarks>http://developer.github.com/v3/pulls/comments/#edit-a-comment</remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="number">The pull request review comment number</param>
        /// <param name="comment">The edited comment</param>
        public IObservable <PullRequestReviewComment> Edit(string owner, string name, int number, PullRequestReviewCommentEdit comment)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNull(comment, "comment");

            return(_client.Edit(owner, name, number, comment).ToObservable());
        }
        /// <summary>
        /// Edits a comment on a pull request review.
        /// </summary>
        /// <remarks>http://developer.github.com/v3/pulls/comments/#edit-a-comment</remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="number">The pull request review comment number</param>
        /// <param name="comment">The edited comment</param>
        public IObservable<PullRequestReviewComment> Edit(long repositoryId, int number, PullRequestReviewCommentEdit comment)
        {
            Ensure.ArgumentNotNull(comment, "comment");

            return _client.Edit(repositoryId, number, comment).ToObservable();
        }