Compare() public method

Compare two objects of the same type to each other.
Check the Differences or DifferencesString Properties for the differences. Default MaxDifferences is 1 for performance
public Compare ( object object1, object object2 ) : bool
object1 object
object2 object
return bool
示例#1
0
        public void Can_restore_from_snapshot()
        {
            var client = CreateGenericClient();

            var originalSnapshot = (client as IEntity).GetSnapshot();
            var restored = EntityFactory.Build<Client>(originalSnapshot);
            var restoredSnapshot = (restored as IEntity).GetSnapshot();

            var comparer = new CompareObjects();
            comparer.Compare(originalSnapshot, restoredSnapshot).ShouldBe(true);
        }
示例#2
0
        public static string FindDifferences(object expected, object actual)
        {
            var compare = new CompareObjects
            {
                MaxDifferences = 10
            };

            if (compare.Compare(expected, actual))
                return null;

            return compare.DifferencesString
                .Trim('\r', '\n')
                .Replace("object1", "expected")
                .Replace("object2", "actual");
        }