expectedObjects
expectedObjects copied to clipboard
Wrong comparision if using LINQ in ignore statements
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).