{"action":"opened","issue":{"url":"https://api.github.com/repos/nunit/nunit/issues/464","labels_url":"https://api.github.com/repos/nunit/nunit/issues/464/labels{/name}","comments_url":"https://api.github.com/repos/nunit/nunit/issues/464/comments","events_url":"https://api.github.com/repos/nunit/nunit/issues/464/events","html_url":"https://github.com/nunit/nunit/issues/464","id":54685362,"number":464,"title":"Async delegate assertions","user":{"login":"StephenCleary","id":900597,"avatar_url":"https://avatars.githubusercontent.com/u/900597?v=3","gravatar_id":"","url":"https://api.github.com/users/StephenCleary","html_url":"https://github.com/StephenCleary","followers_url":"https://api.github.com/users/StephenCleary/followers","following_url":"https://api.github.com/users/StephenCleary/following{/other_user}","gists_url":"https://api.github.com/users/StephenCleary/gists{/gist_id}","starred_url":"https://api.github.com/users/StephenCleary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StephenCleary/subscriptions","organizations_url":"https://api.github.com/users/StephenCleary/orgs","repos_url":"https://api.github.com/users/StephenCleary/repos","events_url":"https://api.github.com/users/StephenCleary/events{/privacy}","received_events_url":"https://api.github.com/users/StephenCleary/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-18T04:00:41Z","updated_at":"2015-01-18T04:00:41Z","closed_at":null,"body":"All assertions that take TestDelegate should have correlating methods that take an asynchronous equivalent (Task AsyncTestDelegate()). E.g., Assert.Throws(TestDelegate) should have a matching Assert.ThrowsAsync(AsyncTestDelegate) or Assert.Throws(AsyncTestDelegate). This would enable this kind of usage:\r\n\r\n    await Assert.ThrowsAsync<Exception>(async () =>\r\n    {\r\n      await Task.Yield();\r\n      throw new Exception();\r\n    });\r\n\r\nAlso, some synchronous assertion code has outdated code; e.g., Assert.Throws will try to create an AsyncInvocationRegion that will never succeed, since AIR (correctly) rejects async void methods and TestDelegate returns void. Ideally, AIR should only be used when executing the [Test] methods themselves, not within any other code."}}