public void Replaced_member_does_not_break_comparison() { var one = new AbstractMembers { NotSealedProperty = _fixture.Create <BaseNestedObject>() }; _comparer.Equals(one, one.DeepClone()).Should().BeTrue(); for (var i = 0; i < 100; i++) { one.NotSealedProperty = _fixture.Create <AnotherNestedObject>(); var other = new AbstractMembers { NotSealedProperty = _fixture.Create <AnotherNestedObject>() }; var expectedHashX = one.GetHashCode(); var expectedHashY = other.GetHashCode(); var expectedEquals = one.Equals(other); var hashX = _comparer.GetHashCode(one); var hashY = _comparer.GetHashCode(other); var equals = _comparer.Equals(one, other); using (new AssertionScope()) { equals.Should().Be(expectedEquals); hashX.Should().Be(expectedHashX); hashY.Should().Be(expectedHashY); } } }
public void Replaced_member_does_not_break_comparison() { var one = new AbstractMembers { NotSealedProperty = _fixture.Create <BaseNestedObject>() }; _comparer.Compare(one, one.DeepClone()).Should().Be(0); for (var i = 0; i < 100; i++) { one.NotSealedProperty = _fixture.Create <AnotherNestedObject>(); var other = new AbstractMembers { NotSealedProperty = _fixture.Create <AnotherNestedObject>() }; var expected = AbstractMembers.Comparer.Compare(one, other).Normalize(); var actual = _comparer.Compare(one, other).Normalize(); actual.Should().Be(expected); } }