internal MergerInstanceStructure(MergerTypeStructure typeStructure, object value) : base(typeStructure)
 {
     TypeStructure = typeStructure;
     Value         = value;
     Nodes         = new Dictionary <MergerTypeStructure, List <MergerInstanceStructure> >(TypeStructure.Nodes.Count);
     Properties    = new Dictionary <MergerTypeProperty, List <MergerInstanceProperty> >(TypeStructure.Properties.Count);
     foreach (var node in TypeStructure.Nodes)
     {
         var nodeValue = HasValue ? node.Property.GetValue(Value) : null;
         if (node.IsArray)
         {
             var nodes = ((object[])nodeValue)?
                         .Select(itemValue => new MergerInstanceStructure(node, itemValue)).ToList();
             Nodes.Add(node, nodes);
         }
         else
         {
             Nodes.AddFirst(node, new MergerInstanceStructure(node, nodeValue));
         }
     }
     foreach (var property in TypeStructure.Properties)
     {
         var propertyValue = HasValue ? property.Property.GetValue(Value) : null;
         if (property.IsArray)
         {
             var properties = ((object[])propertyValue)?
                              .Select(itemValue => new MergerInstanceProperty(property, itemValue)).ToList();
             Properties.Add(property, properties);
         }
         else
         {
             Properties.AddFirst(property, new MergerInstanceProperty(property, propertyValue));
         }
     }
 }
        public void TestContactObjectLonelyObjectStructureEquality()
        {
            var mergerA = new MyLittleMerger <ContactObject>(new MergerOptions
            {
                AutoAddTypeAssembly = true
            });
            var structureA = new MergerTypeStructure <ContactObject>(mergerA);
            var mergerB    = new MyLittleMerger <LittleObject>(new MergerOptions
            {
                AutoAddTypeAssembly = true
            });
            var structureB = new MergerTypeStructure <LittleObject>(mergerB);

            // ReSharper disable once PossibleUnintendedReferenceComparison
            Assert.AreNotEqual(structureA, structureB);
        }
        public void TestContactObjectStructureEquality()
        {
            var merger = new MyLittleMerger <ContactObject>(new MergerOptions
            {
                AutoAddTypeAssembly = true
            });
            var structureA = new MergerTypeStructure <ContactObject>(merger);
            var structureB = new MergerTypeStructure <ContactObject>(merger);

            var genderNodeA = structureA.Nodes.First(n => Equals(n.Identifier, nameof(ContactObject.Gender)));
            var genderNodeB = structureB.Nodes.First(n => Equals(n.Identifier, nameof(ContactObject.Gender)));

            // ReSharper disable once PossibleUnintendedReferenceComparison
            Assert.IsFalse(structureA == structureB);
            Assert.AreEqual(genderNodeA, genderNodeB);
            Assert.AreEqual(structureA, structureB);
        }