diff --git a/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs
index 1a8ed9b9..804e5d7a 100644
--- a/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs
+++ b/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs
@@ -4,6 +4,12 @@ using System.Reactive;
namespace Octokit.Reactive
{
+ ///
+ /// A client for GitHub's Repository Comments API.
+ ///
+ ///
+ /// See the Repository Comments API documentation for more information.
+ ///
public interface IObservableRepositoryCommentsClient
{
///
@@ -13,20 +19,35 @@ namespace Octokit.Reactive
/// The owner of the repository
/// The name of the repository
/// The comment id
- ///
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
- Justification = "Method makes a network request")]
+ Justification = "Method makes a network request")]
IObservable Get(string owner, string name, int number);
+ ///
+ /// Gets a single Repository Comment by number.
+ ///
+ /// http://developer.github.com/v3/repos/comments/#get-a-single-commit-comment
+ /// The ID of the repository
+ /// The comment id
+ [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
+ Justification = "Method makes a network request")]
+ IObservable Get(int repositoryId, int number);
+
///
/// Gets Commit Comments for a repository.
///
/// http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository
/// The owner of the repository
/// The name of the repository
- ///
IObservable GetAllForRepository(string owner, string name);
+ ///
+ /// Gets Commit Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository
+ /// The ID of the repository
+ IObservable GetAllForRepository(int repositoryId);
+
///
/// Gets Commit Comments for a repository.
///
@@ -34,9 +55,16 @@ namespace Octokit.Reactive
/// The owner of the repository
/// The name of the repository
/// Options to change the API response
- ///
IObservable GetAllForRepository(string owner, string name, ApiOptions options);
+ ///
+ /// Gets Commit Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository
+ /// The ID of the repository
+ /// Options to change the API response
+ IObservable GetAllForRepository(int repositoryId, ApiOptions options);
+
///
/// Gets Commit Comments for a specified Commit.
///
@@ -44,9 +72,16 @@ namespace Octokit.Reactive
/// The owner of the repository
/// The name of the repository
/// The sha of the commit
- ///
IObservable GetAllForCommit(string owner, string name, string sha);
+ ///
+ /// Gets Commit Comments for a specified Commit.
+ ///
+ /// http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit
+ /// The ID of the repository
+ /// The sha of the commit
+ IObservable GetAllForCommit(int repositoryId, string sha);
+
///
/// Gets Commit Comments for a specified Commit.
///
@@ -55,9 +90,17 @@ namespace Octokit.Reactive
/// The name of the repository
/// The sha of the commit
/// Options to change the API response
- ///
IObservable GetAllForCommit(string owner, string name, string sha, ApiOptions options);
+ ///
+ /// Gets Commit Comments for a specified Commit.
+ ///
+ /// http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit
+ /// The ID of the repository
+ /// The sha of the commit
+ /// Options to change the API response
+ IObservable GetAllForCommit(int repositoryId, string sha, ApiOptions options);
+
///
/// Creates a new Commit Comment for a specified Commit.
///
@@ -66,9 +109,17 @@ namespace Octokit.Reactive
/// The name of the repository
/// The sha reference of commit
/// The new comment to add to the commit
- ///
IObservable Create(string owner, string name, string sha, NewCommitComment newCommitComment);
+ ///
+ /// Creates a new Commit Comment for a specified Commit.
+ ///
+ /// http://developer.github.com/v3/repos/comments/#create-a-commit-comment
+ /// The ID of the repository
+ /// The sha reference of commit
+ /// The new comment to add to the commit
+ IObservable Create(int repositoryId, string sha, NewCommitComment newCommitComment);
+
///
/// Updates a specified Commit Comment.
///
@@ -77,9 +128,17 @@ namespace Octokit.Reactive
/// The name of the repository
/// The comment number
/// The modified comment
- ///
IObservable Update(string owner, string name, int number, string commentUpdate);
+ ///
+ /// Updates a specified Commit Comment.
+ ///
+ /// http://developer.github.com/v3/repos/comments/#update-a-commit-comment
+ /// The ID of the repository
+ /// The comment number
+ /// The modified comment
+ IObservable Update(int repositoryId, int number, string commentUpdate);
+
///
/// Deletes the specified Commit Comment
///
@@ -87,7 +146,14 @@ namespace Octokit.Reactive
/// The owner of the repository
/// The name of the repository
/// The comment id
- ///
IObservable Delete(string owner, string name, int number);
+
+ ///
+ /// Deletes the specified Commit Comment
+ ///
+ /// http://developer.github.com/v3/repos/comments/#delete-a-commit-comment
+ /// The ID of the repository
+ /// The comment id
+ IObservable Delete(int repositoryId, int number);
}
}
diff --git a/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs
index 3826850f..48391689 100644
--- a/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs
+++ b/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs
@@ -5,11 +5,17 @@ using Octokit.Reactive.Internal;
namespace Octokit.Reactive
{
+ ///
+ /// A client for GitHub's Repository Comments API.
+ ///
+ ///
+ /// See the Repository Comments API documentation for more information.
+ ///
public class ObservableRepositoryCommentsClient : IObservableRepositoryCommentsClient
{
readonly IRepositoryCommentsClient _client;
readonly IConnection _connection;
-
+
public ObservableRepositoryCommentsClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, "client");
@@ -21,11 +27,10 @@ namespace Octokit.Reactive
///
/// Gets a single Repository Comment by number.
///
- /// http://developer.github.com/v3/repos/comments/#get-a-single-commit-comment
/// The owner of the repository
/// The name of the repository
/// The comment id
- ///
+ /// http://developer.github.com/v3/repos/comments/#get-a-single-commit-comment
public IObservable Get(string owner, string name, int number)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -34,13 +39,23 @@ namespace Octokit.Reactive
return _client.Get(owner, name, number).ToObservable();
}
+ ///
+ /// Gets a single Repository Comment by number.
+ ///
+ /// The ID of the repository
+ /// The comment id
+ /// http://developer.github.com/v3/repos/comments/#get-a-single-commit-comment
+ public IObservable Get(int repositoryId, int number)
+ {
+ return _client.Get(repositoryId, number).ToObservable();
+ }
+
///
/// Gets Commit Comments for a repository.
///
- /// http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository
/// The owner of the repository
/// The name of the repository
- ///
+ /// http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository
public IObservable GetAllForRepository(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -52,11 +67,20 @@ namespace Octokit.Reactive
///
/// Gets Commit Comments for a repository.
///
+ /// The ID of the repository
/// http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository
+ public IObservable GetAllForRepository(int repositoryId)
+ {
+ return GetAllForRepository(repositoryId, ApiOptions.None);
+ }
+
+ ///
+ /// Gets Commit Comments for a repository.
+ ///
/// The owner of the repository
/// The name of the repository
/// Options to change the API response
- ///
+ /// http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository
public IObservable GetAllForRepository(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -66,14 +90,26 @@ namespace Octokit.Reactive
return _connection.GetAndFlattenAllPages(ApiUrls.CommitComments(owner, name), options);
}
+ ///
+ /// Gets Commit Comments for a repository.
+ ///
+ /// The ID of the repository
+ /// Options to change the API response
+ /// http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository
+ public IObservable GetAllForRepository(int repositoryId, ApiOptions options)
+ {
+ Ensure.ArgumentNotNull(options, "options");
+
+ return _connection.GetAndFlattenAllPages(ApiUrls.CommitComments(repositoryId), options);
+ }
+
///
/// Gets Commit Comments for a specified Commit.
///
- /// http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit
/// The owner of the repository
/// The name of the repository
/// The sha of the commit
- ///
+ /// http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit
public IObservable GetAllForCommit(string owner, string name, string sha)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -86,12 +122,24 @@ namespace Octokit.Reactive
///
/// Gets Commit Comments for a specified Commit.
///
+ /// The ID of the repository
+ /// The sha of the commit
/// http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit
+ public IObservable GetAllForCommit(int repositoryId, string sha)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(sha, "sha");
+
+ return GetAllForCommit(repositoryId, sha, ApiOptions.None);
+ }
+
+ ///
+ /// Gets Commit Comments for a specified Commit.
+ ///
/// The owner of the repository
/// The name of the repository
/// The sha of the commit
/// Options to change the API response
- ///
+ /// http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit
public IObservable GetAllForCommit(string owner, string name, string sha, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -102,15 +150,29 @@ namespace Octokit.Reactive
return _connection.GetAndFlattenAllPages(ApiUrls.CommitComments(owner, name, sha), options);
}
+ ///
+ /// Gets Commit Comments for a specified Commit.
+ ///
+ /// The ID of the repository
+ /// The sha of the commit
+ /// Options to change the API response
+ /// http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit
+ public IObservable GetAllForCommit(int repositoryId, string sha, ApiOptions options)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(sha, "sha");
+ Ensure.ArgumentNotNull(options, "options");
+
+ return _connection.GetAndFlattenAllPages(ApiUrls.CommitComments(repositoryId, sha), options);
+ }
+
///
/// Creates a new Commit Comment for a specified Commit.
///
- /// http://developer.github.com/v3/repos/comments/#create-a-commit-comment
/// The owner of the repository
/// The name of the repository
/// The sha reference of commit
/// The new comment to add to the commit
- ///
+ /// http://developer.github.com/v3/repos/comments/#create-a-commit-comment
public IObservable Create(string owner, string name, string sha, NewCommitComment newCommitComment)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -121,15 +183,29 @@ namespace Octokit.Reactive
return _client.Create(owner, name, sha, newCommitComment).ToObservable();
}
+ ///
+ /// Creates a new Commit Comment for a specified Commit.
+ ///
+ /// The ID of the repository
+ /// The sha reference of commit
+ /// The new comment to add to the commit
+ /// http://developer.github.com/v3/repos/comments/#create-a-commit-comment
+ public IObservable Create(int repositoryId, string sha, NewCommitComment newCommitComment)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(sha, "sha");
+ Ensure.ArgumentNotNull(newCommitComment, "newCommitComment");
+
+ return _client.Create(repositoryId, sha, newCommitComment).ToObservable();
+ }
+
///
/// Updates a specified Commit Comment.
///
- /// http://developer.github.com/v3/repos/comments/#update-a-commit-comment
/// The owner of the repository
/// The name of the repository
/// The comment number
/// The modified comment
- ///
+ /// http://developer.github.com/v3/repos/comments/#update-a-commit-comment
public IObservable Update(string owner, string name, int number, string commentUpdate)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -139,14 +215,27 @@ namespace Octokit.Reactive
return _client.Update(owner, name, number, commentUpdate).ToObservable();
}
+ ///
+ /// Updates a specified Commit Comment.
+ ///
+ /// The ID of the repository
+ /// The comment number
+ /// The modified comment
+ /// http://developer.github.com/v3/repos/comments/#update-a-commit-comment
+ public IObservable Update(int repositoryId, int number, string commentUpdate)
+ {
+ Ensure.ArgumentNotNull(commentUpdate, "commentUpdate");
+
+ return _client.Update(repositoryId, number, commentUpdate).ToObservable();
+ }
+
///
/// Deletes the specified Commit Comment
///
- /// http://developer.github.com/v3/repos/comments/#delete-a-commit-comment
/// The owner of the repository
/// The name of the repository
/// The comment id
- ///
+ /// http://developer.github.com/v3/repos/comments/#delete-a-commit-comment
public IObservable Delete(string owner, string name, int number)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -154,5 +243,16 @@ namespace Octokit.Reactive
return _client.Delete(owner, name, number).ToObservable();
}
+
+ ///
+ /// Deletes the specified Commit Comment
+ ///
+ /// The ID of the repository
+ /// The comment id
+ /// http://developer.github.com/v3/repos/comments/#delete-a-commit-comment
+ public IObservable Delete(int repositoryId, int number)
+ {
+ return _client.Delete(repositoryId, number).ToObservable();
+ }
}
}
diff --git a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs
index dad6ab1a..8421cfda 100644
--- a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs
@@ -12,6 +12,7 @@ public class RepositoryCommentsClientTests
readonly IRepositoryCommentsClient _fixture;
const string owner = "octocat";
const string name = "Hello-World";
+ const int repositoryId = 1296269;
public TheGetMethod()
{
@@ -26,6 +27,13 @@ public class RepositoryCommentsClientTests
var commit = await _fixture.Get(owner, name, 1467023);
Assert.NotNull(commit);
}
+
+ [IntegrationTest]
+ public async Task CanGetCommentWithRepositoryId()
+ {
+ var commit = await _fixture.Get(repositoryId, 1467023);
+ Assert.NotNull(commit);
+ }
}
public class TheGetAllForRepositoryMethod
@@ -33,6 +41,7 @@ public class RepositoryCommentsClientTests
readonly IRepositoryCommentsClient _fixture;
const string owner = "octocat";
const string name = "Hello-World";
+ const int repositoryId = 1296269;
public TheGetAllForRepositoryMethod()
{
@@ -48,6 +57,13 @@ public class RepositoryCommentsClientTests
Assert.NotEmpty(list);
}
+ [IntegrationTest]
+ public async Task CanGetListOfCommentsForRepositoryWithRepositoryId()
+ {
+ var list = await _fixture.GetAllForRepository(repositoryId);
+ Assert.NotEmpty(list);
+ }
+
[IntegrationTest]
public async Task CanGetCorrectCountOfCommentsWithoutStart()
{
@@ -61,6 +77,19 @@ public class RepositoryCommentsClientTests
Assert.Equal(5, commits.Count);
}
+ [IntegrationTest]
+ public async Task CanGetCorrectCountOfCommentsWithoutStartWithRepositoryId()
+ {
+ var options = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1
+ };
+
+ var commits = await _fixture.GetAllForRepository(repositoryId, options);
+ Assert.Equal(5, commits.Count);
+ }
+
[IntegrationTest]
public async Task CanGetCorrectCountOfCommentsWithStart()
{
@@ -75,6 +104,20 @@ public class RepositoryCommentsClientTests
Assert.Equal(5, commits.Count);
}
+ [IntegrationTest]
+ public async Task CanGetCorrectCountOfCommentsWithStartWithRepositoryId()
+ {
+ var options = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1,
+ StartPage = 2
+ };
+
+ var commits = await _fixture.GetAllForRepository(repositoryId, options);
+ Assert.Equal(5, commits.Count);
+ }
+
[IntegrationTest]
public async Task ReturnsDistinctResultsBasedOnStart()
{
@@ -100,6 +143,32 @@ public class RepositoryCommentsClientTests
Assert.NotEqual(firstCommit[3].Id, secondCommit[3].Id);
Assert.NotEqual(firstCommit[4].Id, secondCommit[4].Id);
}
+
+ [IntegrationTest]
+ public async Task ReturnsDistinctResultsBasedOnStartWithRepositoryId()
+ {
+ var startOptions = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1
+ };
+
+ var skipStartOptions = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1,
+ StartPage = 2
+ };
+
+ var firstCommit = await _fixture.GetAllForRepository(repositoryId, startOptions);
+ var secondCommit = await _fixture.GetAllForRepository(repositoryId, skipStartOptions);
+
+ Assert.NotEqual(firstCommit[0].Id, secondCommit[0].Id);
+ Assert.NotEqual(firstCommit[1].Id, secondCommit[1].Id);
+ Assert.NotEqual(firstCommit[2].Id, secondCommit[2].Id);
+ Assert.NotEqual(firstCommit[3].Id, secondCommit[3].Id);
+ Assert.NotEqual(firstCommit[4].Id, secondCommit[4].Id);
+ }
}
public class TheGetAllForCommitMethod
@@ -107,6 +176,7 @@ public class RepositoryCommentsClientTests
readonly IRepositoryCommentsClient _fixture;
const string owner = "octocat";
const string name = "Hello-World";
+ const int repositoryId = 1296269;
public TheGetAllForCommitMethod()
{
@@ -122,6 +192,13 @@ public class RepositoryCommentsClientTests
Assert.NotEmpty(list);
}
+ [IntegrationTest]
+ public async Task CanGetListOfCommentsForCommitWithRepositoryId()
+ {
+ var list = await _fixture.GetAllForCommit(repositoryId, "7fd1a60b01f91b314f59955a4e4d4e80d8edf11d");
+ Assert.NotEmpty(list);
+ }
+
[IntegrationTest]
public async Task CanGetCorrectCountOfCommentsWithoutStartForCommit()
{
@@ -135,6 +212,19 @@ public class RepositoryCommentsClientTests
Assert.Equal(5, commits.Count);
}
+ [IntegrationTest]
+ public async Task CanGetCorrectCountOfCommentsWithoutStartForCommitWithRepositoryId()
+ {
+ var options = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1
+ };
+
+ var commits = await _fixture.GetAllForCommit(repositoryId, "7fd1a60b01f91b314f59955a4e4d4e80d8edf11d", options);
+ Assert.Equal(5, commits.Count);
+ }
+
[IntegrationTest]
public async Task CanGetCorrectCountOfCommentsWithStartForCommit()
{
@@ -149,6 +239,20 @@ public class RepositoryCommentsClientTests
Assert.Equal(5, commits.Count);
}
+ [IntegrationTest]
+ public async Task CanGetCorrectCountOfCommentsWithStartForCommitWithRepositoryId()
+ {
+ var options = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1,
+ StartPage = 2
+ };
+
+ var commits = await _fixture.GetAllForCommit(repositoryId, "7fd1a60b01f91b314f59955a4e4d4e80d8edf11d", options);
+ Assert.Equal(5, commits.Count);
+ }
+
[IntegrationTest]
public async Task ReturnsDistinctResultsBasedOnStartForCommit()
{
@@ -174,6 +278,32 @@ public class RepositoryCommentsClientTests
Assert.NotEqual(firstCommit[3].Id, secondCommit[3].Id);
Assert.NotEqual(firstCommit[4].Id, secondCommit[4].Id);
}
+
+ [IntegrationTest]
+ public async Task ReturnsDistinctResultsBasedOnStartForCommitWithRepositoryId()
+ {
+ var startOptions = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1
+ };
+
+ var skipStartOptions = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1,
+ StartPage = 2
+ };
+
+ var firstCommit = await _fixture.GetAllForCommit(repositoryId, "7fd1a60b01f91b314f59955a4e4d4e80d8edf11d", startOptions);
+ var secondCommit = await _fixture.GetAllForCommit(repositoryId, "7fd1a60b01f91b314f59955a4e4d4e80d8edf11d", skipStartOptions);
+
+ Assert.NotEqual(firstCommit[0].Id, secondCommit[0].Id);
+ Assert.NotEqual(firstCommit[1].Id, secondCommit[1].Id);
+ Assert.NotEqual(firstCommit[2].Id, secondCommit[2].Id);
+ Assert.NotEqual(firstCommit[3].Id, secondCommit[3].Id);
+ Assert.NotEqual(firstCommit[4].Id, secondCommit[4].Id);
+ }
}
public class TheCreateMethod : IDisposable
@@ -230,6 +360,23 @@ public class RepositoryCommentsClientTests
Assert.NotNull(retrieved);
}
+ [IntegrationTest]
+ public async Task CanCreateCommentWithRepositoryId()
+ {
+ var commit = await SetupCommitForRepository(_github);
+
+ var comment = new NewCommitComment("test");
+
+ var result = await _github.Repository.Comment.Create(_context.Repository.Id,
+ commit.Sha, comment);
+
+ Assert.NotNull(result);
+
+ var retrieved = await _github.Repository.Comment.Get(_context.Repository.Id, result.Id);
+
+ Assert.NotNull(retrieved);
+ }
+
public void Dispose()
{
_context.Dispose();
@@ -296,6 +443,29 @@ public class RepositoryCommentsClientTests
Assert.Equal("new comment", retrievedAfter.Body);
}
+ [IntegrationTest]
+ public async Task CanUpdateCommentWithRepositoryId()
+ {
+ var commit = await SetupCommitForRepository(_github);
+
+ var comment = new NewCommitComment("test");
+
+ var result = await _github.Repository.Comment.Create(_context.Repository.Id,
+ commit.Sha, comment);
+
+ Assert.NotNull(result);
+
+ var retrievedBefore = await _github.Repository.Comment.Get(_context.Repository.Id, result.Id);
+
+ Assert.NotNull(retrievedBefore);
+
+ await _github.Repository.Comment.Update(_context.Repository.Id, result.Id, "new comment");
+
+ var retrievedAfter = await _github.Repository.Comment.Get(_context.Repository.Id, result.Id);
+
+ Assert.Equal("new comment", retrievedAfter.Body);
+ }
+
public void Dispose()
{
_context.Dispose();
@@ -371,6 +541,38 @@ public class RepositoryCommentsClientTests
Assert.True(notFound);
}
+ [IntegrationTest]
+ public async Task CanDeleteCommentWithRepositoryId()
+ {
+ var commit = await SetupCommitForRepository(_github);
+
+ var comment = new NewCommitComment("test");
+
+ var result = await _github.Repository.Comment.Create(_context.Repository.Id,
+ commit.Sha, comment);
+
+ Assert.NotNull(result);
+
+ var retrievedBefore = await _github.Repository.Comment.Get(_context.Repository.Id, result.Id);
+
+ Assert.NotNull(retrievedBefore);
+
+ await _github.Repository.Comment.Delete(_context.Repository.Id, result.Id);
+
+ var notFound = false;
+
+ try
+ {
+ await _github.Repository.Comment.Get(_context.Repository.Id, result.Id);
+ }
+ catch (NotFoundException)
+ {
+ notFound = true;
+ }
+
+ Assert.True(notFound);
+ }
+
public void Dispose()
{
_context.Dispose();
diff --git a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs
index 2628f060..b54ef6a6 100644
--- a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs
+++ b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs
@@ -23,19 +23,31 @@ public class RepositoryCommentsClientTests
connection.Received().Get(Arg.Is(u => u.ToString() == "repos/fake/repo/comments/42"));
}
+ [Fact]
+ public async Task RequestsCorrectUrlWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new RepositoryCommentsClient(connection);
+
+ await client.Get(1, 42);
+
+ connection.Received().Get(Arg.Is(u => u.ToString() == "repositories/1/comments/42"));
+ }
+
[Fact]
public async Task EnsuresNonNullArguments()
{
var client = new RepositoryCommentsClient(Substitute.For());
await Assert.ThrowsAsync(() => client.Get(null, "name", 1));
- await Assert.ThrowsAsync(() => client.Get("", "name", 1));
await Assert.ThrowsAsync(() => client.Get("owner", null, 1));
+
+ await Assert.ThrowsAsync(() => client.Get("", "name", 1));
await Assert.ThrowsAsync(() => client.Get("owner", "", 1));
}
}
- public class TheGetForRepositoryMethod
+ public class TheGetAllForRepositoryMethod
{
[Fact]
public async Task RequestsCorrectUrl()
@@ -48,6 +60,17 @@ public class RepositoryCommentsClientTests
connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/comments"), Args.ApiOptions);
}
+ [Fact]
+ public async Task RequestsCorrectUrlWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new RepositoryCommentsClient(connection);
+
+ await client.GetAllForRepository(1);
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/comments"), Args.ApiOptions);
+ }
+
[Fact]
public async Task RequestsCorrectUrlWithApiOptions()
{
@@ -67,21 +90,38 @@ public class RepositoryCommentsClientTests
}
[Fact]
- public async Task EnsuresArgumentsNotNull()
+ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()
+ {
+ var connection = Substitute.For();
+ var client = new RepositoryCommentsClient(connection);
+
+ var options = new ApiOptions
+ {
+ StartPage = 1,
+ PageCount = 1,
+ PageSize = 1
+ };
+
+ await client.GetAllForRepository(1, options);
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/comments"), options);
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For();
var client = new RepositoryCommentsClient(connection);
- await Assert.ThrowsAsync(() => client.GetAllForRepository(null, null, null));
- await Assert.ThrowsAsync(() => client.GetAllForRepository(null, null, ApiOptions.None));
- await Assert.ThrowsAsync(() => client.GetAllForRepository(null, "name", null));
- await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null, null));
- await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name", null));
- await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null, ApiOptions.None));
await Assert.ThrowsAsync(() => client.GetAllForRepository(null, "name", ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null, ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name", null));
+
await Assert.ThrowsAsync(() => client.GetAllForRepository(null, "name"));
await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null));
+ await Assert.ThrowsAsync(() => client.GetAllForRepository(1, null));
+
await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name"));
await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", ""));
await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name", ApiOptions.None));
@@ -103,6 +143,18 @@ public class RepositoryCommentsClientTests
Args.ApiOptions);
}
+ [Fact]
+ public async Task RequestsCorrectUrlWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new RepositoryCommentsClient(connection);
+
+ await client.GetAllForCommit(1, "sha");
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/commits/sha/comments"),
+ Args.ApiOptions);
+ }
+
[Fact]
public async Task RequestsCorrectUrlWithApiOptions()
{
@@ -122,36 +174,48 @@ public class RepositoryCommentsClientTests
}
[Fact]
- public async Task EnsuresArgumentsNotNull()
+ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()
{
var connection = Substitute.For();
var client = new RepositoryCommentsClient(connection);
- await Assert.ThrowsAsync(() => client.GetAllForCommit(null, null, null, null));
- await Assert.ThrowsAsync(() => client.GetAllForCommit(null, null, null, ApiOptions.None));
- await Assert.ThrowsAsync(() => client.GetAllForCommit(null, null, "sha1", null));
- await Assert.ThrowsAsync(() => client.GetAllForCommit(null, "name", null, null));
- await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", null, null, null));
+ var options = new ApiOptions
+ {
+ StartPage = 1,
+ PageCount = 1,
+ PageSize = 1
+ };
- await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "name", null, null));
+ await client.GetAllForCommit(1, "sha", options);
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/commits/sha/comments"), options);
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var connection = Substitute.For();
+ var client = new RepositoryCommentsClient(connection);
+
+ await Assert.ThrowsAsync(() => client.GetAllForCommit(null, "name", "sha"));
+ await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", null, "sha"));
+ await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "name", null));
+ await Assert.ThrowsAsync(() => client.GetAllForCommit(null, "name", "sha", ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", null, "sha", ApiOptions.None));
await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "name", null, ApiOptions.None));
- await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "name", "sha1", null));
- await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "name", null, ApiOptions.None));
- await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", null, "sha1", ApiOptions.None));
- await Assert.ThrowsAsync(() => client.GetAllForCommit(null, "name", "sha1", ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "name", "sha", null));
- await Assert.ThrowsAsync(() => client.GetAllForCommit("", "", "", null));
- await Assert.ThrowsAsync(() => client.GetAllForCommit("", "", "", ApiOptions.None));
- await Assert.ThrowsAsync(() => client.GetAllForCommit("", "", "sha1", null));
- await Assert.ThrowsAsync(() => client.GetAllForCommit("", "name", "", null));
- await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "", "", null));
+ await Assert.ThrowsAsync(() => client.GetAllForCommit(1, null, ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForCommit(1, "sha", null));
+
+ await Assert.ThrowsAsync(() => client.GetAllForCommit("", "name", "sha"));
+ await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "", "sha"));
+ await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "name", ""));
+ await Assert.ThrowsAsync(() => client.GetAllForCommit("", "name", "sha", ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "", "sha", ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "name", "", ApiOptions.None));
- await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "name", "", null));
- await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "name", "", ApiOptions.None));
- await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "name", "sha1", null));
- await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "name", "", ApiOptions.None));
- await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "", "sha1", ApiOptions.None));
- await Assert.ThrowsAsync(() => client.GetAllForCommit("", "name", "sha1", ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForCommit(1, "", ApiOptions.None));
}
}
@@ -160,7 +224,7 @@ public class RepositoryCommentsClientTests
[Fact]
public async Task PostsToCorrectUrl()
{
- NewCommitComment newComment = new NewCommitComment("body");
+ var newComment = new NewCommitComment("body");
var connection = Substitute.For();
var client = new RepositoryCommentsClient(connection);
@@ -171,18 +235,36 @@ public class RepositoryCommentsClientTests
}
[Fact]
- public async Task EnsuresArgumentsNotNull()
+ public async Task PostsToCorrectUrlWithRepositoryId()
+ {
+ var newComment = new NewCommitComment("body");
+
+ var connection = Substitute.For();
+ var client = new RepositoryCommentsClient(connection);
+
+ await client.Create(1, "sha", newComment);
+
+ connection.Received().Post(Arg.Is(u => u.ToString() == "repositories/1/commits/sha/comments"), Arg.Any