Octokit.Tests.Integration\Clients

This commit is contained in:
Mordechai Zuber
2015-05-19 09:54:08 +03:00
parent ea90328332
commit d83a4bbcbc
7 changed files with 23 additions and 29 deletions

View File

@@ -119,7 +119,7 @@ namespace Octokit.Tests.Integration.Clients
Assert.Equal(created.Token, applicationAuthorization.Token);
await client.Authorization.Delete(created.Id);
AssertEx.Throws<NotFoundException>(async () => await client.Authorization.Get(created.Id));
Assert.ThrowsAsync<NotFoundException>(() => client.Authorization.Get(created.Id));
}
[ApplicationTest]
@@ -145,7 +145,7 @@ namespace Octokit.Tests.Integration.Clients
Assert.NotEqual(created.Token, applicationAuthorization.Token);
await client.Authorization.Delete(created.Id);
AssertEx.Throws<NotFoundException>(async () => await client.Authorization.Get(created.Id));
Assert.ThrowsAsync<NotFoundException>(() => client.Authorization.Get(created.Id));
}
[ApplicationTest]
@@ -167,8 +167,8 @@ namespace Octokit.Tests.Integration.Clients
var applicationClient = Helper.GetAuthenticatedApplicationClient();
await applicationClient.Authorization.RevokeApplicationAuthentication(Helper.ClientId, created.Token);
AssertEx.Throws<NotFoundException>(async () => await applicationClient.Authorization.CheckApplicationAuthentication(Helper.ClientId, created.Token));
AssertEx.Throws<NotFoundException>(async () => await client.Authorization.Get(created.Id));
Assert.ThrowsAsync<NotFoundException>(() => applicationClient.Authorization.CheckApplicationAuthentication(Helper.ClientId, created.Token));
Assert.ThrowsAsync<NotFoundException>(() => client.Authorization.Get(created.Id));
}
[ApplicationTest]
@@ -199,13 +199,13 @@ namespace Octokit.Tests.Integration.Clients
var applicationClient = Helper.GetAuthenticatedApplicationClient();
await applicationClient.Authorization.RevokeAllApplicationAuthentications(Helper.ClientId);
AssertEx.Throws<NotFoundException>(async () =>
Assert.ThrowsAsync<NotFoundException>(async () =>
await applicationClient.Authorization.CheckApplicationAuthentication(Helper.ClientId, token1.Token));
AssertEx.Throws<NotFoundException>(async () =>
Assert.ThrowsAsync<NotFoundException>(async () =>
await applicationClient.Authorization.CheckApplicationAuthentication(Helper.ClientId, token2.Token));
AssertEx.Throws<NotFoundException>(async () => await client.Authorization.Get(token1.Id));
AssertEx.Throws<NotFoundException>(async () => await client.Authorization.Get(token2.Id));
Assert.ThrowsAsync<NotFoundException>(() => client.Authorization.Get(token1.Id));
Assert.ThrowsAsync<NotFoundException>(() => client.Authorization.Get(token2.Id));
}
}
}

View File

