added new integration tests

This commit is contained in:
aedampir@gmail.com
2016-06-10 20:05:40 +07:00
parent f3e90ba68f
commit 112036dda9
2 changed files with 113 additions and 0 deletions
@@ -0,0 +1,112 @@
using System.Threading.Tasks;
using Octokit.Tests.Integration.Helpers;
using Xunit;
namespace Octokit.Tests.Integration.Clients
{
public class TagsClientTests
{
public class TheCreateMethod
{
readonly RepositoryContext context;
readonly ITagsClient fixture;
readonly string sha;
public TheCreateMethod()
{
var github = Helper.GetAuthenticatedClient();
fixture = github.Git.Tag;
context = github.CreateRepositoryContext("public-repo").Result;
var blob = new NewBlob
{
Content = "Hello World!",
Encoding = EncodingType.Utf8
};
var blobResult = github.Git.Blob.Create(context.RepositoryOwner, context.RepositoryName, blob).Result;
sha = blobResult.Sha;
}
[IntegrationTest]
public async Task CreatesTagForRepository()
{
var newTag = new NewTag { Message = "Hello", Type = TaggedType.Blob, Object = sha, Tag = "tag" };
var tag = await fixture.Create(context.Repository.Id, newTag);
Assert.Equal(tag.Object.Type, TaggedType.Blob);
Assert.Equal(tag.Message, "Hello");
Assert.Equal(tag.Object.Sha, sha);
}
[IntegrationTest]
public async Task CreatesTagForRepositoryWithRepositoryId()
{
var newTag = new NewTag { Message = "Hello", Type = TaggedType.Tree, Object = sha, Tag = "tag" };
var tag = await fixture.Create(context.Repository.Id, newTag);
Assert.Equal(tag.Object.Type, TaggedType.Blob);
Assert.Equal(tag.Message, "Hello");
Assert.Equal(tag.Object.Sha, sha);
}
}
public class TheGetMethod
{
readonly RepositoryContext context;
readonly ITagsClient fixture;
readonly string sha;
public TheGetMethod()
{
var github = Helper.GetAuthenticatedClient();
fixture = github.Git.Tag;
context = github.CreateRepositoryContext("public-repo").Result;
var blob = new NewBlob
{
Content = "Hello World!",
Encoding = EncodingType.Utf8
};
var blobResult = github.Git.Blob.Create(context.RepositoryOwner, context.RepositoryName, blob).Result;
sha = blobResult.Sha;
}
[IntegrationTest]
public async Task CreatesTagForRepository()
{
var newTag = new NewTag { Message = "Hello", Type = TaggedType.Blob, Object = sha, Tag = "tag" };
var tag = await fixture.Create(context.RepositoryOwner, context.RepositoryName, newTag);
var gitTag = await fixture.Get(context.RepositoryOwner, context.RepositoryName, tag.Sha);
Assert.NotNull(gitTag);
Assert.Equal(gitTag.Object.Type, TaggedType.Blob);
Assert.Equal(gitTag.Message, "Hello");
Assert.Equal(gitTag.Object.Sha, sha);
}
[IntegrationTest]
public async Task CreatesTagForRepositoryWithRepositoryId()
{
var github = Helper.GetAuthenticatedClient();
var newTag = new NewTag { Message = "Hello", Type = TaggedType.Blob, Object = sha, Tag = "tag" };
var tag = await github.Git.Tag.Create(context.Repository.Id, newTag);
var gitTag = await github.Git.Tag.Get(context.Repository.Id, tag.Sha);
Assert.NotNull(gitTag);
Assert.Equal(gitTag.Object.Type, TaggedType.Blob);
Assert.Equal(gitTag.Message, "Hello");
Assert.Equal(gitTag.Object.Sha, sha);
}
}
}
}
@@ -108,6 +108,7 @@
<Compile Include="Clients\SearchClientTests.cs" />
<Compile Include="Clients\StarredClientTests.cs" />
<Compile Include="Clients\StatisticsClientTests.cs" />
<Compile Include="Clients\TagsClientTests.cs" />
<Compile Include="Clients\TreeClientTests.cs" />
<Compile Include="Clients\UserAdministrationClientTests.cs" />
<Compile Include="Clients\UserEmailsClientTests.cs" />