add integration test for CommitCommentReactionsClient

This commit is contained in:
maddin2016
2016-06-02 08:49:40 +02:00
parent 5fcc30d068
commit 7794aaf421
3 changed files with 75 additions and 65 deletions
@@ -0,0 +1,74 @@
using Octokit;
using Octokit.Tests.Integration;
using Octokit.Tests.Integration.Helpers;
using System;
using System.Threading.Tasks;
using Xunit;
public class CommitCommentReactionsClientTests
{
public class TheCreateReactionMethod : IDisposable
{
private readonly IGitHubClient _github;
private readonly RepositoryContext _context;
public TheCreateReactionMethod()
{
_github = Helper.GetAuthenticatedClient();
_context = _github.CreateRepositoryContext("public-repo").Result;
}
private async Task<Commit> SetupCommitForRepository(IGitHubClient client)
{
var blob = new NewBlob
{
Content = "Hello World!",
Encoding = EncodingType.Utf8
};
var blobResult = await client.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob);
var newTree = new NewTree();
newTree.Tree.Add(new NewTreeItem
{
Type = TreeType.Blob,
Mode = FileMode.File,
Path = "README.md",
Sha = blobResult.Sha
});
var treeResult = await client.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree);
var newCommit = new NewCommit("test-commit", treeResult.Sha);
return await client.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit);
}
[IntegrationTest]
public async Task CanCreateReaction()
{
var commit = await SetupCommitForRepository(_github);
var comment = new NewCommitComment("test");
var result = await _github.Repository.Comment.Create(_context.RepositoryOwner, _context.RepositoryName,
commit.Sha, comment);
Assert.NotNull(result);
var newReaction = new NewReaction(ReactionType.Confused);
var reaction = await _github.Reaction.CommitComment.Create(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReaction);
Assert.IsType<Reaction>(reaction);
Assert.Equal(ReactionType.Confused, reaction.Content);
Assert.Equal(result.User.Id, reaction.UserId);
}
public void Dispose()
{
_context.Dispose();
}
}
}
@@ -376,69 +376,4 @@ public class RepositoryCommentsClientTests
_context.Dispose();
}
}
//public class TheCreateReactionMethod : IDisposable
//{
// private readonly IGitHubClient _github;
// private readonly RepositoryContext _context;
// public TheCreateReactionMethod()
// {
// _github = Helper.GetAuthenticatedClient();
// _context = _github.CreateRepositoryContext("public-repo").Result;
// }
// private async Task<Commit> SetupCommitForRepository(IGitHubClient client)
// {
// var blob = new NewBlob
// {
// Content = "Hello World!",
// Encoding = EncodingType.Utf8
// };
// var blobResult = await client.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob);
// var newTree = new NewTree();
// newTree.Tree.Add(new NewTreeItem
// {
// Type = TreeType.Blob,
// Mode = FileMode.File,
// Path = "README.md",
// Sha = blobResult.Sha
// });
// var treeResult = await client.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree);
// var newCommit = new NewCommit("test-commit", treeResult.Sha);
// return await client.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit);
// }
// [IntegrationTest]
// public async Task CanCreateReaction()
// {
// var commit = await SetupCommitForRepository(_github);
// var comment = new NewCommitComment("test");
// var result = await _github.Repository.Comment.Create(_context.RepositoryOwner, _context.RepositoryName,
// commit.Sha, comment);
// Assert.NotNull(result);
// var newReaction = new NewReaction(ReactionType.Confused);
// var reaction = await _github.Repository.Comment.CreateReaction(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReaction);
// Assert.IsType<Reaction>(reaction);
// Assert.Equal(ReactionType.Confused, reaction.Content);
// Assert.Equal(result.User.Id, reaction.UserId);
// }
// public void Dispose()
// {
// _context.Dispose();
// }
//}
}
@@ -77,6 +77,7 @@
<Compile Include="Clients\AuthorizationClientTests.cs" />
<Compile Include="Clients\BlobClientTests.cs" />
<Compile Include="Clients\BranchesClientTests.cs" />
<Compile Include="Clients\CommitCommentReactionsClientTests.cs" />
<Compile Include="Clients\Enterprise\EnterpriseLdapClientTests.cs" />
<Compile Include="Clients\Enterprise\EnterpriseLicenseClientTests.cs" />
<Compile Include="Clients\Enterprise\EnterpriseAdminStatsClientTests.cs" />