Skip to content

Assertion that asynchronous operation completes within time spanΒ #1001

@lg2de

Description

@lg2de

Testing asynchronous operations is currently available like this:

this.myServer.Invoking(s => s.OpenAsync).Should().NotThrow();

I'm missing the option just check, that the operation will complete (and not throw) within specific time range. Therefore a new assertion could be created:

this.myServer.Invoking(s => s.OpenAsync).Should().Complete(TimeSpan.FromMilliseconds(100));

Such an idea I already mentioned in #990.

While thinking about the implementation I found a different approach.
Why to I need the indirection using "Invoking"? Why not asserting the Task directly:

this.myServer.OpenAsync().Should().Complete(TimeSpan.FromMilliseconds(100));

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions