Replaced public properties by readonly fields with a public getter and cleaned code

This commit is contained in:
Gabriel Weyer
2013-11-24 19:06:59 +11:00
parent ceb943c550
commit 921353dd4b
9 changed files with 146 additions and 151 deletions

View File

@@ -93,9 +93,6 @@ namespace Octokit.Reactive
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(comment, "comment"); Ensure.ArgumentNotNull(comment, "comment");
Ensure.ArgumentNotNullOrEmptyString(comment.Body, "body");
Ensure.ArgumentNotNullOrEmptyString(comment.CommitId, "commitId");
Ensure.ArgumentNotNullOrEmptyString(comment.Path, "path");
return _client.Create(owner, name, number, comment).ToObservable(); return _client.Create(owner, name, number, comment).ToObservable();
} }
@@ -114,7 +111,6 @@ namespace Octokit.Reactive
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(comment, "comment"); Ensure.ArgumentNotNull(comment, "comment");
Ensure.ArgumentNotNullOrEmptyString(comment.Body, "body");
return _client.CreateReply(owner, name, number, comment).ToObservable(); return _client.CreateReply(owner, name, number, comment).ToObservable();
} }
@@ -133,7 +129,6 @@ namespace Octokit.Reactive
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(comment, "comment"); Ensure.ArgumentNotNull(comment, "comment");
Ensure.ArgumentNotNullOrEmptyString(comment.Body, "body");
return _client.Edit(owner, name, number, comment).ToObservable(); return _client.Edit(owner, name, number, comment).ToObservable();
} }

View File

@@ -98,13 +98,7 @@ public class PullRequestReviewCommentsClientTests : IDisposable
[IntegrationTest(Skip = "Requires Blob, Tree, Fork and Pull Request Api implementation")] [IntegrationTest(Skip = "Requires Blob, Tree, Fork and Pull Request Api implementation")]
public async Task CanCreateAndRetrieveReviewComment() public async Task CanCreateAndRetrieveReviewComment()
{ {
var pullRequestReviewComment = new PullRequestReviewCommentCreate var pullRequestReviewComment = new PullRequestReviewCommentCreate("A review comment message", _pullRequestCommitId, _path, 1);
{
Body = "A review comment message",
CommitId = _pullRequestCommitId,
Path = _path,
Position = 1,
};
var createdComment = await _client.Create(_ownerName, _repoName, _pullRequestNumber, pullRequestReviewComment); var createdComment = await _client.Create(_ownerName, _repoName, _pullRequestNumber, pullRequestReviewComment);

View File

@@ -8,6 +8,79 @@ using Xunit;
public class PullRequestReviewCommentsClientTests public class PullRequestReviewCommentsClientTests
{ {
public class TheModelConstructors
{
[Fact]
public void PullRequestReviewCommentCreateEnsuresArgumentsValue()
{
string body = "body";
string commitId = "sha";
string path = "path";
int position = 1;
var comment = new PullRequestReviewCommentCreate(body, commitId, path, position);
Assert.Equal(body, comment.Body);
Assert.Equal(commitId, comment.CommitId);
Assert.Equal(path, comment.Path);
Assert.Equal(position, comment.Position);
}
[Fact]
public void PullRequestReviewCommentCreateEnsuresArgumentsNotNull()
{
string body = "body";
string commitId = "sha";
string path = "path";
int position = 1;
Assert.Throws<ArgumentNullException>(() => new PullRequestReviewCommentCreate(null, commitId, path, position));
Assert.Throws<ArgumentException>(() => new PullRequestReviewCommentCreate("", commitId, path, position));
Assert.Throws<ArgumentNullException>(() => new PullRequestReviewCommentCreate(body, null, path, position));
Assert.Throws<ArgumentException>(() => new PullRequestReviewCommentCreate(body, "", path, position));
Assert.Throws<ArgumentNullException>(() => new PullRequestReviewCommentCreate(body, commitId, null, position));
Assert.Throws<ArgumentException>(() => new PullRequestReviewCommentCreate(body, commitId, "", position));
}
[Fact]
public void PullRequestReviewCommentEditEnsuresArgumentsValue()
{
string body = "body";
var comment = new PullRequestReviewCommentEdit(body);
Assert.Equal(body, comment.Body);
}
[Fact]
public void PullRequestReviewCommentEditEnsuresArgumentsNotNull()
{
Assert.Throws<ArgumentNullException>(() => new PullRequestReviewCommentEdit(null));
Assert.Throws<ArgumentException>(() => new PullRequestReviewCommentEdit(""));
}
[Fact]
public void PullRequestReviewCommentReplyCreateEnsuresArgumentsValue()
{
string body = "body";
int inReplyTo = 1;
var comment = new PullRequestReviewCommentReplyCreate(body, inReplyTo);
Assert.Equal(body, comment.Body);
Assert.Equal(inReplyTo, comment.InReplyTo);
}
[Fact]
public void PullRequestReviewCommentReplyCreateEnsuresArgumentsNotNull()
{
int inReplyTo = 1;
Assert.Throws<ArgumentNullException>(() => new PullRequestReviewCommentReplyCreate(null, inReplyTo));
Assert.Throws<ArgumentException>(() => new PullRequestReviewCommentReplyCreate("", inReplyTo));
}
}
public class TheGetForPullRequestMethod public class TheGetForPullRequestMethod
{ {
[Fact] [Fact]
@@ -131,13 +204,7 @@ public class PullRequestReviewCommentsClientTests
var connection = Substitute.For<IApiConnection>(); var connection = Substitute.For<IApiConnection>();
var client = new PullRequestReviewCommentsClient(connection); var client = new PullRequestReviewCommentsClient(connection);
var comment = new PullRequestReviewCommentCreate var comment = new PullRequestReviewCommentCreate("Comment content", "qe3dsdsf6", "file.css", 7);
{
Body = "Comment content",
CommitId = "qe3dsdsf6",
Path = "file.css",
Position = 7,
};
client.Create("fakeOwner", "fakeRepoName", 13, comment); client.Create("fakeOwner", "fakeRepoName", 13, comment);
@@ -156,37 +223,13 @@ public class PullRequestReviewCommentsClientTests
string path = "file.css"; string path = "file.css";
int position = 7; int position = 7;
var comment = new PullRequestReviewCommentCreate var comment = new PullRequestReviewCommentCreate(body, commitId, path, position);
{
Body = body,
CommitId = commitId,
Path = path,
Position = position,
};
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create(null, "fakeRepoName", 1, comment)); await AssertEx.Throws<ArgumentNullException>(async () => await client.Create(null, "fakeRepoName", 1, comment));
await AssertEx.Throws<ArgumentException>(async () => await client.Create("", "fakeRepoName", 1, comment)); await AssertEx.Throws<ArgumentException>(async () => await client.Create("", "fakeRepoName", 1, comment));
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create("fakeOwner", null, 1, comment)); await AssertEx.Throws<ArgumentNullException>(async () => await client.Create("fakeOwner", null, 1, comment));
await AssertEx.Throws<ArgumentException>(async () => await client.Create("fakeOwner", "", 1, comment)); await AssertEx.Throws<ArgumentException>(async () => await client.Create("fakeOwner", "", 1, comment));
await AssertEx.Throws<ArgumentException>(async () => await client.Create("fakeOwner", "fakeRepoName", 1, null)); await AssertEx.Throws<ArgumentException>(async () => await client.Create("fakeOwner", "fakeRepoName", 1, null));
comment.Body = null;
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create("fakeOwner", "fakeRepoName", 1, comment));
comment.Body = "";
await AssertEx.Throws<ArgumentException>(async () => await client.Create("fakeOwner", "fakeRepoName", 1, comment));
comment.Body = body;
comment.CommitId = null;
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create("fakeOwner", "fakeRepoName", 1, comment));
comment.CommitId = "";
await AssertEx.Throws<ArgumentException>(async () => await client.Create("fakeOwner", "fakeRepoName", 1, comment));
comment.CommitId = commitId;
comment.Path = null;
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create("fakeOwner", "fakeRepoName", 1, comment));
comment.Path = "";
await AssertEx.Throws<ArgumentException>(async () => await client.Create("fakeOwner", "fakeRepoName", 1, comment));
comment.Path = path;
} }
} }
@@ -198,11 +241,7 @@ public class PullRequestReviewCommentsClientTests
var connection = Substitute.For<IApiConnection>(); var connection = Substitute.For<IApiConnection>();
var client = new PullRequestReviewCommentsClient(connection); var client = new PullRequestReviewCommentsClient(connection);
var comment = new PullRequestReviewCommentReplyCreate var comment = new PullRequestReviewCommentReplyCreate("Comment content", 5);
{
Body = "Comment content",
InReplyTo = 5
};
client.CreateReply("fakeOwner", "fakeRepoName", 13, comment); client.CreateReply("fakeOwner", "fakeRepoName", 13, comment);
@@ -219,23 +258,13 @@ public class PullRequestReviewCommentsClientTests
string body = "Comment content"; string body = "Comment content";
int inReplyTo = 7; int inReplyTo = 7;
var comment = new PullRequestReviewCommentReplyCreate var comment = new PullRequestReviewCommentReplyCreate(body, inReplyTo);
{
Body = body,
InReplyTo = inReplyTo,
};
await AssertEx.Throws<ArgumentNullException>(async () => await client.CreateReply(null, "fakeRepoName", 1, comment)); await AssertEx.Throws<ArgumentNullException>(async () => await client.CreateReply(null, "fakeRepoName", 1, comment));
await AssertEx.Throws<ArgumentException>(async () => await client.CreateReply("", "fakeRepoName", 1, comment)); await AssertEx.Throws<ArgumentException>(async () => await client.CreateReply("", "fakeRepoName", 1, comment));
await AssertEx.Throws<ArgumentNullException>(async () => await client.CreateReply("fakeOwner", null, 1, comment)); await AssertEx.Throws<ArgumentNullException>(async () => await client.CreateReply("fakeOwner", null, 1, comment));
await AssertEx.Throws<ArgumentException>(async () => await client.CreateReply("fakeOwner", "", 1, comment)); await AssertEx.Throws<ArgumentException>(async () => await client.CreateReply("fakeOwner", "", 1, comment));
await AssertEx.Throws<ArgumentException>(async () => await client.CreateReply("fakeOwner", "fakeRepoName", 1, null)); await AssertEx.Throws<ArgumentException>(async () => await client.CreateReply("fakeOwner", "fakeRepoName", 1, null));
comment.Body = null;
await AssertEx.Throws<ArgumentNullException>(async () => await client.CreateReply("fakeOwner", "fakeRepoName", 1, comment));
comment.Body = "";
await AssertEx.Throws<ArgumentException>(async () => await client.CreateReply("fakeOwner", "fakeRepoName", 1, comment));
comment.Body = body;
} }
} }
@@ -247,10 +276,7 @@ public class PullRequestReviewCommentsClientTests
var connection = Substitute.For<IApiConnection>(); var connection = Substitute.For<IApiConnection>();
var client = new PullRequestReviewCommentsClient(connection); var client = new PullRequestReviewCommentsClient(connection);
var comment = new PullRequestReviewCommentEdit var comment = new PullRequestReviewCommentEdit("New comment content");
{
Body = "New comment content",
};
client.Edit("fakeOwner", "fakeRepoName", 13, comment); client.Edit("fakeOwner", "fakeRepoName", 13, comment);
@@ -265,22 +291,13 @@ public class PullRequestReviewCommentsClientTests
var body = "New comment content"; var body = "New comment content";
var comment = new PullRequestReviewCommentEdit var comment = new PullRequestReviewCommentEdit(body);
{
Body = body,
};
await AssertEx.Throws<ArgumentNullException>(async () => await client.Edit(null, "fakeRepoName", 1, comment)); await AssertEx.Throws<ArgumentNullException>(async () => await client.Edit(null, "fakeRepoName", 1, comment));
await AssertEx.Throws<ArgumentException>(async () => await client.Edit("", "fakeRepoName", 1, comment)); await AssertEx.Throws<ArgumentException>(async () => await client.Edit("", "fakeRepoName", 1, comment));
await AssertEx.Throws<ArgumentNullException>(async () => await client.Edit("fakeOwner", null, 1, comment)); await AssertEx.Throws<ArgumentNullException>(async () => await client.Edit("fakeOwner", null, 1, comment));
await AssertEx.Throws<ArgumentException>(async () => await client.Edit("fakeOwner", "", 1, comment)); await AssertEx.Throws<ArgumentException>(async () => await client.Edit("fakeOwner", "", 1, comment));
await AssertEx.Throws<ArgumentNullException>(async () => await client.Edit("fakeOwner", null, 1, null)); await AssertEx.Throws<ArgumentNullException>(async () => await client.Edit("fakeOwner", null, 1, null));
comment.Body = null;
await AssertEx.Throws<ArgumentNullException>(async () => await client.Edit("fakeOwner", "fakeRepoName", 1, comment));
comment.Body = "";
await AssertEx.Throws<ArgumentException>(async () => await client.Edit("fakeOwner", "fakeRepoName", 1, comment));
comment.Body = body;
} }
} }

