I am creating two objects of the same type in an integration test, but trying to exclude autoincremented members generated on object creation.
I successfully exclude the RecordId and Number property, but the equivalence test fails on the Id property. The RecordId and number properties are inherited from an abstract class, but the Id is different in that it is an abstract property inherited from an abstract class which is then overridden.
The Id property is an abstract string property and readonly.
//CreateJob creates indentical jobs, but with autoincremented id, number and recordid
Job job1 = CreateJob();
Job job2 = CreateJob();
job1.Should().BeEquivalentTo(job2, config => config
.Excluding(o => o.RecordId)
.Excluding(o => o.Id)
.Excluding(o => o.Number)
);
Message: Expected member Id to be "45", but "46" differs near "6" (index 1).
With configuration: - Use declared types and members
- Compare enums by value
- Exclude member root.RecordId
- Exclude member root.Id
- Exclude member root.Number
- Match member by name (or throw)
- Without automatic conversion.
- Be strict about the order of items in byte arrays
I also tried running with the WithTracing() option, but it provided no information about the property in question.
I have read the documentation and not found anything that indicates that excluding abstract or virtual properties shouldn't be possible, am I wrong?
I have tried this on version 5.5.0 and 5.5.3, with identical results.
EDIT:
I have checked and double checked that neither the class or the classes it inherits override equals.