Skip to content

Throws() bug for a NotImplemented Func<Task> #42

Open
@chris-findlay

Description

@chris-findlay

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions