public async void DeleteComment(Comment comment)
        {
            if (MessageBox.Show("Are you sure you want to delete this comment?", "Question", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop) == DialogResult.Yes)
            {
                int pos = _commentCollection.IndexOf(comment);
                await issue.DeleteCommentAsync(comment);

                IEnumerable <Comment> newcomments = await issue.GetCommentsAsync();

                CommentCollection = newcomments.ToList <Comment>();
                UpdatePositions((pos < comments.Count) ? comments[pos] : null);
            }
        }
Example #2
0
        public async Task AddGetAndDeleteCommentsAsync()
        {
            var summaryValue = "Test Summary with comments " + _random.Next(int.MaxValue);
            var issue        = new Issue(_jira, "TST")
            {
                Type     = "1",
                Summary  = summaryValue,
                Assignee = "admin"
            };

            // create an issue, verify no comments
            issue.SaveChanges();
            var comments = await issue.GetPagedCommentsAsync();

            Assert.Empty(comments);

            // Add a comment
            var commentFromAdd = await issue.AddCommentAsync("new comment");

            Assert.Equal("new comment", commentFromAdd.Body);

            // Verify comment retrieval
            comments = await issue.GetPagedCommentsAsync();

            Assert.Single(comments);
            var commentFromGet = comments.First();

            Assert.Equal(commentFromAdd.Id, commentFromGet.Id);
            Assert.Equal("new comment", commentFromGet.Body);
            Assert.Empty(commentFromGet.Properties);

            // Delete comment.
            await issue.DeleteCommentAsync(commentFromGet);

            // Verify no comments
            comments = await issue.GetPagedCommentsAsync();

            Assert.Empty(comments);
        }