What is the best way to compare two similar objects?
Given FlintlockDTOand Flintlock:
public class FlintlockDTO
{
public string GName { get; set; }
public string SharedPropertyName { get; set; }
...
}
and
public class Flintlock
{
public Flintlock(FlintlockDTO inflator)
{
this.GoodName = inflator.GName;
this.SharedPropertyName = inflator.SharedPropertyName;
...
}
public string GoodName { get; private set; }
public string SharedPropertyName { get; private set; }
...
}
If both classes have common properties of N (for example, SharedPropertyName), but differ in properties of M, which are equivalent, but are called differently (for example, GoodName\ GName.)
Tools like fluentassert almost do this, if the property names match, to my understanding this will work:
flintlockDto.ShouldBeEquivalentTo(flintlock);
Is there a way to do this neatly in fluentassert or any other tool?
Perfectly,
flintlockDto.IsTheSameAs(flintlock).WhenMapping("GName","GoodName");
source
share