Skip to content

Commit

Permalink
add doc and test for AddCommentForIssue method
Browse files Browse the repository at this point in the history
  • Loading branch information
rekolobov committed Jan 26, 2022
1 parent b79f238 commit 32475f3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/YouTrackSharp/Issues/IIssuesService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ Task<ICollection<Issue>> GetIssues(string filter = null, int? skip = null, int?
/// <exception cref="T:System.Net.HttpRequestException">When the call to the remote YouTrack server instance failed.</exception>
Task<IEnumerable<Comment>> GetCommentsForIssue(string issueId, bool wikifyDescription = false);

/// <summary>
/// Adds a comment for an issue on the server.
/// </summary>
/// <remarks>Uses the REST API <a href="https://www.jetbrains.com/help/youtrack/devportal/resource-api-issues-issueID-comments.html#create-IssueComment-method">Update a Comment</a>.</remarks>
/// <param name="issueId">Id of the issue to add comment to.</param>
/// <param name="text">The text of the new comment.</param>
/// <exception cref="T:System.ArgumentNullException">When the <paramref name="issueId"/> or <paramref name="text"/> is null or empty.</exception>
/// <exception cref="T:System.Net.HttpRequestException">When the call to the remote YouTrack server instance failed.</exception>
Task AddCommentForIssue(string issueId, string text);

/// <summary>
/// Updates a comment for an issue on the server.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
}
}

0 comments on commit 32475f3

Please sign in to comment.