DeepEqual
DeepEqual copied to clipboard
Default comparison of enums
It seems that by default instances of different enum types are never evaluated as deep-equal, even if their names match.
I have to apply SkipDefault<EnumType1>().SkipDefault<EnumType2>() or WithCustomComparison(new EnumComparison()) to get a working comparison.
Is this the intended behavior?
public enum Foo { X = 1, Y = 2 }
public enum Bar { X = 1, Y = 2 }
[Test]
public void Enums_WithSameName_ShouldDeepEqual()
{
// throws with Actual != Expected (X != X)
(Foo.X).ShouldDeepEqual(Bar.X);
}
[Test]
public void Enums_WithSameName_WithDeepEqualAndSkipTypes_ShouldAssert()
{
// works (and successfully throws when comparing Foo.X with Bar.Y)
(Foo.X).WithDeepEqual(Bar.X).SkipDefault<Foo>().SkipDefault<Bar>().Assert();
}
[Test]
public void Enums_WithSameName_WithCustomComparison_ShouldAssert()
{
// works (and successfully throws when comparing Foo.X with Bar.Y)
(Foo.X).WithDeepEqual(Bar.X).WithCustomComparison(new EnumComparison()).Assert();
}