Skip to content

CallerIdentification can't seem to handle new[]{} #1695

@mdentremont

Description

@mdentremont

I noticed that the subject in our assertion output often had "root[..]", which seemed odd so whipped up a quick test case to validate my concerns. The following test fails (output is included), but using new List<int> { 1, 2, 3} instead of new[] works just fine.

I was on master SHA: b5b5ceb

[Fact]
public void When_the_caller_is_bob()
{
    // Arrange
    var foo = new Foo();

    // Act
    Action act = () => foo.GetFoo(new[] { 1, 2, 3 }.Sum() + "")
        .Should()
        .BeNull();

    // Assert
    act.Should().Throw<XunitException>()
        .WithMessage("Expected foo.GetFoo(new[]{1,2,3}.Sum()+\"\") to be <null>*");
}

Output:

Expected exception message to match the equivalent of "Expected foo.GetFoo(new[]{1,2,3}.Sum()+"") to be <null>*", but "Expected object to be <null>, but found FluentAssertions.Specs.Execution.Foo
{
    Bar = "bar", 
    Field = "bar"
}." does not.

I can probably work on this in the future, but it might be a little as things are busy at the moment 👍.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions