我正在尝试将测试移植到 NUnit3 并收到 System.ArgumentException:不支持“async void”方法,请改用“async Task”。
[Test]
public void InvalidUsername()
{
...
var exception = Assert.Throws<HttpResponseException>(async () => await client.LoginAsync("notarealuser@example.com", testpassword));
exception.HttpResponseMessage.StatusCode.ShouldEqual(HttpStatusCode.BadRequest); // according to http://tools.ietf.org/html/rfc6749#section-5.2
...
}
Assert.Throws 似乎采用了一个 TestDelegate,定义为:
public delegate void TestDelegate();
因此 ArgumentException。移植此代码的最佳方法是什么?