@@ -243,8 +243,8 @@ public class IssuesClientTests : IDisposable
{
var owner = _repository.Owner.Login;
await AssertEx.Throws<ApiValidationException>(
async () => await _issuesClient.GetAllForRepository(owner, _repository.Name,
await Assert.ThrowsAsync<ApiValidationException>(
() => _issuesClient.GetAllForRepository(owner, _repository.Name,
new RepositoryIssueRequest { Assignee = "some-random-account" }));
}

View File

@@ -237,7 +237,7 @@ public class PullRequestsClientTests : IDisposable
var pullRequest = await _fixture.Create(Helper.UserName, _repository.Name, newPullRequest);
var merge = new MergePullRequest { Sha = fakeSha };
var ex = await AssertEx.Throws<ApiException>(async () => await _fixture.Merge(Helper.UserName, _repository.Name, pullRequest.Number, merge));
var ex = await Assert.ThrowsAsync<ApiException>(() => _fixture.Merge(Helper.UserName, _repository.Name, pullRequest.Number, merge));
Assert.True(ex.ApiError.Message.StartsWith("Head branch was modified"));
}

View File

@@ -41,7 +41,7 @@ public class ReferencesClientTests : IDisposable
[IntegrationTest]
public async Task WhenReferenceDoesNotExistAnExeptionIsThrown()
{
await AssertEx.Throws<NotFoundException>(
await Assert.ThrowsAsync<NotFoundException>(
() => _fixture.Get("octokit", "octokit.net", "heads/foofooblahblah"));
}
@@ -66,7 +66,7 @@ public class ReferencesClientTests : IDisposable
var repo = "octokit.net";
var subNamespace = "666";
var result = await AssertEx.Throws<NotFoundException>(
var result = await Assert.ThrowsAsync<NotFoundException>(
async () => { await _fixture.GetAllForSubNamespace(owner, repo, subNamespace); });
Assert.Equal(string.Format("{0} was not found.", ApiUrls.Reference(owner, repo, subNamespace)), result.Message);
}

View File

@@ -258,8 +258,8 @@ public class RepositoriesClientTests
{
var message = string.Format(CultureInfo.InvariantCulture, "There is already a repository named '{0}' for the current account.", repoName);
var thrown = await AssertEx.Throws<RepositoryExistsException>(
async () => await github.Repository.Create(repository));
var thrown = await Assert.ThrowsAsync<RepositoryExistsException>(
() => github.Repository.Create(repository));
Assert.NotNull(thrown);
Assert.Equal(repoName, thrown.RepositoryName);
@@ -358,8 +358,8 @@ public class RepositoriesClientTests
var repositoryUrl = string.Format(CultureInfo.InvariantCulture, "https://github.com/{0}/{1}", Helper.Organization, repository.Name);
var message = string.Format(CultureInfo.InvariantCulture, "There is already a repository named '{0}' in the organization '{1}'.", repository.Name, Helper.Organization);
var thrown = await AssertEx.Throws<RepositoryExistsException>(
async () => await github.Repository.Create(Helper.Organization, repository));
var thrown = await Assert.ThrowsAsync<RepositoryExistsException>(
() => github.Repository.Create(Helper.Organization, repository));
Assert.NotNull(thrown);
Assert.Equal(repoName, thrown.RepositoryName);

View File

@@ -17,8 +17,7 @@ public class TeamsClientTests
var github = Helper.GetAnonymousClient();
var newTeam = new NewTeam("Test");
var e = await AssertEx.Throws<AuthorizationException>(async
() => await github.Organization.Team.Create(Helper.Organization, newTeam));
var e = await Assert.ThrowsAsync<AuthorizationException>(() => github.Organization.Team.Create(Helper.Organization, newTeam));
Assert.Equal(HttpStatusCode.Unauthorized, e.StatusCode);
}
@@ -30,8 +29,7 @@ public class TeamsClientTests
var newTeam = new NewTeam("Test");
var e = await AssertEx.Throws<AuthorizationException>(async
() => await github.Organization.Team.Create(Helper.Organization, newTeam));
var e = await Assert.ThrowsAsync<AuthorizationException>(() => github.Organization.Team.Create(Helper.Organization, newTeam));
Assert.Equal(HttpStatusCode.Unauthorized, e.StatusCode);
}
@@ -64,8 +62,7 @@ public class TeamsClientTests
{
var github = Helper.GetAnonymousClient();
var e = await AssertEx.Throws<AuthorizationException>(async
() => await github.Organization.Team.IsMember(team.Id, Helper.UserName));
var e = await Assert.ThrowsAsync<AuthorizationException>(() => github.Organization.Team.IsMember(team.Id, Helper.UserName));
Assert.Equal(HttpStatusCode.Unauthorized, e.StatusCode);
}
@@ -75,8 +72,7 @@ public class TeamsClientTests
{
var github = Helper.GetBadCredentialsClient();
var e = await AssertEx.Throws<AuthorizationException>(async
() => await github.Organization.Team.IsMember(team.Id, Helper.UserName));
var e = await Assert.ThrowsAsync<AuthorizationException>(() => github.Organization.Team.IsMember(team.Id, Helper.UserName));
Assert.Equal(HttpStatusCode.Unauthorized, e.StatusCode);
}

View File

@@ -79,8 +79,7 @@ public class UsersClientTests
Bio = "UPDATED BIO"
};
var e = await AssertEx.Throws<AuthorizationException>(async
() => await github.User.Update(userUpdate));
var e = await Assert.ThrowsAsync<AuthorizationException>(() => github.User.Update(userUpdate));
Assert.Equal(HttpStatusCode.Unauthorized, e.StatusCode);
}
@@ -95,8 +94,7 @@ public class UsersClientTests
Bio = "UPDATED BIO"
};
var e = await AssertEx.Throws<AuthorizationException>(async
() => await github.User.Update(userUpdate));
var e = await Assert.ThrowsAsync<AuthorizationException>(() => github.User.Update(userUpdate));
Assert.Equal(HttpStatusCode.Unauthorized, e.StatusCode);
}
}