public void When_sealed_comparable_has_member_with_cycle() { var comparer = _builder.For <ComparableChildObject <OneSealed> >().GetComparer(); ComparableChildObject <OneSealed> .ChildComparer = ComparerForOneSealed; 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 }; var expected = ComparerForOneSealed.Compare(other, one); var actual = comparer.Compare(x, y); using (new AssertionScope()) { actual.Should().Be(expected); actual.Should().BePositive(); } }
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 Create_generic_comparer() { var comparer = _builder.For <DummyObject>().GetComparer(); comparer.Should().NotBeNull(); }