added tests specific to redirects

This commit is contained in:
Brendan Forster
2015-06-05 15:59:58 +09:30
parent ea4804048e
commit 72339c81d1
3 changed files with 46 additions and 15 deletions
@@ -537,23 +537,8 @@ public class RepositoriesClientTests
Assert.Equal("https://github.com/Haacked/libgit2sharp.git", repository.CloneUrl);
Assert.True(repository.Fork);
}
[IntegrationTest]
public async Task ReturnsRedirectedRepository()
{
var github = Helper.GetAuthenticatedClient();
var repository = await github.Repository.Get("robconery", "massive");
Assert.Equal("https://github.com/FransBouma/Massive.git", repository.CloneUrl);
Assert.False(repository.Private);
Assert.False(repository.Fork);
Assert.Equal(AccountType.User, repository.Owner.Type);
}
}
public class TheGetAllPublicMethod
{
[IntegrationTest(Skip = "Takes too long to run.")]
@@ -120,6 +120,7 @@
<Compile Include="Reactive\ObservableRespositoryDeployKeysClientTests.cs" />
<Compile Include="Reactive\ObservableUserEmailsClientTests.cs" />
<Compile Include="Reactive\ObservableTeamsClientTests.cs" />
<Compile Include="RedirectTests.cs" />
<Compile Include="SelfTests.cs" />
</ItemGroup>
<ItemGroup>
@@ -0,0 +1,45 @@
using System.Threading.Tasks;
using Xunit;
namespace Octokit.Tests.Integration
{
public class RedirectTests
{
[IntegrationTest]
public async Task ReturnsRedirectedRepository()
{
var github = Helper.GetAuthenticatedClient();
var repository = await github.Repository.Get("robconery", "massive");
Assert.Equal("https://github.com/FransBouma/Massive.git", repository.CloneUrl);
Assert.False(repository.Private);
Assert.False(repository.Fork);
Assert.Equal(AccountType.User, repository.Owner.Type);
}
[IntegrationTest]
public async Task CanCreateIssueOnRedirectedRepository()
{
var client = Helper.GetAuthenticatedClient();
var owner = "shiftkey-tester";
var oldRepoName = "repository-before-rename";
var newRepoName = "repository-after-rename";
var newIssue = new NewIssue("a test issue") { Body = "A new unassigned issue" };
var issue = await client.Issue.Create(owner, oldRepoName, newIssue);
Assert.NotNull(issue);
Assert.True(issue.Url.AbsoluteUri.Contains("repository-after-rename"));
var resolvedIssue = await client.Issue.Get(owner, newRepoName, issue.Number);
Assert.NotNull(resolvedIssue);
var update = resolvedIssue.ToUpdate();
update.State = ItemState.Closed;
await client.Issue.Update(owner, oldRepoName, issue.Number, update);
}
}
}