So habe ich einen Test wie folgt aus:xunit Assert.ThrowsAsync() funktioniert nicht richtig?
[Fact]
public void Test1()
{
Assert.ThrowsAsync<ArgumentNullException>(() => MethodThatThrows());
}
private async Task MethodThatThrows()
{
await Task.Delay(100);
throw new NotImplementedException();
}
Zu meiner Überraschung Test1 erfolgreich passiert. Um es scheitern muss ich so schreiben:
Assert.Throws<ArgumentNullException>(() => MethodThatThrows().Wait());
Was ist der Zweck der ThrowsAsync(), wenn es nicht funktioniert, in dem obigen Szenario?