public void When_sealed_comparable_has_member_with_cycle() { var comparer = _builder.For <ComparableChildObject <OneSealed> >().GetEqualityComparer(); ComparableChildObject <OneSealed> .ChildComparer = _builder.GetComparer <OneSealed>(); var one = _fixture.Create <OneSealed>(); var other = _fixture.Create <OneSealed>(); one.Value = other.Value; one.Two.Three.One = one; other.Two.Three.One = _fixture.Create <OneSealed>(); other.Two.Three.One.Value = one.Value; other.Two.Three.One.Two.Three.One = other; var x = new ComparableChildObject <OneSealed> { ChildField = null, ChildProperty = other }; var y = new ComparableChildObject <OneSealed> { ChildField = null, ChildProperty = one }; using (new AssertionScope()) { comparer.Equals(x, y).Should().BeFalse(); comparer.GetHashCode(x).Should().NotBe(comparer.GetHashCode(y)); } }
public void Sefl_sealed_struct_should_be_equal() { var comparer = _builder.GetComparer <SelfStruct <Guid> >(); var x = new SelfStruct <Guid> { Key = Guid.NewGuid(), Value = Guid.NewGuid() }; comparer.Compare(x, x).Should().Be(0); }