//[Fact] TODO: Update test.
        public void CustomFactoryMismatch()
        {
            TypeWithAttributedProperty leftObject = new TypeWithAttributedProperty()
            {
                PropertyWithoutTestAttribute = "Should not be compared",
                PropertyWithTestAttribute = "Should be compared",
            };

            TypeWithAttributedProperty rightObject = new TypeWithAttributedProperty()
            {
                PropertyWithoutTestAttribute = "Should not be compared - so this is different",
                PropertyWithTestAttribute = "Should be compared - and should fail because its different",
            };

            ExtractAttributeObjectGraphFactory factory = new ExtractAttributeObjectGraphFactory();
            ObjectComparer comparer = new ObjectComparer(factory);

            Assert.False(comparer.Compare(leftObject, rightObject).None(), "Custom compare passed when it should have failed");
        }
        public void CompareBasicTypesMaxValues()
        {
            BasicTypes leftObject = new BasicTypes()
            {
                BoolPrimitive = true,
                BytePrimitive = byte.MaxValue,
                CharValue = char.MaxValue,
                DoublePrimitive = double.MaxValue,
                FloatPrimitive = float.MaxValue,
                IntPrimitive = int.MaxValue,
                LongPrimitive = long.MaxValue,
                ShortPrimitive = short.MaxValue,
                StringPrimitive = string.Empty,
                TimeSpanValue = TimeSpan.MaxValue,
            };

            BasicTypes rightObject = leftObject.Clone();

            ObjectGraphFactory factory = new PublicPropertyObjectGraphFactory();
            ObjectComparer comparer = new ObjectComparer(factory);
            bool match = comparer.Compare(leftObject, rightObject).None();

            Assert.True(match, "Basic types did not match");
        }
        public void TestSimpleClassHierarchy()
        {
            var leftObject = new Element()
            {
                Name = "root",
                Content = new Element()
                {
                    Name = "element1",
                    Content = new Element()
                        {
                            Name = "element2",
                        }
                }
            };

            var rightObject = new Element()
            {
                Name = "root",
                Content = new Element()
                {
                    Name = "element1",
                    Content = new Element()
                    {
                        Name = "element2",
                    }
                }
            };

            ObjectGraphFactory factory = new PublicPropertyObjectGraphFactory();
            ObjectComparer comparer = new ObjectComparer(factory);
            bool match = comparer.Compare(leftObject, rightObject).None();

            Assert.True(match, "objects did not match");
        }
        public void ComparePropertyThrows()
        {
            Element leftObject = new Element()
            {
                Content = new TypeWithPropertyThatThrows(),
            };

            Element rightObject = new Element()
            {
                Content = new TypeWithPropertyThatThrows(),
            };

            ObjectGraphFactory factory = new PublicPropertyObjectGraphFactory();
            ObjectComparer comparer = new ObjectComparer(factory);
            bool match = comparer.Compare(leftObject, rightObject).None();

            ObjectToConsole(leftObject, factory);

            Assert.True(match, "objects did not match");
        }
        public void CompareTypesDoNotMatch()
        {
            var leftObject = new Element()
            {
                Content = 32,
            };

            var rightObject = new Element()
            {
                Content = "stringvalue",
            };

            ObjectGraphFactory factory = new PublicPropertyObjectGraphFactory();
            ObjectComparer comparer = new ObjectComparer(factory);
            IEnumerable<ObjectComparisonMismatch> mismatches = comparer.Compare(leftObject, rightObject);
            bool match = mismatches.None();

            string[] expectedMismatches = new string[]
            {
                "ObjectTypesDoNotMatch:Left=Element.Content(32) Right=Element.Content(stringvalue)",
            };

            string[] actualMismatches = StringFromMismatches(mismatches);

            Assert.False(match);
            Assert.True(actualMismatches.Length == expectedMismatches.Length);
            for (int index = 0; index < expectedMismatches.Length; index++)
            {
                Assert.Equal(expectedMismatches[index], actualMismatches[index]);
            }
        }
        public void CompareObjectWithLoopInSecondLevel()
        {
            Element leftObject = new Element()
            {
                Name = "RootElement",
                Content = new Element()
                {
                    Name = "ChildElement"
                }
            };

            // child points to root
            ((Element)leftObject.Content).Content = leftObject;

            Element rightObject = new Element()
            {
                Name = "RootElement",
                Content = new Element()
                {
                    Name = "ChildElement"
                }
            };

            // child points to parent
            ((Element)rightObject.Content).Content = rightObject;

            ObjectGraphFactory factory = new PublicPropertyObjectGraphFactory();
            ObjectComparer comparer = new ObjectComparer(factory);
            bool match = comparer.Compare(leftObject, rightObject).None();

            Assert.True(match, "object with loop did not match");
        }
        public void CompareObjectWithSharedNodes()
        {
            Element sharedLeftObject = new Element() { Name = "shared" };
            Element leftObject = new Element()
            {
                Name = "RootElement",
                Content = new List<Element>()
                {
                   sharedLeftObject,
                   sharedLeftObject,
                },
            };

            Element sharedRightObject = new Element() { Name = "shared" };
            Element rightObject = new Element()
            {
                Name = "RootElement",
                Content = new List<Element>()
                {
                   sharedRightObject,
                   sharedRightObject,
                },
            };

            ObjectGraphFactory factory = new PublicPropertyObjectGraphFactory();
            ObjectComparer comparer = new ObjectComparer(factory);
            bool match = comparer.Compare(leftObject, rightObject).None();

            Assert.True(match, "object with loop did not match");
        }
        public void CompareMissingNodes()
        {
            var leftObject = new Element()
            {
                Name = "Content1",
                Content = new Element()
                {
                    Name = "OnlyOnLeft",
                }
            };

            var rightObject = new Element()
            {
                Name = "Content1"
            };

            ObjectGraphFactory factory = new PublicPropertyObjectGraphFactory();
            ObjectComparer comparer = new ObjectComparer(factory);
            IEnumerable<ObjectComparisonMismatch> mismatches = comparer.Compare(leftObject, rightObject);
            bool match = mismatches.None();
            Assert.False(match);
        }
        public void CompareList()
        {
            List<string> leftObject = new List<string>()
            {
                "Hello",
                "World",
            };

            List<string> rightObject = new List<string>()
            {
                "Hello",
                "World",
            };

            ObjectGraphFactory factory = new PublicPropertyObjectGraphFactory();
            ObjectComparer comparer = new ObjectComparer(factory);
            bool match = comparer.Compare(leftObject, rightObject).None();

            Assert.True(match, "List<string> did not match");
        }
        public void CompareIncorrectChildCount()
        {
            var leftObject = new Element()
            {
                Content = new string[]
                {
                    "String1",
                    "String2",
                },
            };

            var rightObject = new Element()
            {
                Content = new string[]
                {
                    "String1",
                },
            };

            ObjectGraphFactory factory = new PublicPropertyObjectGraphFactory();
            ObjectComparer comparer = new ObjectComparer(factory);
            IEnumerable<ObjectComparisonMismatch> mismatches = comparer.Compare(leftObject, rightObject);
            bool match = mismatches.None();

            string[] expectedMismatches = new string[]
            {
               "RightNodeHasFewerChildren:Left=Element.Content(System.String[]) Right=Element.Content(System.String[])",
               "MissingRightNode:Left=Element.Content.IEnumerable1(String2) Right=Null(Null)"
            };

            string[] actualMismatches = StringFromMismatches(mismatches);

            Assert.False(match);
            Assert.True(actualMismatches.Length == expectedMismatches.Length);
            for (int index = 0; index < expectedMismatches.Length; index++)
            {
                Assert.Equal(expectedMismatches[index], actualMismatches[index]);
            }
        }
        public void CompareIEnumerable()
        {
            Element leftObject = new Element()
            {
                Name = "root",
                Content = new List<string>
                {
                    "hello1",
                    "hello2",
                    "hello3"
                }
            };

            Element rightObject = new Element()
            {
                Name = "root",
                Content = new List<string>
                {
                    "hello1",
                    "hello2",
                    "hello3"
                }
            };

            ObjectGraphFactory factory = new PublicPropertyObjectGraphFactory();
            ObjectComparer comparer = new ObjectComparer(factory);
            bool match = comparer.Compare(leftObject, rightObject).None();

            Assert.True(match, "objects did not match");
        }
        public void CompareDictionary()
        {
            Dictionary<int, string> leftObject = new Dictionary<int, string>()
            {
                { 10, "Hello" },
                { 20, "World" },
            };

            Dictionary<int, string> rightObject = new Dictionary<int, string>()
            {
                { 10, "Hello" },
                { 20, "World" },
            };

            ObjectGraphFactory factory = new PublicPropertyObjectGraphFactory();
            ObjectComparer comparer = new ObjectComparer(factory);
            bool match = comparer.Compare(leftObject, rightObject).None();

            Assert.True(match, "Dictionary<int, string> did not match");
        }