Skip to content

Instantly share code, notes, and snippets.

@simoneb
Created January 20, 2013 11:50
Show Gist options
  • Save simoneb/4578097 to your computer and use it in GitHub Desktop.
Save simoneb/4578097 to your computer and use it in GitHub Desktop.
Async lambda support in NUnit framework
[Test]
public async Task AsyncLambaSupport()
{
// throwing asynchronously
Assert.That(async () => await ThrowAsync(), Throws.TypeOf<InvalidOperationException>());
// returning values asynchronously
Assert.That(async () => await ReturnOneAsync(), Is.EqualTo(1));
// "After" works with async methods too
Assert.That(async () => await ResutnOneAsync(), Is.EqualTo(1).After(100));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment