Skip to content

Add async-support for WithMessage() #1052

@mu88

Description

@mu88

Description

It would be great to use WithMessage() on ThrowAsync<>().

Complete minimal example reproducing the issue

// Arrange
Func<Task> act = () => throw new InvalidOperationException("Hello World");

// Act & Assert
await act().Should().ThrowAsync<InvalidOperationException>().WithMessage("HelloWorld");

Actual behavior:

Compile-time error. If have to await/block the Task to use WithMessage() (e. g. await act().Should().ThrowAsync<InvalidOperationException>().Result.WithMessage("HelloWorld");).

Versions

5.6.0

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