View File

@@ -276,13 +276,7 @@ namespace Octokit.Tests.Reactive
var gitHubClient = Substitute.For<IGitHubClient>(); var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient);
var comment = new PullRequestReviewCommentCreate var comment = new PullRequestReviewCommentCreate("Comment content", "qe3dsdsf6", "file.css", 7);
{
Body = "Comment content",
CommitId = "qe3dsdsf6",
Path = "file.css",
Position = 7,
};
client.Create("fakeOwner", "fakeRepoName", 13, comment); client.Create("fakeOwner", "fakeRepoName", 13, comment);
@@ -300,37 +294,13 @@ namespace Octokit.Tests.Reactive
string path = "file.css"; string path = "file.css";
int position = 7; int position = 7;
var comment = new PullRequestReviewCommentCreate var comment = new PullRequestReviewCommentCreate(body, commitId, path, position);
{
Body = body,
CommitId = commitId,
Path = path,
Position = position,
};
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create(null, "name", 1, comment)); await AssertEx.Throws<ArgumentNullException>(async () => await client.Create(null, "name", 1, comment));
await AssertEx.Throws<ArgumentException>(async () => await client.Create("", "name", 1, comment)); await AssertEx.Throws<ArgumentException>(async () => await client.Create("", "name", 1, comment));
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create("owner", null, 1, comment)); await AssertEx.Throws<ArgumentNullException>(async () => await client.Create("owner", null, 1, comment));
await AssertEx.Throws<ArgumentException>(async () => await client.Create("owner", "", 1, comment)); await AssertEx.Throws<ArgumentException>(async () => await client.Create("owner", "", 1, comment));
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create("owner", "name", 1, null)); await AssertEx.Throws<ArgumentNullException>(async () => await client.Create("owner", "name", 1, null));
comment.Body = null;
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create("owner", "name", 1, comment));
comment.Body = "";
await AssertEx.Throws<ArgumentException>(async () => await client.Create("owner", "name", 1, comment));
comment.Body = body;
comment.CommitId = null;
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create("owner", "name", 1, comment));
comment.CommitId = "";
await AssertEx.Throws<ArgumentException>(async () => await client.Create("owner", "name", 1, comment));
comment.CommitId = commitId;
comment.Path = null;
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create("owner", "name", 1, comment));
comment.Path = "";
await AssertEx.Throws<ArgumentException>(async () => await client.Create("owner", "name", 1, comment));
comment.Path = path;
} }
} }
@@ -342,11 +312,7 @@ namespace Octokit.Tests.Reactive
var gitHubClient = Substitute.For<IGitHubClient>(); var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient);
var comment = new PullRequestReviewCommentReplyCreate var comment = new PullRequestReviewCommentReplyCreate("Comment content", 9);
{
Body = "Comment content",
InReplyTo = 9,
};
client.CreateReply("fakeOwner", "fakeRepoName", 13, comment); client.CreateReply("fakeOwner", "fakeRepoName", 13, comment);
@@ -362,23 +328,13 @@ namespace Octokit.Tests.Reactive
string body = "Comment content"; string body = "Comment content";
int inReplyTo = 7; int inReplyTo = 7;
var comment = new PullRequestReviewCommentReplyCreate var comment = new PullRequestReviewCommentReplyCreate(body, inReplyTo);
{
Body = body,
InReplyTo = inReplyTo,
};
await AssertEx.Throws<ArgumentNullException>(async () => await client.CreateReply(null, "name", 1, comment)); await AssertEx.Throws<ArgumentNullException>(async () => await client.CreateReply(null, "name", 1, comment));
await AssertEx.Throws<ArgumentException>(async () => await client.CreateReply("", "name", 1, comment)); await AssertEx.Throws<ArgumentException>(async () => await client.CreateReply("", "name", 1, comment));
await AssertEx.Throws<ArgumentNullException>(async () => await client.CreateReply("owner", null, 1, comment)); await AssertEx.Throws<ArgumentNullException>(async () => await client.CreateReply("owner", null, 1, comment));
await AssertEx.Throws<ArgumentException>(async () => await client.CreateReply("owner", "", 1, comment)); await AssertEx.Throws<ArgumentException>(async () => await client.CreateReply("owner", "", 1, comment));
await AssertEx.Throws<ArgumentNullException>(async () => await client.CreateReply("owner", "name", 1, null)); await AssertEx.Throws<ArgumentNullException>(async () => await client.CreateReply("owner", "name", 1, null));
comment.Body = null;
await AssertEx.Throws<ArgumentNullException>(async () => await client.CreateReply("owner", "name", 1, comment));
comment.Body = "";
await AssertEx.Throws<ArgumentException>(async () => await client.CreateReply("owner", "name", 1, comment));
comment.Body = body;
} }
} }
@@ -390,10 +346,7 @@ namespace Octokit.Tests.Reactive
var gitHubClient = Substitute.For<IGitHubClient>(); var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservablePullRequestReviewCommentsClient(gitHubClient); var client = new ObservablePullRequestReviewCommentsClient(gitHubClient);
var comment = new PullRequestReviewCommentEdit var comment = new PullRequestReviewCommentEdit("New comment content");
{
Body = "New comment content",
};
client.Edit("fakeOwner", "fakeRepoName", 13, comment); client.Edit("fakeOwner", "fakeRepoName", 13, comment);
@@ -408,22 +361,13 @@ namespace Octokit.Tests.Reactive
var body = "New comment content"; var body = "New comment content";
var comment = new PullRequestReviewCommentEdit var comment = new PullRequestReviewCommentEdit(body);
{
Body = body,
};
await AssertEx.Throws<ArgumentNullException>(async () => await client.Edit(null, "name", 1, comment)); 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<ArgumentException>(async () => await client.Edit("", "name", 1, comment));
await AssertEx.Throws<ArgumentNullException>(async () => await client.Edit("owner", null, 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<ArgumentException>(async () => await client.Edit("owner", "", 1, comment));
await AssertEx.Throws<ArgumentNullException>(async () => await client.Edit("owner", "name", 1, null)); await AssertEx.Throws<ArgumentNullException>(async () => await client.Edit("owner", "name", 1, null));
comment.Body = null;
await AssertEx.Throws<ArgumentNullException>(async () => await client.Edit("owner", "name", 1, comment));
comment.Body = "";
await AssertEx.Throws<ArgumentException>(async () => await client.Edit("owner", "name", 1, comment));
comment.Body = body;
} }
} }

View File

@@ -86,9 +86,6 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(comment, "comment"); Ensure.ArgumentNotNull(comment, "comment");
Ensure.ArgumentNotNullOrEmptyString(comment.Body, "body");
Ensure.ArgumentNotNullOrEmptyString(comment.CommitId, "commitId");
Ensure.ArgumentNotNullOrEmptyString(comment.Path, "path");
var response = await ApiConnection.Connection.PostAsync<PullRequestReviewComment>(ApiUrls.PullRequestReviewComments(owner, name, number), comment, null, null).ConfigureAwait(false); var response = await ApiConnection.Connection.PostAsync<PullRequestReviewComment>(ApiUrls.PullRequestReviewComments(owner, name, number), comment, null, null).ConfigureAwait(false);
@@ -114,7 +111,6 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(comment, "comment"); Ensure.ArgumentNotNull(comment, "comment");
Ensure.ArgumentNotNullOrEmptyString(comment.Body, "body");
var response = await ApiConnection.Connection.PostAsync<PullRequestReviewComment>(ApiUrls.PullRequestReviewComments(owner, name, number), comment, null, null).ConfigureAwait(false); var response = await ApiConnection.Connection.PostAsync<PullRequestReviewComment>(ApiUrls.PullRequestReviewComments(owner, name, number), comment, null, null).ConfigureAwait(false);
@@ -140,7 +136,6 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(comment, "comment"); Ensure.ArgumentNotNull(comment, "comment");
Ensure.ArgumentNotNullOrEmptyString(comment.Body, "body");
return ApiConnection.Patch<PullRequestReviewComment>(ApiUrls.PullRequestReviewComment(owner, name, number), comment); return ApiConnection.Patch<PullRequestReviewComment>(ApiUrls.PullRequestReviewComment(owner, name, number), comment);
} }

View File

@@ -4,25 +4,48 @@ namespace Octokit
{ {
public class PullRequestReviewCommentCreate : RequestParameters public class PullRequestReviewCommentCreate : RequestParameters
{ {
private readonly string _body;
private readonly string _commitId;
private readonly string _path;
private readonly int _position;
/// <summary> /// <summary>
/// The text of the comment. /// The text of the comment.
/// </summary> /// </summary>
public string Body { get; set; } public string Body { get { return _body; } }
/// <summary> /// <summary>
/// The SHA of the commit to comment on. /// The SHA of the commit to comment on.
/// </summary> /// </summary>
[Parameter(Key = "commit_id")] public string CommitId { get { return _commitId; } }
public string CommitId { get; set; }
/// <summary> /// <summary>
/// The relative path of the file to comment on. /// The relative path of the file to comment on.
/// </summary> /// </summary>
public string Path { get; set; } public string Path { get { return _path; } }
/// <summary> /// <summary>
/// The line index in the diff to comment on. /// The line index in the diff to comment on.
/// </summary> /// </summary>
public int Position { get; set; } public int Position { get { return _position; } }
/// <summary>
/// Creates a comment
/// </summary>
/// <param name="body">The text of the comment</param>
/// <param name="commitId">The SHA of the commit to comment on</param>
/// <param name="path">The relative path of the file to comment on</param>
/// <param name="position">The line index in the diff to comment on</param>
public PullRequestReviewCommentCreate(string body, string commitId, string path, int position)
{
Ensure.ArgumentNotNullOrEmptyString(body, "body");
Ensure.ArgumentNotNullOrEmptyString(commitId, "commitId");
Ensure.ArgumentNotNullOrEmptyString(path, "path");
_body = body;
_commitId = commitId;
_path = path;
_position = position;
}
} }
} }

View File

@@ -3,9 +3,22 @@ namespace Octokit
{ {
public class PullRequestReviewCommentEdit : RequestParameters public class PullRequestReviewCommentEdit : RequestParameters
{ {
private readonly string _body;
/// <summary> /// <summary>
/// The text of the comment. /// The text of the comment.
/// </summary> /// </summary>
public string Body { get; set; } public string Body { get { return _body; }}
/// <summary>
/// Creates an edit to a comment
/// </summary>
/// <param name="body">The text of the comment</param>
public PullRequestReviewCommentEdit(string body)
{
Ensure.ArgumentNotNullOrEmptyString(body, "body");
_body = body;
}
} }
} }

View File

@@ -4,15 +4,30 @@ namespace Octokit
{ {
public class PullRequestReviewCommentReplyCreate : RequestParameters public class PullRequestReviewCommentReplyCreate : RequestParameters
{ {
private readonly string _body;
private readonly int _inReplyTo;
/// <summary> /// <summary>
/// The text of the comment. /// The text of the comment.
/// </summary> /// </summary>
public string Body { get; set; } public string Body { get { return _body; } }
/// <summary> /// <summary>
/// The comment Id to reply to. /// The comment Id to reply to.
/// </summary> /// </summary>
[Parameter(Key = "in_reply_to")] public int InReplyTo { get { return _inReplyTo; } }
public int InReplyTo { get; set; }
/// <summary>
/// Creates a comment that is replying to another comment.
/// </summary>
/// <param name="body">The text of the comment</param>
/// <param name="inReplyTo">The comment Id to reply to</param>
public PullRequestReviewCommentReplyCreate(string body, int inReplyTo)
{
Ensure.ArgumentNotNullOrEmptyString(body, "body");
_body = body;
_inReplyTo = inReplyTo;
}
} }
} }

View File

@@ -7,7 +7,6 @@ namespace Octokit
public PullRequestReviewCommentRequest() public PullRequestReviewCommentRequest()
{ {
// Default arguments // Default arguments
Sort = PullRequestReviewCommentSort.Created; Sort = PullRequestReviewCommentSort.Created;
Direction = SortDirection.Ascending; Direction = SortDirection.Ascending;
Since = null; Since = null;