Ejemplo n.º 1
0
        public void TestCustomFindTargetReference()
        {
            var nodeContainer = new NodeContainer();
            var instance1     = new ObjectListClass {
                Member1 = 3, Member2 = new List <SimpleClass> {
                    new SimpleClass {
                        Member1 = 1
                    }, new SimpleClass {
                        Member1 = 2
                    }, new SimpleClass {
                        Member1 = 3
                    }
                }
            };
            var instance2 = new ObjectListClass {
                Member1 = 3, Member2 = new List <SimpleClass> {
                    new SimpleClass {
                        Member1 = 2
                    }, new SimpleClass {
                        Member1 = 4
                    }, new SimpleClass {
                        Member1 = 1
                    }
                }
            };
            var source = nodeContainer.GetOrCreateNode(instance1);
            var target = nodeContainer.GetOrCreateNode(instance2);
            var linker = new CustomFindTargetReferenceLinker();

            linker.LinkGraph(source, target);
            // Expected links by index: 0 -> 2, 1 -> 0, 2 -> null
            var expectedLinks = new Dictionary <IGraphNode, IGraphNode>
            {
                { source, target },
                { source[nameof(SimpleClass.Member1)], target[nameof(SimpleClass.Member1)] },
                { source[nameof(SimpleClass.Member2)], target[nameof(SimpleClass.Member2)] },
                { source[nameof(SimpleClass.Member2)].Target, target[nameof(SimpleClass.Member2)].Target },
                { source[nameof(SimpleClass.Member2)].Target.IndexedTarget(new NodeIndex(0)), target[nameof(SimpleClass.Member2)].Target.IndexedTarget(new NodeIndex(2)) },
                { source[nameof(SimpleClass.Member2)].Target.IndexedTarget(new NodeIndex(0))[nameof(SimpleClass.Member1)], target[nameof(SimpleClass.Member2)].Target.IndexedTarget(new NodeIndex(2))[nameof(SimpleClass.Member1)] },
                { source[nameof(SimpleClass.Member2)].Target.IndexedTarget(new NodeIndex(0))[nameof(SimpleClass.Member2)], target[nameof(SimpleClass.Member2)].Target.IndexedTarget(new NodeIndex(2))[nameof(SimpleClass.Member2)] },
                { source[nameof(SimpleClass.Member2)].Target.IndexedTarget(new NodeIndex(1)), target[nameof(SimpleClass.Member2)].Target.IndexedTarget(new NodeIndex(0)) },
                { source[nameof(SimpleClass.Member2)].Target.IndexedTarget(new NodeIndex(1))[nameof(SimpleClass.Member1)], target[nameof(SimpleClass.Member2)].Target.IndexedTarget(new NodeIndex(0))[nameof(SimpleClass.Member1)] },
                { source[nameof(SimpleClass.Member2)].Target.IndexedTarget(new NodeIndex(1))[nameof(SimpleClass.Member2)], target[nameof(SimpleClass.Member2)].Target.IndexedTarget(new NodeIndex(0))[nameof(SimpleClass.Member2)] },
                { source[nameof(SimpleClass.Member2)].Target.IndexedTarget(new NodeIndex(2)), null },
                { source[nameof(SimpleClass.Member2)].Target.IndexedTarget(new NodeIndex(2))[nameof(SimpleClass.Member1)], null },
                { source[nameof(SimpleClass.Member2)].Target.IndexedTarget(new NodeIndex(2))[nameof(SimpleClass.Member2)], null },
            };

            VerifyLinks(expectedLinks, linker);
        }
 public void TestCustomFindTargetReference()
 {
     var nodeContainer = new NodeContainer();
     var instance1 = new ObjectListClass { Member1 = 3, Member2 = new List<SimpleClass> { new SimpleClass { Member1 = 1 }, new SimpleClass { Member1 = 2 }, new SimpleClass { Member1 = 3 } } };
     var instance2 = new ObjectListClass { Member1 = 3, Member2 = new List<SimpleClass> { new SimpleClass { Member1 = 2 }, new SimpleClass { Member1 = 4 }, new SimpleClass { Member1 = 1 } } };
     var source = nodeContainer.GetOrCreateNode(instance1);
     var target = nodeContainer.GetOrCreateNode(instance2);
     var linker = new CustomFindTargetReferenceLinker();
     linker.LinkGraph(source, target);
     // Expected links by index: 0 -> 2, 1 -> 0, 2 -> null
     Index index = new Index(0);
     IGraphNode tempQualifier = source[nameof(SimpleClass.Member2)];
     Index index1 = new Index(2);
     IGraphNode tempQualifier1 = target[nameof(SimpleClass.Member2)];
     Index index2 = new Index(0);
     IGraphNode tempQualifier2 = source[nameof(SimpleClass.Member2)];
     Index index3 = new Index(2);
     IGraphNode tempQualifier3 = target[nameof(SimpleClass.Member2)];
     Index index4 = new Index(0);
     IGraphNode tempQualifier4 = source[nameof(SimpleClass.Member2)];
     Index index5 = new Index(2);
     IGraphNode tempQualifier5 = target[nameof(SimpleClass.Member2)];
     Index index6 = new Index(1);
     IGraphNode tempQualifier6 = source[nameof(SimpleClass.Member2)];
     Index index7 = new Index(0);
     IGraphNode tempQualifier7 = target.TryGetChild(nameof(SimpleClass.Member2));
     Index index8 = new Index(1);
     IGraphNode tempQualifier8 = source[nameof(SimpleClass.Member2)];
     Index index9 = new Index(0);
     IGraphNode tempQualifier9 = target[nameof(SimpleClass.Member2)];
     Index index10 = new Index(1);
     IGraphNode tempQualifier10 = source[nameof(SimpleClass.Member2)];
     Index index11 = new Index(0);
     IGraphNode tempQualifier11 = target[nameof(SimpleClass.Member2)];
     Index index12 = new Index(2);
     IGraphNode tempQualifier12 = source[nameof(SimpleClass.Member2)];
     Index index13 = new Index(2);
     IGraphNode tempQualifier13 = source[nameof(SimpleClass.Member2)];
     Index index14 = new Index(2);
     IGraphNode tempQualifier14 = source[nameof(SimpleClass.Member2)];
     var expectedLinks = new Dictionary<IGraphNode, IGraphNode>
     {
         { source, target },
         { source[nameof(SimpleClass.Member1)], target.TryGetChild(nameof(SimpleClass.Member1)) },
         { source[nameof(SimpleClass.Member2)], target.TryGetChild(nameof(SimpleClass.Member2)) },
         { tempQualifier.IndexedTarget(index), tempQualifier1.IndexedTarget(index1) },
         { tempQualifier2.IndexedTarget(index2)[nameof(SimpleClass.Member1)], tempQualifier3.IndexedTarget(index3)[nameof(SimpleClass.Member1)] },
         { tempQualifier4.IndexedTarget(index4)[nameof(SimpleClass.Member2)], tempQualifier5.IndexedTarget(index5)[nameof(SimpleClass.Member2)] },
         { tempQualifier6.IndexedTarget(index6), tempQualifier7.IndexedTarget(index7) },
         { tempQualifier8.IndexedTarget(index8)[nameof(SimpleClass.Member1)], tempQualifier9.IndexedTarget(index9)[nameof(SimpleClass.Member1)] },
         { tempQualifier10.IndexedTarget(index10)[nameof(SimpleClass.Member2)], tempQualifier11.IndexedTarget(index11)[nameof(SimpleClass.Member2)] },
         { tempQualifier12.IndexedTarget(index12), null },
         { tempQualifier13.IndexedTarget(index13)[nameof(SimpleClass.Member1)], null },
         { tempQualifier14.IndexedTarget(index14)[nameof(SimpleClass.Member2)], null },
     };
     VerifyLinks(expectedLinks, linker);
 }
Ejemplo n.º 3
0
        public void TestCustomFindTargetReference()
        {
            var nodeContainer = new NodeContainer();
            var instance1     = new ObjectListClass {
                Member1 = 3, Member2 = new List <SimpleClass> {
                    new SimpleClass {
                        Member1 = 1
                    }, new SimpleClass {
                        Member1 = 2
                    }, new SimpleClass {
                        Member1 = 3
                    }
                }
            };
            var instance2 = new ObjectListClass {
                Member1 = 3, Member2 = new List <SimpleClass> {
                    new SimpleClass {
                        Member1 = 2
                    }, new SimpleClass {
                        Member1 = 4
                    }, new SimpleClass {
                        Member1 = 1
                    }
                }
            };
            var source = nodeContainer.GetOrCreateNode(instance1);
            var target = nodeContainer.GetOrCreateNode(instance2);
            var linker = new CustomFindTargetReferenceLinker();

            linker.LinkGraph(source, target);
            // Expected links by index: 0 -> 2, 1 -> 0, 2 -> null
            Index        index           = new Index(0);
            IContentNode tempQualifier   = source[nameof(SimpleClass.Member2)];
            Index        index1          = new Index(2);
            IContentNode tempQualifier1  = target[nameof(SimpleClass.Member2)];
            Index        index2          = new Index(0);
            IContentNode tempQualifier2  = source[nameof(SimpleClass.Member2)];
            Index        index3          = new Index(2);
            IContentNode tempQualifier3  = target[nameof(SimpleClass.Member2)];
            Index        index4          = new Index(0);
            IContentNode tempQualifier4  = source[nameof(SimpleClass.Member2)];
            Index        index5          = new Index(2);
            IContentNode tempQualifier5  = target[nameof(SimpleClass.Member2)];
            Index        index6          = new Index(1);
            IContentNode tempQualifier6  = source[nameof(SimpleClass.Member2)];
            Index        index7          = new Index(0);
            IContentNode tempQualifier7  = target[nameof(SimpleClass.Member2)];
            Index        index8          = new Index(1);
            IContentNode tempQualifier8  = source[nameof(SimpleClass.Member2)];
            Index        index9          = new Index(0);
            IContentNode tempQualifier9  = target[nameof(SimpleClass.Member2)];
            Index        index10         = new Index(1);
            IContentNode tempQualifier10 = source[nameof(SimpleClass.Member2)];
            Index        index11         = new Index(0);
            IContentNode tempQualifier11 = target[nameof(SimpleClass.Member2)];
            Index        index12         = new Index(2);
            IContentNode tempQualifier12 = source[nameof(SimpleClass.Member2)];
            Index        index13         = new Index(2);
            IContentNode tempQualifier13 = source[nameof(SimpleClass.Member2)];
            Index        index14         = new Index(2);
            IContentNode tempQualifier14 = source[nameof(SimpleClass.Member2)];
            var          expectedLinks   = new Dictionary <IContentNode, IContentNode>
            {
                { source, target },
                { source[nameof(SimpleClass.Member1)], target[nameof(SimpleClass.Member1)] },
                { source[nameof(SimpleClass.Member2)], target[nameof(SimpleClass.Member2)] },
                { tempQualifier.IndexedTarget(index), tempQualifier1.IndexedTarget(index1) },
                { tempQualifier2.IndexedTarget(index2)[nameof(SimpleClass.Member1)], tempQualifier3.IndexedTarget(index3)[nameof(SimpleClass.Member1)] },
                { tempQualifier4.IndexedTarget(index4)[nameof(SimpleClass.Member2)], tempQualifier5.IndexedTarget(index5)[nameof(SimpleClass.Member2)] },
                { tempQualifier6.IndexedTarget(index6), tempQualifier7.IndexedTarget(index7) },
                { tempQualifier8.IndexedTarget(index8)[nameof(SimpleClass.Member1)], tempQualifier9.IndexedTarget(index9)[nameof(SimpleClass.Member1)] },
                { tempQualifier10.IndexedTarget(index10)[nameof(SimpleClass.Member2)], tempQualifier11.IndexedTarget(index11)[nameof(SimpleClass.Member2)] },
                { tempQualifier12.IndexedTarget(index12), null },
                { tempQualifier13.IndexedTarget(index13)[nameof(SimpleClass.Member1)], null },
                { tempQualifier14.IndexedTarget(index14)[nameof(SimpleClass.Member2)], null },
            };

            VerifyLinks(expectedLinks, linker);
        }