Skip to content

[Bug]: xUnit code fixer drops lambda from Assert.Single #4805

@ascott18

Description

@ascott18

Description

The lambda from the xUnit method Assert.Single<T>(IEnumerable<T> collection, Predicate<T> predicate) is dropped by the xUnit code fixer.

Expected Behavior

Assert.Single(properties, p => p.Prop == "myKey"); should become await Assert.That(properties.Where(p => p.Prop == "myKey")).HasSingleItem();.

Or, even better, an equivalent HasSingleItem overload that accepts a filter lambda is added to TUnit, allowing await Assert.That(properties).HasSingleItem(p => p.Prop == "myKey");.

Actual Behavior

Lambda was dropped entirely, leaving only await Assert.That(properties).HasSingleItem();

Steps to Reproduce

Apply xUnit code fixers against an xUnit assertion like Assert.Single(properties, p => p.Prop == "myKey");

TUnit Version

1.14.0

.NET Version

NET 10

Operating System

Windows

IDE / Test Runner

dotnet CLI (dotnet test / dotnet run)

Error Output / Stack Trace

Additional Context

No response

IDE-Specific Issue?

  • I've confirmed this issue occurs when running via dotnet test or dotnet run, not just in my IDE

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions