public void EqualsForwardsCorrectCallToComparer(
     object a,
     object b,
     bool expected)
 {
     // Fixture setup
     var comparerStub = new DelegatingEqualityComparer
     {
         OnEquals = (x, y) => x.Equals(y)
     };
     var sut = new MemberComparer(comparerStub);
     // Exercise system
     var result = sut.Equals(a, b);
     // Verify outcome
     Assert.Equal(expected, result);
     // Teardown
 }
        public void EqualsForwardsCorrectCallToComparer(
            object a,
            object b,
            bool expected)
        {
            // Fixture setup
            var comparerStub = new DelegatingEqualityComparer
            {
                OnEquals = (x, y) => x.Equals(y)
            };
            var sut = new MemberComparer(comparerStub);
            // Exercise system
            var result = sut.Equals(a, b);

            // Verify outcome
            Assert.Equal(expected, result);
            // Teardown
        }
Esempio n. 3
0
 public bool Equals(VirtualSite <TNode, TMember> other)
 {
     return(other != null &&
            TargetComparer.Equals(target, other.target) &&
            MemberComparer.Equals(member, other.member));
 }
Esempio n. 4
0
        protected override bool EqualsStructural(Type x, Type y)
        {
            if (_structuralMap.TryGetValue(x, out var mappedY))
            {
                return(y == mappedY);
            }
            else
            {
                _structuralMap.Add(x, y);
            }

            try
            {
                var xDataType = (StructuralDataType)DataType.FromType(x, allowCycles: true);
                var yDataType = (StructuralDataType)DataType.FromType(y, allowCycles: true);

                if (xDataType.Properties.Count != yDataType.Properties.Count)
                {
                    return(false);
                }

                var xProperties = new Dictionary <string, DataProperty>(xDataType.Properties.Count);
                for (var i = 0; i < xDataType.Properties.Count; ++i)
                {
                    var property = xDataType.Properties[i];
                    xProperties[property.Name] = property;
                }

                for (var i = 0; i < yDataType.Properties.Count; ++i)
                {
                    var yProperty = yDataType.Properties[i];
                    if (!xProperties.TryGetValue(yProperty.Name, out var xProperty) || !MemberComparer.Equals(xProperty.Property, yProperty.Property))
                    {
                        return(false);
                    }
                }

                return(true);
            }
            finally
            {
                _structuralMap.Remove(x);
            }
        }
Esempio n. 5
0
                protected override bool EqualsStructural(Type x, Type y)
                {
                    if (_recursionMap.TryGetValue(x, out var recursedY))
                    {
                        return(y == recursedY);
                    }
                    else
                    {
                        _recursionMap.Add(x, y);
                    }

                    try
                    {
                        var dataTypeX = (StructuralDataType)DataType.FromType(x, allowCycles: true);
                        var dataTypeY = (StructuralDataType)DataType.FromType(y, allowCycles: true);

                        if (EqualsByKey(dataTypeX.Properties, dataTypeY.Properties, p => p.Name, (p1, p2) => MemberComparer.Equals(p1.Property, p2.Property)))
                        {
                            return(true);
                        }

                        return(base.EqualsStructural(x, y));
                    }
                    finally
                    {
                        _recursionMap.Remove(x);
                    }
                }