Class that allows comparison of two objects of the same type to each other. Supports classes, lists, arrays, dictionaries, child comparison and more.
Example #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);
        }
Example #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");
        }