Skip to content

Feature request: Assert.Multiple() could return an IDisposable, avoiding passing an Action around. #4587

@andrewimcclement

Description

@andrewimcclement

Would it be possible to be able to write code like:

// Act
var result = GetResult();

// Assert
using (Assert.Multiple())
{
    Assert.That(result.A, Is.EqualTo("A"));
    Assert.That(result.B, Is.EqualTo("B"));
}

This would hopefully avoid capturing unnecessary context into the Action (because it wouldn't exist). Async code becomes slightly simpler (no need to specify async again) also.

It might also make things like #4242 easier to get right.

Considerations:

  • As written, this would not conflict, but we would certainly want to drive users towards this as a preferred option over the existing Assert.Multiple(() => { ... }); option. So we could consider using a different name to avoid ambiguity.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions