From e60acbf3170057ba49c3fe2f37018b3b7a5c6d7a Mon Sep 17 00:00:00 2001 From: Tim Clem Date: Fri, 27 Apr 2012 22:12:27 -0700 Subject: [PATCH] Assert.Throw doesn't seem to work with async --- Burr.Tests/GitHubClientTests.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Burr.Tests/GitHubClientTests.cs b/Burr.Tests/GitHubClientTests.cs index 00f560e8..62d2f3b5 100644 --- a/Burr.Tests/GitHubClientTests.cs +++ b/Burr.Tests/GitHubClientTests.cs @@ -76,7 +76,7 @@ namespace Burr.Tests public class TheUserMethod { Func>> fakeUserResponse = - new Func>>(() => new Task>(() => new Response { BodyAsObject = new User() })); + new Func>>(() => Task.FromResult>(new Response { BodyAsObject = new User() })); [Fact] public async Task GetsAuthenticatedUserWithBasic() @@ -118,10 +118,15 @@ namespace Burr.Tests [Fact] public async Task ThrowsIfNotAuthenticated() { - Assert.Throws(async () => + try { var user = await new GitHubClient().GetUserAsync(); - }); + + Assert.True(false, "AuthenticationException was not thrown"); + } + catch (AuthenticationException ex) + { + } } } }