Skip to content

Wrong comparision if using LINQ in ignore statements #42

@Zyertdox

Description

@Zyertdox

The following test should fail (different Ids), but it passes. The reason is in attempt to ignore field inside collection using LINQ.

public void Test()
{
    var guid = Guid.NewGuid();
    var expected = (Id: guid, Arr: new List<(Guid, DateTime)> { (Guid.Empty, DateTime.UtcNow) });
    var actual = (Id: Guid.Empty, Arr: new List<(Guid, DateTime)> { (Guid.Empty, DateTime.UtcNow) });

    var expectedObject = expected.ToExpectedObject(context =>
    {
        context.UseOrdinalComparison();

        context.Ignore(tuple => tuple.Arr.Select(a => a.Item2));
        //context.Ignore(tuple => tuple.Arr.First().Item2);
        //context.Ignore(tuple => tuple.Arr.Single().Item2);
    });

    expectedObject.ShouldMatch(actual);
}

It do not fail also for First() and Single() calls (commented).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions