Add repositoryId overloads to methods on I(Observable)RepositoryCommentsClient (#1344)

This commit is contained in:
Alexander Efremov
2016-06-18 04:47:43 +07:00
committed by Brendan Forster
parent 637802c90a
commit 6bd1f06962
7 changed files with 986 additions and 134 deletions
@@ -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();