diff --git a/src/YouTrackSharp/Issues/IIssuesService.cs b/src/YouTrackSharp/Issues/IIssuesService.cs index bb068c65..264474fd 100644 --- a/src/YouTrackSharp/Issues/IIssuesService.cs +++ b/src/YouTrackSharp/Issues/IIssuesService.cs @@ -146,6 +146,16 @@ Task> GetIssues(string filter = null, int? skip = null, int? /// When the call to the remote YouTrack server instance failed. Task> GetCommentsForIssue(string issueId, bool wikifyDescription = false); + /// + /// Adds a comment for an issue on the server. + /// + /// Uses the REST API Update a Comment. + /// Id of the issue to add comment to. + /// The text of the new comment. + /// When the or is null or empty. + /// When the call to the remote YouTrack server instance failed. + Task AddCommentForIssue(string issueId, string text); + /// /// Updates a comment for an issue on the server. /// diff --git a/tests/YouTrackSharp.Tests/Integration/Issues/Comments/AddCommentForIssue.cs b/tests/YouTrackSharp.Tests/Integration/Issues/Comments/AddCommentForIssue.cs new file mode 100644 index 00000000..720ef1ae --- /dev/null +++ b/tests/YouTrackSharp.Tests/Integration/Issues/Comments/AddCommentForIssue.cs @@ -0,0 +1,37 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using Xunit; +using YouTrackSharp.Tests.Infrastructure; + +// ReSharper disable once CheckNamespace +namespace YouTrackSharp.Tests.Integration.Issues +{ + public partial class IssuesServiceTests + { + public class AddCommentForIssue + { + [Fact] + public async Task Valid_Connection_Adds_Comment_For_Issue() + { + // Arrange + var connection = Connections.Demo1Token; + using (var temporaryIssueContext = await TemporaryIssueContext.Create(connection, GetType())) + { + var service = connection.CreateIssuesService(); + var commentText = "Test comment " + DateTime.UtcNow.ToString("U"); + + // Act + await service.AddCommentForIssue(temporaryIssueContext.Issue.Id, commentText); + + // Assert + var comments = await service.GetCommentsForIssue(temporaryIssueContext.Issue.Id); + + Assert.NotNull(comments.FirstOrDefault(comment => comment.Text.Equals(commentText))); + + await temporaryIssueContext.Destroy(); + } + } + } + } +} \ No newline at end of file