Exemplo n.º 1
0
        public void AddAndGetComments()
        {
            var summaryValue = "Test Summary " + _random.Next(int.MaxValue);
            var issue        = new Issue(_jira, "TST")
            {
                Type     = "1",
                Summary  = summaryValue,
                Assignee = "admin"
            };

            // create an issue, verify no comments
            issue.SaveChanges();
            Assert.Empty(issue.GetCommentsAsync().Result);

            // Add a comment
            issue.AddCommentAsync("new comment").Wait();

            var options = new CommentQueryOptions();

            options.Expand.Add("renderedBody");
            var comments = issue.GetCommentsAsync(options).Result;

            Assert.Single(comments);

            var comment = comments.First();

            Assert.Equal("new comment", comment.Body);
            Assert.Equal(DateTime.Now.Year, comment.CreatedDate.Value.Year);
            Assert.Null(comment.Visibility);
            Assert.Equal("new comment", comment.RenderedBody);
        }
Exemplo n.º 2
0
        public Task <IEnumerable <Comment> > GetCommentsAsync(string issueKey, CancellationToken token = default(CancellationToken))
        {
            var options = new CommentQueryOptions();

            options.Expand.Add("properties");

            return(GetCommentsAsync(issueKey, options, token));
        }
Exemplo n.º 3
0
        public async Task <IEnumerable <Comment> > GetCommentsAsync(string issueKey, CommentQueryOptions options, CancellationToken token = default(CancellationToken))
        {
            var resource = String.Format("rest/api/2/issue/{0}/comment", issueKey);

            if (options.Expand.Any())
            {
                resource += $"?expand={String.Join(",", options.Expand)}";
            }

            var issueJson = await _jira.RestClient.ExecuteRequestAsync(Method.GET, resource, null, token).ConfigureAwait(false);

            var commentJson = issueJson["comments"];

            var serializerSettings = _jira.RestClient.Settings.JsonSerializerSettings;
            var remoteComments     = JsonConvert.DeserializeObject <RemoteComment[]>(commentJson.ToString(), serializerSettings);

            return(remoteComments.Select(c => new Comment(c)));
        }