Assert.Throw doesn't seem to work with async

This commit is contained in:
Tim Clem
2012-04-27 22:12:27 -07:00
parent cd1068f474
commit e60acbf317
+8 -3
View File
@@ -76,7 +76,7 @@ namespace Burr.Tests
public class TheUserMethod
{
Func<Task<IResponse<User>>> fakeUserResponse =
new Func<Task<IResponse<User>>>(() => new Task<IResponse<User>>(() => new Response<User> { BodyAsObject = new User() }));
new Func<Task<IResponse<User>>>(() => Task.FromResult<IResponse<User>>(new Response<User> { BodyAsObject = new User() }));
[Fact]
public async Task GetsAuthenticatedUserWithBasic()
@@ -118,10 +118,15 @@ namespace Burr.Tests
[Fact]
public async Task ThrowsIfNotAuthenticated()
{
Assert.Throws<AuthenticationException>(async () =>
try
{
var user = await new GitHubClient().GetUserAsync();
});
Assert.True(false, "AuthenticationException was not thrown");
}
catch (AuthenticationException ex)
{
}
}
}
}