Skip to content

[Bug]: [TUnit.Assertions.Should] Should().HaveSingleItem() returns int[] instead of int #6318

Description

@kzrnm

Description

// OK
await (await Assert.That(new int[1] { 1 }).HasSingleItem()).Should().BeOfType(typeof(int));

// NG
await (await new int[1] { 1 }.Should().HaveSingleItem()).Should().BeOfType(typeof(int));

Expected Behavior

new int[1] { 1 }.Should().HaveSingleItem() returns int.

Actual Behavior

new int[1] { 1 }.Should().HaveSingleItem() returns IEnumerable.

Steps to Reproduce

// OK
await (await Assert.That(new int[1] { 1 }).HasSingleItem()).Should().BeOfType(typeof(int));

// NG
await (await new int[1] { 1 }.Should().HaveSingleItem()).Should().BeOfType(typeof(int));

TUnit Version

1.56.35

.NET Version

.NET 9

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