public void TestObjectWithListOfReferences() { var nodeContainer = new NodeContainer(); var instance1 = new ObjectListClass { Member1 = 3, Member2 = new List <SimpleClass> { new SimpleClass(), new SimpleClass() } }; var instance2 = new ObjectListClass { Member1 = 3, Member2 = new List <SimpleClass> { new SimpleClass(), new SimpleClass() } }; var source = nodeContainer.GetOrCreateNode(instance1); var target = nodeContainer.GetOrCreateNode(instance2); var linker = new TestLinker(); linker.LinkGraph(source, target); var expectedLinks = new Dictionary <IGraphNode, IGraphNode> { { source, target }, { source.GetChild(nameof(SimpleClass.Member1)), target.GetChild(nameof(SimpleClass.Member1)) }, { source.GetChild(nameof(SimpleClass.Member2)), target.GetChild(nameof(SimpleClass.Member2)) }, { source.GetChild(nameof(SimpleClass.Member2)).GetTarget(new Index(0)), target.GetChild(nameof(SimpleClass.Member2)).GetTarget(new Index(0)) }, { source.GetChild(nameof(SimpleClass.Member2)).GetTarget(new Index(0)).GetChild(nameof(SimpleClass.Member1)), target.GetChild(nameof(SimpleClass.Member2)).GetTarget(new Index(0)).GetChild(nameof(SimpleClass.Member1)) }, { source.GetChild(nameof(SimpleClass.Member2)).GetTarget(new Index(0)).GetChild(nameof(SimpleClass.Member2)), target.GetChild(nameof(SimpleClass.Member2)).GetTarget(new Index(0)).GetChild(nameof(SimpleClass.Member2)) }, { source.GetChild(nameof(SimpleClass.Member2)).GetTarget(new Index(1)), target.GetChild(nameof(SimpleClass.Member2)).GetTarget(new Index(1)) }, { source.GetChild(nameof(SimpleClass.Member2)).GetTarget(new Index(1)).GetChild(nameof(SimpleClass.Member1)), target.GetChild(nameof(SimpleClass.Member2)).GetTarget(new Index(1)).GetChild(nameof(SimpleClass.Member1)) }, { source.GetChild(nameof(SimpleClass.Member2)).GetTarget(new Index(1)).GetChild(nameof(SimpleClass.Member2)), target.GetChild(nameof(SimpleClass.Member2)).GetTarget(new Index(1)).GetChild(nameof(SimpleClass.Member2)) }, }; VerifyLinks(expectedLinks, linker); }
public void TestObjectWithListOfReferences() { var nodeContainer = new NodeContainer(); var instance1 = new ObjectListClass { Member1 = 3, Member2 = new List <SimpleClass> { new SimpleClass(), new SimpleClass() } }; var instance2 = new ObjectListClass { Member1 = 3, Member2 = new List <SimpleClass> { new SimpleClass(), new SimpleClass() } }; var source = nodeContainer.GetOrCreateNode(instance1); var target = nodeContainer.GetOrCreateNode(instance2); var linker = new TestLinker(); linker.LinkGraph(source, target); Index index = new Index(0); IContentNode tempQualifier = source[nameof(SimpleClass.Member2)]; Index index1 = new Index(0); IContentNode tempQualifier1 = target[nameof(SimpleClass.Member2)]; Index index2 = new Index(0); IContentNode tempQualifier2 = source[nameof(SimpleClass.Member2)]; Index index3 = new Index(0); IContentNode tempQualifier3 = target[nameof(SimpleClass.Member2)]; Index index4 = new Index(0); IContentNode tempQualifier4 = source[nameof(SimpleClass.Member2)]; Index index5 = new Index(0); IContentNode tempQualifier5 = target[nameof(SimpleClass.Member2)]; Index index6 = new Index(1); IContentNode tempQualifier6 = source[nameof(SimpleClass.Member2)]; Index index7 = new Index(1); IContentNode tempQualifier7 = target[nameof(SimpleClass.Member2)]; Index index8 = new Index(1); IContentNode tempQualifier8 = source[nameof(SimpleClass.Member2)]; Index index9 = new Index(1); IContentNode tempQualifier9 = target[nameof(SimpleClass.Member2)]; Index index10 = new Index(1); IContentNode tempQualifier10 = source[nameof(SimpleClass.Member2)]; Index index11 = new Index(1); IContentNode tempQualifier11 = target[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)] }, }; VerifyLinks(expectedLinks, linker); }
public void TestObjectWithObjectList() { var nodeContainer = new NodeContainer(); // We also test a null item in the list var instance = new ObjectListClass { Member1 = 3, Member2 = new List <SimpleClass> { new SimpleClass(), null, new SimpleClass() } }; var rootNode = nodeContainer.GetOrCreateNode(instance); var visitor = new TestVisitor(); visitor.Visit(rootNode); Index index = new Index(2); IContentNode tempQualifier = rootNode[nameof(ObjectListClass.Member2)]; Index index1 = new Index(2); IContentNode tempQualifier1 = rootNode[nameof(ObjectListClass.Member2)]; Index index2 = new Index(2); IContentNode tempQualifier2 = rootNode[nameof(ObjectListClass.Member2)]; Index index3 = new Index(0); IContentNode tempQualifier3 = rootNode[nameof(ObjectListClass.Member2)]; Index index4 = new Index(0); IContentNode tempQualifier4 = rootNode[nameof(ObjectListClass.Member2)]; Index index5 = new Index(0); IContentNode tempQualifier5 = rootNode[nameof(ObjectListClass.Member2)]; var expectedNodes = new IContentNode[] { rootNode, rootNode[nameof(ObjectListClass.Member1)], rootNode[nameof(ObjectListClass.Member2)], tempQualifier4.IndexedTarget(index4), tempQualifier5.IndexedTarget(index5)[nameof(ObjectListClass.Member1)], tempQualifier3.IndexedTarget(index3)[nameof(ObjectListClass.Member2)], tempQualifier1.IndexedTarget(index1), tempQualifier2.IndexedTarget(index2)[nameof(ObjectListClass.Member1)], tempQualifier.IndexedTarget(index)[nameof(ObjectListClass.Member2)], }; var expectedPaths = new[] { new GraphNodePath(rootNode), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member1)), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member2)), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member2)).PushIndex(new Index(0)), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member2)).PushIndex(new Index(0)).PushMember(nameof(ObjectListClass.Member1)), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member2)).PushIndex(new Index(0)).PushMember(nameof(ObjectListClass.Member2)), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member2)).PushIndex(new Index(2)), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member2)).PushIndex(new Index(2)).PushMember(nameof(ObjectListClass.Member1)), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member2)).PushIndex(new Index(2)).PushMember(nameof(ObjectListClass.Member2)), }; VerifyNodesAndPath(expectedNodes, expectedPaths, visitor); }
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 TestObjectWithObjectList() { var nodeContainer = new NodeContainer(); // We also test a null item in the list var instance = new ObjectListClass { Member1 = 3, Member2 = new List <SimpleClass> { new SimpleClass(), null, new SimpleClass() } }; var rootNode = nodeContainer.GetOrCreateNode(instance); var visitor = new TestVisitor(); visitor.Visit(rootNode); var expectedNodes = new IGraphNode[] { rootNode, rootNode[nameof(ObjectListClass.Member1)], rootNode[nameof(ObjectListClass.Member2)], rootNode[nameof(ObjectListClass.Member2)].Target, rootNode[nameof(ObjectListClass.Member2)].Target.IndexedTarget(new NodeIndex(0)), rootNode[nameof(ObjectListClass.Member2)].Target.IndexedTarget(new NodeIndex(0))[nameof(ObjectListClass.Member1)], rootNode[nameof(ObjectListClass.Member2)].Target.IndexedTarget(new NodeIndex(0))[nameof(ObjectListClass.Member2)], rootNode[nameof(ObjectListClass.Member2)].Target.IndexedTarget(new NodeIndex(2)), rootNode[nameof(ObjectListClass.Member2)].Target.IndexedTarget(new NodeIndex(2))[nameof(ObjectListClass.Member1)], rootNode[nameof(ObjectListClass.Member2)].Target.IndexedTarget(new NodeIndex(2))[nameof(ObjectListClass.Member2)], }; var expectedPaths = new GraphNodePath[10]; expectedPaths[0] = new GraphNodePath(rootNode); expectedPaths[1] = expectedPaths[0].Clone(); expectedPaths[1].PushMember(nameof(ObjectListClass.Member1)); expectedPaths[2] = expectedPaths[0].Clone(); expectedPaths[2].PushMember(nameof(ObjectListClass.Member2)); expectedPaths[3] = expectedPaths[2].Clone(); expectedPaths[3].PushTarget(); expectedPaths[4] = expectedPaths[3].Clone(); expectedPaths[4].PushIndex(new NodeIndex(0)); expectedPaths[5] = expectedPaths[4].Clone(); expectedPaths[5].PushMember(nameof(ObjectListClass.Member1)); expectedPaths[6] = expectedPaths[4].Clone(); expectedPaths[6].PushMember(nameof(ObjectListClass.Member2)); expectedPaths[7] = expectedPaths[3].Clone(); expectedPaths[7].PushIndex(new NodeIndex(2)); expectedPaths[8] = expectedPaths[7].Clone(); expectedPaths[8].PushMember(nameof(ObjectListClass.Member1)); expectedPaths[9] = expectedPaths[7].Clone(); expectedPaths[9].PushMember(nameof(ObjectListClass.Member2)); VerifyNodesAndPath(expectedNodes, expectedPaths, visitor); }
public void TestObjectWithObjectList() { var nodeContainer = new NodeContainer(); // We also test a null item in the list var instance = new ObjectListClass { Member1 = 3, Member2 = new List <SimpleClass> { new SimpleClass(), null, new SimpleClass() } }; var rootNode = nodeContainer.GetOrCreateNode(instance); var visitor = new TestVisitor(); visitor.Visit(rootNode); var expectedNodes = new[] { rootNode, rootNode.GetChild(nameof(ObjectListClass.Member1)), rootNode.GetChild(nameof(ObjectListClass.Member2)), rootNode.GetChild(nameof(ObjectListClass.Member2)).GetTarget(new Index(0)), rootNode.GetChild(nameof(ObjectListClass.Member2)).GetTarget(new Index(0)).GetChild(nameof(ObjectListClass.Member1)), rootNode.GetChild(nameof(ObjectListClass.Member2)).GetTarget(new Index(0)).GetChild(nameof(ObjectListClass.Member2)), rootNode.GetChild(nameof(ObjectListClass.Member2)).GetTarget(new Index(2)), rootNode.GetChild(nameof(ObjectListClass.Member2)).GetTarget(new Index(2)).GetChild(nameof(ObjectListClass.Member1)), rootNode.GetChild(nameof(ObjectListClass.Member2)).GetTarget(new Index(2)).GetChild(nameof(ObjectListClass.Member2)), }; var expectedPaths = new[] { new GraphNodePath(rootNode), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member1)), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member2)), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member2)).PushIndex(new Index(0)), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member2)).PushIndex(new Index(0)).PushMember(nameof(ObjectListClass.Member1)), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member2)).PushIndex(new Index(0)).PushMember(nameof(ObjectListClass.Member2)), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member2)).PushIndex(new Index(2)), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member2)).PushIndex(new Index(2)).PushMember(nameof(ObjectListClass.Member1)), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member2)).PushIndex(new Index(2)).PushMember(nameof(ObjectListClass.Member2)), }; VerifyNodesAndPath(expectedNodes, expectedPaths, visitor); }
public void TestObjectWithObjectList() { var nodeContainer = new NodeContainer(); // We also test a null item in the list var instance = new ObjectListClass { Member1 = 3, Member2 = new List<SimpleClass> { new SimpleClass(), null, new SimpleClass() } }; var rootNode = nodeContainer.GetOrCreateNode(instance); var visitor = new TestVisitor(); visitor.Visit(rootNode); Index index = new Index(2); IGraphNode tempQualifier = rootNode.TryGetChild(nameof(ObjectListClass.Member2)); Index index1 = new Index(2); IGraphNode tempQualifier1 = rootNode.TryGetChild(nameof(ObjectListClass.Member2)); Index index2 = new Index(2); IGraphNode tempQualifier2 = rootNode.TryGetChild(nameof(ObjectListClass.Member2)); Index index3 = new Index(0); IGraphNode tempQualifier3 = rootNode.TryGetChild(nameof(ObjectListClass.Member2)); Index index4 = new Index(0); IGraphNode tempQualifier4 = rootNode.TryGetChild(nameof(ObjectListClass.Member2)); Index index5 = new Index(0); IGraphNode tempQualifier5 = rootNode.TryGetChild(nameof(ObjectListClass.Member2)); var expectedNodes = new[] { rootNode, rootNode.TryGetChild(nameof(ObjectListClass.Member1)), rootNode.TryGetChild(nameof(ObjectListClass.Member2)), tempQualifier4.IndexedTarget(index4), tempQualifier5.IndexedTarget(index5).TryGetChild(nameof(ObjectListClass.Member1)), tempQualifier3.IndexedTarget(index3).TryGetChild(nameof(ObjectListClass.Member2)), tempQualifier1.IndexedTarget(index1), tempQualifier2.IndexedTarget(index2).TryGetChild(nameof(ObjectListClass.Member1)), tempQualifier.IndexedTarget(index).TryGetChild(nameof(ObjectListClass.Member2)), }; var expectedPaths = new[] { new GraphNodePath(rootNode), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member1)), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member2)), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member2)).PushIndex(new Index(0)), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member2)).PushIndex(new Index(0)).PushMember(nameof(ObjectListClass.Member1)), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member2)).PushIndex(new Index(0)).PushMember(nameof(ObjectListClass.Member2)), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member2)).PushIndex(new Index(2)), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member2)).PushIndex(new Index(2)).PushMember(nameof(ObjectListClass.Member1)), new GraphNodePath(rootNode).PushMember(nameof(ObjectListClass.Member2)).PushIndex(new Index(2)).PushMember(nameof(ObjectListClass.Member2)), }; VerifyNodesAndPath(expectedNodes, expectedPaths, visitor); }
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); }
public void TestObjectWithListOfReferences() { var nodeContainer = new NodeContainer(); var instance1 = new ObjectListClass { Member1 = 3, Member2 = new List<SimpleClass> { new SimpleClass(), new SimpleClass() } }; var instance2 = new ObjectListClass { Member1 = 3, Member2 = new List<SimpleClass> { new SimpleClass(), new SimpleClass() } }; var source = nodeContainer.GetOrCreateNode(instance1); var target = nodeContainer.GetOrCreateNode(instance2); var linker = new TestLinker(); linker.LinkGraph(source, target); Index index = new Index(0); IGraphNode tempQualifier = source.TryGetChild(nameof(SimpleClass.Member2)); Index index1 = new Index(0); IGraphNode tempQualifier1 = target.TryGetChild(nameof(SimpleClass.Member2)); Index index2 = new Index(0); IGraphNode tempQualifier2 = source.TryGetChild(nameof(SimpleClass.Member2)); Index index3 = new Index(0); IGraphNode tempQualifier3 = target.TryGetChild(nameof(SimpleClass.Member2)); Index index4 = new Index(0); IGraphNode tempQualifier4 = source.TryGetChild(nameof(SimpleClass.Member2)); Index index5 = new Index(0); IGraphNode tempQualifier5 = target.TryGetChild(nameof(SimpleClass.Member2)); Index index6 = new Index(1); IGraphNode tempQualifier6 = source.TryGetChild(nameof(SimpleClass.Member2)); Index index7 = new Index(1); IGraphNode tempQualifier7 = target.TryGetChild(nameof(SimpleClass.Member2)); Index index8 = new Index(1); IGraphNode tempQualifier8 = source.TryGetChild(nameof(SimpleClass.Member2)); Index index9 = new Index(1); IGraphNode tempQualifier9 = target.TryGetChild(nameof(SimpleClass.Member2)); Index index10 = new Index(1); IGraphNode tempQualifier10 = source.TryGetChild(nameof(SimpleClass.Member2)); Index index11 = new Index(1); IGraphNode tempQualifier11 = target.TryGetChild(nameof(SimpleClass.Member2)); var expectedLinks = new Dictionary<IGraphNode, IGraphNode> { { source, target }, { source.TryGetChild(nameof(SimpleClass.Member1)), target.TryGetChild(nameof(SimpleClass.Member1)) }, { source.TryGetChild(nameof(SimpleClass.Member2)), target.TryGetChild(nameof(SimpleClass.Member2)) }, { tempQualifier.IndexedTarget(index), tempQualifier1.IndexedTarget(index1) }, { tempQualifier2.IndexedTarget(index2).TryGetChild(nameof(SimpleClass.Member1)), tempQualifier3.IndexedTarget(index3).TryGetChild(nameof(SimpleClass.Member1)) }, { tempQualifier4.IndexedTarget(index4).TryGetChild(nameof(SimpleClass.Member2)), tempQualifier5.IndexedTarget(index5).TryGetChild(nameof(SimpleClass.Member2)) }, { tempQualifier6.IndexedTarget(index6), tempQualifier7.IndexedTarget(index7) }, { tempQualifier8.IndexedTarget(index8).TryGetChild(nameof(SimpleClass.Member1)), tempQualifier9.IndexedTarget(index9).TryGetChild(nameof(SimpleClass.Member1)) }, { tempQualifier10.IndexedTarget(index10).TryGetChild(nameof(SimpleClass.Member2)), tempQualifier11.IndexedTarget(index11).TryGetChild(nameof(SimpleClass.Member2)) }, }; 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); 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); }