Created
January 24, 2013 00:03
-
-
Save haacked/4616032 to your computer and use it in GitHub Desktop.
Example usage of an async lambda.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Assert.Throws<SomeException>(async () => await obj.GetAsync()); |
Somewhat related, I started hacking on a library to make testing Tasks better... https://github.com/pprovost/assertex
Goddamn it, its not on NuGet. I'll go stand in the corner until I've fixed that...
How's this? https://gist.github.com/4616366
Just pushed AssertEx up to NuGet. Here's a teaser:
If you want to inspect the Task:
public class Subject
{
public Task GetAsync()
{
return Task.Run(() => { throw new SomeException(); });
}
}
...
AssertEx.TaskThrows<SomeException>(obj.GetAsync);
I need to write up a decent wiki on how to test async code - all the horrors are coming back to me now...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks nigel! I saw the same thing here: http://blogs.msdn.com/b/pfxteam/archive/2012/02/08/10265476.aspx