The base comparer which contains all the type comparers
Inheritance: KellermanSoftware.CompareNetObjects.TypeComparers.BaseComparer
Exemplo n.º 1
0
        private static RootComparer BuildRootComparer()
        {
            _rootComparer = new RootComparer();

            _rootComparer.TypeComparers = new List <BaseTypeComparer>();

            _rootComparer.TypeComparers.Add(new RuntimeTypeComparer(_rootComparer));
#if !PORTABLE && !NEWPCL
            _rootComparer.TypeComparers.Add(new FontComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new IpEndPointComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DatasetComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DataTableComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DataRowComparer(_rootComparer));
#endif
            _rootComparer.TypeComparers.Add(new EnumerableComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new ByteArrayComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new ListComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new HashSetComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DictionaryComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new EnumComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new PointerComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new UriComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new StringComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DateComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DateTimeOffSetComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DoubleComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new SimpleTypeComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new ClassComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new TimespanComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new StructComparer(_rootComparer));
            return(_rootComparer);
        }
        private static RootComparer BuildRootComparer()
        {
            _rootComparer = new RootComparer();

            _rootComparer.TypeComparers = new List<BaseTypeComparer>();

            _rootComparer.TypeComparers.Add(new RuntimeTypeComparer(_rootComparer));
#if !PORTABLE && !NEWPCL
            _rootComparer.TypeComparers.Add(new FontComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new IpEndPointComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DatasetComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DataTableComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DataRowComparer(_rootComparer));
#endif
            _rootComparer.TypeComparers.Add(new EnumerableComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new ByteArrayComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new ListComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new HashSetComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DictionaryComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new EnumComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new PointerComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new UriComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new StringComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DateComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DateTimeOffSetComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DoubleComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new SimpleTypeComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new ClassComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new TimespanComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new StructComparer(_rootComparer));
            return _rootComparer;
        }
        /// <summary>
        /// Compare two objects of the same type to each other.
        /// </summary>
        /// <remarks>
        /// Check the Differences or DifferencesString Properties for the differences.
        /// Default MaxDifferences is 1 for performance
        /// </remarks>
        /// <param name="object1"></param>
        /// <param name="object2"></param>
        /// <returns>True if they are equal</returns>
        public ComparisonResult Compare(object object1, object object2)
        {
            ComparisonResult result = new ComparisonResult(Config);

            #if !PORTABLE
            result.Watch.Start();
            #endif

            RootComparer rootComparer = RootComparerFactory.GetRootComparer();

            CompareParms parms = new CompareParms
            {
                Config     = Config,
                Result     = result,
                Object1    = object1,
                Object2    = object2,
                BreadCrumb = string.Empty
            };

            rootComparer.Compare(parms);

            if (Config.AutoClearCache)
            {
                ClearCache();
            }

            #if !PORTABLE
            result.Watch.Stop();
            #endif

            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Compare two objects of the same type to each other.
        /// </summary>
        /// <remarks>
        /// Check the Differences or DifferencesString Properties for the differences.
        /// Default MaxDifferences is 1 for performance
        /// </remarks>
        /// <param name="expectedObject">The expected object value to compare</param>
        /// <param name="actualObject">The actual object value to compare</param>
        /// <returns>True if they are equal</returns>
        public ComparisonResult Compare(object expectedObject, object actualObject)
        {
            ComparisonResult result = new ComparisonResult(Config);

            result.Watch.Start();

            Config.PopulateHashSets();

            RootComparer rootComparer = RootComparerFactory.GetRootComparer();

            CompareParms parms = new CompareParms
            {
                Config     = Config,
                Result     = result,
                Object1    = expectedObject,
                Object2    = actualObject,
                BreadCrumb = string.Empty
            };

            rootComparer.Compare(parms);

            if (Config.AutoClearCache)
            {
                ClearCache();
            }

            result.Watch.Stop();

            return(result);
        }
        /// <summary>
        /// Get the current root comparer
        /// </summary>
        /// <returns></returns>
        public static RootComparer GetRootComparer()
        {
            lock(_locker)
                if (_rootComparer == null)
                    _rootComparer= BuildRootComparer();

            return _rootComparer;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Get the current root comparer
        /// </summary>
        /// <returns></returns>
        public static RootComparer GetRootComparer()
        {
            lock (_locker)
                if (_rootComparer == null)
                {
                    _rootComparer = BuildRootComparer();
                }

            return(_rootComparer);
        }
Exemplo n.º 7
0
        private static RootComparer BuildRootComparer()
        {
            _rootComparer = new RootComparer();

            _rootComparer.TypeComparers = new List <BaseTypeComparer>();

            _rootComparer.TypeComparers.Add(new StringComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DateComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DecimalComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DoubleComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new PointerComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new SimpleTypeComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new ListComparer(_rootComparer));

#if NETFULL || NETSTANDARD2_0 || NETSTANDARD2_1
            _rootComparer.TypeComparers.Add(new IpEndPointComparer(_rootComparer));
#endif

            _rootComparer.TypeComparers.Add(new RuntimeTypeComparer(_rootComparer));

#if !NETSTANDARD
            _rootComparer.TypeComparers.Add(new FontComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DatasetComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DataTableComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DataRowComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DataColumnComparer(_rootComparer));
#endif
            _rootComparer.TypeComparers.Add(new EnumerableComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new ByteArrayComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DictionaryComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new HashSetComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new CollectionComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new UriComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new StringBuilderComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new ClassComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new DateTimeOffSetComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new TimespanComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new StructComparer(_rootComparer));
            _rootComparer.TypeComparers.Add(new ImmutableArrayComparer(_rootComparer));

            return(_rootComparer);
        }
Exemplo n.º 8
0
 public NDbUnitDataRowCollectionComparer(RootComparer rootComparer)
     : base(rootComparer)
 {
 }
Exemplo n.º 9
0
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public NDbUnitDataTableComparer(RootComparer rootComparer)
     : base(rootComparer)
 {
 }
Exemplo n.º 10
0
 /// <summary>
 /// Constructor that takes a root comparer
 /// </summary>
 /// <param name="rootComparer"></param>
 public NDbUnitDataSetComparer(RootComparer rootComparer)
     : base(rootComparer)
 {
 }
 public DomainObjectComparer(RootComparer rootComparer)
     : base(rootComparer)
 {
 }
 public MyCustomComparer(RootComparer rootComparer) : base(rootComparer)
 {
 }