private void Compare(object obj1, object obj2, string[] propertiesToIgnore, Func<string, string, bool> hasProblem, string problemDescription)
        {
            propertiesToIgnore = propertiesToIgnore ?? new string[] { };
            var propertiesIgnored = new List<string>();

            var problemCount = 0;

            var serializer = new ObjectSerializer();

            var obj1Content = serializer.SerializeForComparison(obj1);
            var obj2Content = serializer.SerializeForComparison(obj2);

            var linesToCompare = obj1Content.Count();
            if (linesToCompare > obj2Content.Count())
            {
                linesToCompare = obj2Content.Count();
                Debug.WriteLine("PROBLEM: Total lines different. Object 1: {0}, Object 2: {1}", obj1Content.Count(), obj2Content.Count());
                problemCount++;
            }

            for (int i = 0; i < linesToCompare; i++)
            {
                if (hasProblem(obj1Content[i], obj2Content[i]))
                {
                    var matches = propertiesToIgnore.Where(x => obj1Content[i].Contains(x)).ToList();
                    if (matches.Any())
                        propertiesIgnored.AddRange(matches);
                    else
                    {
                        Debug.WriteLine("PROBLEM: " + problemDescription + " property detected: " + obj1Content[i]);
                        problemCount++;
                    }
                }
            }

            if (problemCount > 0)
            {
                Debug.WriteLine("\nObject 1: ");
                obj1Content.ForEach(x => Debug.WriteLine(x));
                Debug.WriteLine("\nObject 2: ");
                obj2Content.ForEach(x => Debug.WriteLine(x));

                throw new AssertDifferenceException(problemCount + " issue(s) found. See output.");
            }

            var propertiesToIgnoreUnused = propertiesToIgnore.Where(x => !propertiesIgnored.Contains(x)).ToList();
            if (propertiesToIgnoreUnused.Any())
            {
                Debug.WriteLine("PropertiesToIgnore contains unused items.");
                propertiesToIgnoreUnused.ForEach(x => Debug.WriteLine(x));
                throw new AssertDifferenceException("PropertiesToIgnore contains unused items. See output.");
            }
        }
        public void SerializeForComparison_test()
        {
            var obj = new TestClass() { Value1 = "1", Value2 = "2", Composite = new TestClass { Value1 = "111" } };
            obj.Dict.Add("key", "value");

            var comparer = new ObjectSerializer();
            var objStrings = comparer.SerializeForComparison(obj);

            Assert.That(objStrings.Contains("/Value1 - 1"), Is.True);
            Assert.That(objStrings.Contains("/Value2 - 2"), Is.True);
            Assert.That(objStrings.Contains("/Composite/Value1 - 111"), Is.True);
        }