Ejemplo n.º 1
0
        public void Self_sealed_struct_should_handle_cycle()
        {
            var comparer = _builder.GetEqualityComparer <SelfStruct <Guid> >();
            var x        = new SelfStruct <Guid> {
                Key   = Guid.NewGuid(),
                Value = Guid.NewGuid()
            };

            using (new AssertionScope()) {
                comparer.Equals(x, x).Should().BeTrue();
                comparer.GetHashCode(x).Should().Be(HashCodeCombiner.Combine <object>(x.Key, 1, x.Value));
            }
        }
        public HierarchyTests()
        {
            _builder = new ComparerBuilder()
                       .For <NestedStruct>(
                config => config.DefineMembersOrder(
                    order => order.Member(o => o.Property)
                    .Member(o => o.NullableProperty)))
                       .For <HierarchicalObject>(
                config => config.DefineMembersOrder(
                    order => order.Member(o => o.ComparableField)
                    .Member(o => o.Value)
                    .Member(o => o.FirstProperty)
                    .Member(o => o.SecondProperty)
                    .Member(o => o.NestedField)
                    .Member(o => o.NestedStructField)
                    .Member(o => o.NestedNullableStructField)
                    .Member(o => o.NestedStructProperty)
                    .Member(o => o.NestedNullableStructProperty)))
                       .Builder;

            _comparer = _builder.GetEqualityComparer <HierarchicalObject>();
        }