public void TestRemoveReferenceListItem() { var nodeContainer = new NodeContainer(); var obj = new[] { new SimpleClass(), new SimpleClass(), new SimpleClass() }; var instance = new ComplexClass { Member6 = new List <SimpleClass> { obj[0], obj[1], obj[2] } }; var rootNode = nodeContainer.GetOrCreateNode(instance); var dynNode = DynamicNode.FromNode(rootNode); Assert.AreEqual(instance.Member6[0], (SimpleClass)dynNode.Member6[0]); Assert.AreEqual(instance.Member6[1], (SimpleClass)dynNode.Member6[1]); Assert.AreEqual(instance.Member6[2], (SimpleClass)dynNode.Member6[2]); Assert.AreEqual(obj[0], (SimpleClass)dynNode.Member6[0]); Assert.AreEqual(obj[1], (SimpleClass)dynNode.Member6[1]); Assert.AreEqual(obj[2], (SimpleClass)dynNode.Member6[2]); dynNode.Member6.Remove(obj[1], new Index(1)); Assert.AreEqual(instance.Member6[0], (SimpleClass)dynNode.Member6[0]); Assert.AreEqual(instance.Member6[1], (SimpleClass)dynNode.Member6[1]); Assert.AreEqual(obj[0], (SimpleClass)dynNode.Member6[0]); Assert.AreEqual(obj[2], (SimpleClass)dynNode.Member6[1]); rootNode[nameof(ComplexClass.Member6)].Remove(obj[2], new Index(1)); Assert.AreEqual(instance.Member6[0], (SimpleClass)dynNode.Member6[0]); Assert.AreEqual(obj[0], (SimpleClass)dynNode.Member6[0]); }
public void TestChangeReferenceList() { var nodeContainer = new NodeContainer(); var obj = new[] { new List <SimpleClass> { new SimpleClass() }, new List <SimpleClass> { new SimpleClass() }, new List <SimpleClass> { new SimpleClass() } }; var instance = new ComplexClass { Member6 = obj[0] }; var rootNode = nodeContainer.GetOrCreateNode(instance); var dynNode = DynamicNode.FromNode(rootNode); Assert.AreEqual(instance.Member6, (List <SimpleClass>)dynNode.Member6); Assert.AreEqual(obj[0], (List <SimpleClass>)dynNode.Member6); dynNode.Member6 = obj[1]; Assert.AreEqual(instance.Member6, (List <SimpleClass>)dynNode.Member6); Assert.AreEqual(obj[1], (List <SimpleClass>)dynNode.Member6); rootNode[nameof(ComplexClass.Member6)].Update(obj[2]); Assert.AreEqual(instance.Member6, (List <SimpleClass>)dynNode.Member6); Assert.AreEqual(obj[2], (List <SimpleClass>)dynNode.Member6); }
public void TestRemovePrimitiveListItem() { var nodeContainer = new NodeContainer(); var obj = new[] { "aa", "bb", "cc" }; var instance = new ComplexClass { Member5 = new List <string> { obj[0], obj[1], obj[2] } }; var rootNode = nodeContainer.GetOrCreateNode(instance); var dynNode = DynamicNode.FromNode(rootNode); Assert.AreEqual(instance.Member5[0], (string)dynNode.Member5[0]); Assert.AreEqual(instance.Member5[1], (string)dynNode.Member5[1]); Assert.AreEqual(instance.Member5[2], (string)dynNode.Member5[2]); Assert.AreEqual(obj[0], (string)dynNode.Member5[0]); Assert.AreEqual(obj[1], (string)dynNode.Member5[1]); Assert.AreEqual(obj[2], (string)dynNode.Member5[2]); dynNode.Member5.Remove(obj[1], new Index(1)); Assert.AreEqual(instance.Member5[0], (string)dynNode.Member5[0]); Assert.AreEqual(instance.Member5[1], (string)dynNode.Member5[1]); Assert.AreEqual(obj[0], (string)dynNode.Member5[0]); Assert.AreEqual(obj[2], (string)dynNode.Member5[1]); rootNode[nameof(ComplexClass.Member5)].Remove(obj[2], new Index(1)); Assert.AreEqual(instance.Member5[0], (string)dynNode.Member5[0]); Assert.AreEqual(obj[0], (string)dynNode.Member5[0]); }
public void TestChangePrimitiveList() { var nodeContainer = new NodeContainer(); var obj = new[] { new List <string> { "aa" }, new List <string> { "bb" }, new List <string> { "cc" } }; var instance = new ComplexClass { Member5 = obj[0] }; var rootNode = nodeContainer.GetOrCreateNode(instance); var dynNode = DynamicNode.FromNode(rootNode); Assert.AreEqual(instance.Member5, (List <string>)dynNode.Member5); Assert.AreEqual(obj[0], (List <string>)dynNode.Member5); dynNode.Member5 = obj[1]; Assert.AreEqual(instance.Member5, (List <string>)dynNode.Member5); Assert.AreEqual(obj[1], (List <string>)dynNode.Member5); rootNode[nameof(ComplexClass.Member5)].Update(obj[2]); Assert.AreEqual(instance.Member5, (List <string>)dynNode.Member5); Assert.AreEqual(obj[2], (List <string>)dynNode.Member5); }
public void TestChangeStruct() { var nodeContainer = new NodeContainer(); var obj = new[] { new Struct { Member1 = "aa" }, new Struct { Member1 = "bb" }, new Struct { Member1 = "cc" } }; var instance = new ComplexClass { Member4 = obj[0] }; var rootNode = nodeContainer.GetOrCreateNode(instance); var dynNode = DynamicNode.FromNode(rootNode); Assert.AreEqual(instance.Member4, (Struct)dynNode.Member4); Assert.AreEqual(obj[0].Member1, (string)dynNode.Member4.Member1); dynNode.Member4 = obj[1]; Assert.AreEqual(obj[1], instance.Member4); Assert.AreEqual(obj[1].Member1, (string)dynNode.Member4.Member1); Assert.AreEqual(instance.Member4, (Struct)dynNode.Member4); rootNode[nameof(ComplexClass.Member4)].Update(obj[2]); Assert.AreEqual(obj[2], instance.Member4); Assert.AreEqual(obj[2].Member1, (string)dynNode.Member4.Member1); Assert.AreEqual(instance.Member4, (Struct)dynNode.Member4); }
public void TestChangeBoxedPrimitiveMember() { var nodeContainer = new NodeContainer(); var instance = new ComplexClass { Member3 = 3 }; var rootNode = nodeContainer.GetOrCreateNode(instance); var dynNode = DynamicNode.FromNode(rootNode); Assert.AreEqual(instance.Member3, (int)dynNode.Member3); dynNode.Member3 = 4; Assert.AreEqual(4, instance.Member3); Assert.AreEqual(instance.Member3, (int)dynNode.Member3); rootNode.GetChild(nameof(ComplexClass.Member3)).Content.Update(5); Assert.AreEqual(5, instance.Member3); Assert.AreEqual(instance.Member3, (int)dynNode.Member3); }
public void TestChangePrimitiveMember() { var nodeContainer = new NodeContainer(); var instance = new ComplexClass { Member1 = 3 }; var rootNode = nodeContainer.GetOrCreateNode(instance); var dynNode = DynamicNode.FromNode(rootNode); Assert.Equal(instance.Member1, (int)dynNode.Member1); dynNode.Member1 = 4; Assert.Equal(4, instance.Member1); Assert.Equal(instance.Member1, (int)dynNode.Member1); rootNode[nameof(ComplexClass.Member1)].Update(5); Assert.Equal(5, instance.Member1); Assert.Equal(instance.Member1, (int)dynNode.Member1); }
public void TestChangeReferenceMemberToNull() { var nodeContainer = new NodeContainer(); var obj = new[] { new SimpleClass(), null, new SimpleClass() }; var instance = new ComplexClass { Member2 = obj[0] }; var rootNode = nodeContainer.GetOrCreateNode(instance); var dynNode = DynamicNode.FromNode(rootNode); Assert.AreEqual(instance.Member2, (SimpleClass)dynNode.Member2); dynNode.Member2 = obj[1]; Assert.AreEqual(obj[1], instance.Member2); Assert.AreEqual(instance.Member2, (SimpleClass)dynNode.Member2); rootNode.GetChild(nameof(ComplexClass.Member2)).Content.Update(obj[2]); Assert.AreEqual(obj[2], instance.Member2); Assert.AreEqual(instance.Member2, (SimpleClass)dynNode.Member2); }
public void TestChangeReferenceInObjectMember() { var nodeContainer = new NodeContainer(); var obj = new[] { new SimpleClass(), new SimpleClass(), new SimpleClass() }; var instance = new ComplexClass { Member3 = obj[0] }; var rootNode = nodeContainer.GetOrCreateNode(instance); var dynNode = DynamicNode.FromNode(rootNode); Assert.Equal(instance.Member3, (SimpleClass)dynNode.Member3); dynNode.Member3 = obj[1]; Assert.Equal(obj[1], instance.Member3); Assert.Equal(instance.Member3, (SimpleClass)dynNode.Member3); rootNode[nameof(ComplexClass.Member3)].Update(obj[2]); Assert.Equal(obj[2], instance.Member3); Assert.Equal(instance.Member3, (SimpleClass)dynNode.Member3); }
public void TestChangeReferenceListItem() { var nodeContainer = new NodeContainer(); var obj = new[] { new SimpleClass(), new SimpleClass(), new SimpleClass() }; var instance = new ComplexClass { Member6 = new List <SimpleClass> { obj[0] } }; var rootNode = nodeContainer.GetOrCreateNode(instance); var dynNode = DynamicNode.FromNode(rootNode); Assert.AreEqual(instance.Member6[0], (SimpleClass)dynNode.Member6[0]); Assert.AreEqual(obj[0], (SimpleClass)dynNode.Member6[0]); dynNode.Member6[0] = obj[1]; Assert.AreEqual(instance.Member6[0], (SimpleClass)dynNode.Member6[0]); Assert.AreEqual(obj[1], (SimpleClass)dynNode.Member6[0]); rootNode.GetChild(nameof(ComplexClass.Member6)).Content.Update(obj[2], new Index(0)); Assert.AreEqual(instance.Member6[0], (SimpleClass)dynNode.Member6[0]); Assert.AreEqual(obj[2], (SimpleClass)dynNode.Member6[0]); }
public void TestChangePrimitiveListItem() { var nodeContainer = new NodeContainer(); var obj = new[] { "aa", "bb", "cc" }; var instance = new ComplexClass { Member5 = new List <string> { obj[0] } }; var rootNode = nodeContainer.GetOrCreateNode(instance); var dynNode = DynamicNode.FromNode(rootNode); Assert.AreEqual(instance.Member5[0], (string)dynNode.Member5[0]); Assert.AreEqual(obj[0], (string)dynNode.Member5[0]); dynNode.Member5[0] = obj[1]; Assert.AreEqual(instance.Member5[0], (string)dynNode.Member5[0]); Assert.AreEqual(obj[1], (string)dynNode.Member5[0]); rootNode.GetChild(nameof(ComplexClass.Member5)).Content.Update(obj[2], new Index(0)); Assert.AreEqual(instance.Member5[0], (string)dynNode.Member5[0]); Assert.AreEqual(obj[2], (string)dynNode.Member5[0]); }
public void TestChangeStructMember() { var nodeContainer = new NodeContainer(); var obj = new[] { "aa", "bb", "cc" }; var instance = new ComplexClass { Member4 = new Struct { Member1 = obj[0] } }; var rootNode = nodeContainer.GetOrCreateNode(instance); var dynNode = DynamicNode.FromNode(rootNode); Assert.AreEqual(instance.Member4, (Struct)dynNode.Member4); Assert.AreEqual(obj[0], (string)dynNode.Member4.Member1); dynNode.Member4.Member1 = obj[1]; Assert.AreEqual(obj[1], (string)dynNode.Member4.Member1); Assert.AreEqual(instance.Member4, (Struct)dynNode.Member4); rootNode.GetChild(nameof(ComplexClass.Member4)).GetChild(nameof(Struct.Member1)).Content.Update(obj[2]); Assert.AreEqual(obj[2], (string)dynNode.Member4.Member1); Assert.AreEqual(instance.Member4, (Struct)dynNode.Member4); }
public void TestChangeStructListItemMember() { var nodeContainer = new NodeContainer(); var obj = new[] { "aa", "bb", "cc" }; var instance = new ComplexClass { Member7 = new List <Struct> { new Struct(), new Struct { Member1 = obj[0] } } }; var rootNode = nodeContainer.GetOrCreateNode(instance); var dynNode = DynamicNode.FromNode(rootNode); Assert.AreEqual(instance.Member7[1].Member1, (string)dynNode.Member7[1].Member1); Assert.AreEqual(obj[0], (string)dynNode.Member7[1].Member1); dynNode.Member7[1].Member1 = obj[1]; Assert.AreEqual(obj[1], (string)dynNode.Member7[1].Member1); Assert.AreEqual(instance.Member7[1].Member1, (string)dynNode.Member7[1].Member1); rootNode.GetChild(nameof(ComplexClass.Member7)).GetTarget(new Index(1)).GetChild(nameof(SimpleClass.Member1)).Content.Update(obj[2]); Assert.AreEqual(obj[2], (string)dynNode.Member7[1].Member1); Assert.AreEqual(instance.Member7[1].Member1, (string)dynNode.Member7[1].Member1); }