You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PAssert.Throws<TException>(Action a, ...) has the expected try/catch structure, but PAssert.Throws<TException>(Func<Task> a, ...) does not - the latter handles the case of the task faulting, but does not work if the code returning the task fails in any synchronous way, e.g:
public Task DoSomethingAsync() { throw new NotImplementedException(); }
---
[Test]
public void TestIt() {
PAssert.Throws<NotImplementedException>(() => obj.DoSomethingAsync());
}
This results in the NIE bubbling up out of the Throws call, as it doesn't check that the setup works, only that the resulting task does (or rather doesn't - i.e. that the Task faults).
The text was updated successfully, but these errors were encountered:
I tried wrapping the content of Throws<>(Func<Task>...) in a try catch like the other one, but the catch needs to return a Task<TException> and not just TException, so I used Task.FromResult(), but get a compile error that says error CS0117: 'Task' does not contain a definition for 'FromResult'
which I completely don't understand, given what's in scope at the time...
PAssert.Throws<TException>(Action a, ...)
has the expected try/catch structure, butPAssert.Throws<TException>(Func<Task> a, ...)
does not - the latter handles the case of the task faulting, but does not work if the code returning the task fails in any synchronous way, e.g:This results in the NIE bubbling up out of the Throws call, as it doesn't check that the setup works, only that the resulting task does (or rather doesn't - i.e. that the Task faults).
The text was updated successfully, but these errors were encountered: