Example #1
0
        public bool CanCompare(Type type1, Type type2)
        {
            if (!ReflectionCache.IsListType(type1) || !ReflectionCache.IsListType(type2))
            {
                return(false);
            }

            return(checkInnerCanCompare());

            bool checkInnerCanCompare()
            {
                var innerType1 = ReflectionCache.GetEnumerationType(type1);
                var innerType2 = ReflectionCache.GetEnumerationType(type2);

                return(Inner.CanCompare(innerType1, innerType2));
            }
        }
Example #2
0
        public ComparisonResult Compare(IComparisonContext context, object value1, object value2)
        {
            var type1 = value1.GetType();

            if (IsSkipped(type1))
            {
                return(ComparisonResult.Inconclusive);
            }

            if (value1.Equals(value2))
            {
                return(ComparisonResult.Pass);
            }

            if (ReflectionCache.IsValueType(type1))
            {
                context.AddDifference(value1, value2);
                return(ComparisonResult.Fail);
            }

            return(ComparisonResult.Inconclusive);
        }
Example #3
0
        public (ComparisonResult result, IComparisonContext context) Compare(IComparisonContext context, object value1, object value2)
        {
            var type1 = value1.GetType();
            var type2 = value2.GetType();

            if (IsSkipped(type1) || IsSkipped(type2))
            {
                return(ComparisonResult.Inconclusive, context);
            }

            if (type1 != type2)
            {
                if (CoerceValues(ref value1, ref value2))
                {
                    type1 = value1.GetType();
                    type2 = value2.GetType();

                    if (type1 != type2)
                    {
                        return(ComparisonResult.Inconclusive, context);
                    }
                }
            }

            if (value1.Equals(value2))
            {
                return(ComparisonResult.Pass, context);
            }

            if (ReflectionCache.IsValueType(type1))
            {
                return(ComparisonResult.Fail, context.AddDifference(value1, value2));
            }

            return(ComparisonResult.Inconclusive, context);
        }
Example #4
0
 public bool CanCompare(Type type1, Type type2)
 {
     return(ReflectionCache.IsDictionaryType(type1) && ReflectionCache.IsDictionaryType(type2));
 }
 public ComparisonBuilder ExposeInternalsOf(params Type[] types)
 {
     ReflectionCache.CachePrivatePropertiesOfTypes(types);
     return(this);
 }