Factory to create a root comparer
        /// <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.º 2
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);
        }