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 listener = new GraphNodeChangeListener(rootNode);
            var node     = rootNode[nameof(ComplexClass.Member6)];

            Assert.AreEqual(obj[0][0], node.Retrieve(new Index(0)));
            TestContentChange(listener, () => rootNode[nameof(ComplexClass.Member6)], ContentChangeType.ValueChange, Index.Empty, obj[0], obj[1], x => x.Update(obj[1]));
            Assert.AreEqual(obj[1][0], node.Retrieve(new Index(0)));
            Assert.AreEqual(node, rootNode[nameof(ComplexClass.Member6)]);
            TestContentChange(listener, () => rootNode[nameof(ComplexClass.Member6)], ContentChangeType.ValueChange, Index.Empty, obj[1], obj[2], x => x.Update(obj[2]));
            Assert.AreEqual(obj[2][0], node.Retrieve(new Index(0)));
            Assert.AreEqual(node, rootNode[nameof(ComplexClass.Member6)]);
            var newItem = new SimpleClass();

            TestContentChange(listener, () => rootNode[nameof(ComplexClass.Member6)], ContentChangeType.CollectionUpdate, new Index(0), obj[2][0], newItem, x => x.Update(newItem, new Index(0)));
            Assert.AreEqual(newItem, node.Retrieve(new Index(0)));
            Assert.AreEqual(node, rootNode[nameof(ComplexClass.Member6)]);
        }
Esempio n. 2
0
        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 listener = new GraphNodeChangeListener(rootNode);
            var node     = rootNode.GetChild(nameof(ComplexClass.Member7)).GetTarget(new Index(1)).GetChild(nameof(SimpleClass.Member1));
            var path     = new GraphNodePath(rootNode).PushMember(nameof(ComplexClass.Member7)).PushIndex(new Index(1)).PushMember(nameof(SimpleClass.Member1));

            Assert.AreEqual(obj[0], node.Content.Retrieve());
            TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[0], obj[1], path, () => node.Content.Update(obj[1], Index.Empty));
            Assert.AreEqual(obj[1], node.Content.Retrieve());
            // TODO: would be nice to be able to keep the same boxed node!
            //Assert.AreEqual(node, rootNode.GetChild(nameof(ComplexClass.Member7)).GetTarget(new Index(1)).GetChild(nameof(SimpleClass.Member1)));
            TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[1], obj[2], path, () => node.Content.Update(obj[2], Index.Empty));
            Assert.AreEqual(obj[2], node.Content.Retrieve());
            //Assert.AreEqual(node, rootNode.GetChild(nameof(ComplexClass.Member7)).GetTarget(new Index(1)).GetChild(nameof(SimpleClass.Member1)));
        }
        public void TestAddStructListItem()
        {
            var nodeContainer = new NodeContainer();
            var obj           = new[] { new Struct {
                                            Member1 = "aa"
                                        }, new Struct {
                                            Member1 = "bb"
                                        }, new Struct {
                                            Member1 = "cc"
                                        } };
            var instance = new ComplexClass {
                Member7 = new List <Struct> {
                    obj[0]
                }
            };
            var rootNode = nodeContainer.GetOrCreateNode(instance);
            var listener = new GraphNodeChangeListener(rootNode);
            var node     = rootNode[nameof(ComplexClass.Member7)];

            Assert.AreEqual(obj[0], node.Retrieve(new Index(0)));
            TestContentChange(listener, () => rootNode[nameof(ComplexClass.Member7)], ContentChangeType.CollectionAdd, new Index(1), null, obj[1], x => x.Add(obj[1], new Index(1)));
            Assert.AreEqual(obj[1], node.Retrieve(new Index(1)));
            Assert.AreEqual(node, rootNode[nameof(ComplexClass.Member7)]);
            TestContentChange(listener, () => rootNode[nameof(ComplexClass.Member7)], ContentChangeType.CollectionAdd, new Index(2), null, obj[2], x => x.Add(obj[2], new Index(2)));
            Assert.AreEqual(obj[2], node.Retrieve(new Index(2)));
            Assert.AreEqual(node, rootNode[nameof(ComplexClass.Member7)]);
        }
Esempio n. 4
0
        public void TestChangeStructListItem()
        {
            var nodeContainer = new NodeContainer();
            var obj           = new[] { new Struct {
                                            Member1 = "aa"
                                        }, new Struct {
                                            Member1 = "bb"
                                        }, new Struct {
                                            Member1 = "cc"
                                        } };
            var instance = new ComplexClass {
                Member7 = new List <Struct> {
                    obj[0]
                }
            };
            var rootNode = nodeContainer.GetOrCreateNode(instance);
            var listener = new GraphNodeChangeListener(rootNode);
            var node     = rootNode.GetChild(nameof(ComplexClass.Member7));
            var path     = new GraphNodePath(rootNode).PushMember(nameof(ComplexClass.Member7));

            Assert.AreEqual(obj[0], node.Content.Retrieve(new Index(0)));
            TestContentChange(listener, node, ContentChangeType.ValueChange, new Index(0), obj[0], obj[1], path, () => node.Content.Update(obj[1], new Index(0)));
            Assert.AreEqual(obj[1], node.Content.Retrieve(new Index(0)));
            TestContentChange(listener, node, ContentChangeType.ValueChange, new Index(0), obj[1], obj[2], path, () => node.Content.Update(obj[2], new Index(0)));
            Assert.AreEqual(obj[2], node.Content.Retrieve(new Index(0)));
        }
Esempio n. 5
0
        public void TestChangeReferenceListItemMember()
        {
            var nodeContainer = new NodeContainer();
            var obj           = new[] { 3, 4, 5 };
            var instance      = new ComplexClass {
                Member6 = new List <SimpleClass> {
                    new SimpleClass(), new SimpleClass {
                        Member1 = obj[0]
                    }
                }
            };
            var rootNode = nodeContainer.GetOrCreateNode(instance);
            var dynNode  = DynamicNode.FromNode(rootNode);

            Assert.Equal(instance.Member6[1].Member1, (int)dynNode.Member6[1].Member1);
            Assert.Equal(obj[0], (int)dynNode.Member6[1].Member1);
            dynNode.Member6[1].Member1 = obj[1];
            Assert.Equal(obj[1], (int)dynNode.Member6[1].Member1);
            Assert.Equal(instance.Member6[1].Member1, (int)dynNode.Member6[1].Member1);
            NodeIndex index = new NodeIndex(1);

            rootNode[nameof(ComplexClass.Member6)].Target.IndexedTarget(index)[nameof(SimpleClass.Member1)].Update(obj[2]);
            Assert.Equal(obj[2], (int)dynNode.Member6[1].Member1);
            Assert.Equal(instance.Member6[1].Member1, (int)dynNode.Member6[1].Member1);
        }
Esempio n. 6
0
        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.GetChild(nameof(ComplexClass.Member6)).Content.Remove(obj[2], new Index(1));
            Assert.AreEqual(instance.Member6[0], (SimpleClass)dynNode.Member6[0]);
            Assert.AreEqual(obj[0], (SimpleClass)dynNode.Member6[0]);
        }
Esempio n. 7
0
        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.Equal(instance.Member7[1].Member1, (string)dynNode.Member7[1].Member1);
            Assert.Equal(obj[0], (string)dynNode.Member7[1].Member1);
            dynNode.Member7[1].Member1 = obj[1];
            Assert.Equal(obj[1], (string)dynNode.Member7[1].Member1);
            Assert.Equal(instance.Member7[1].Member1, (string)dynNode.Member7[1].Member1);
            NodeIndex index = new NodeIndex(1);

            rootNode[nameof(ComplexClass.Member7)].Target.IndexedTarget(index)[nameof(SimpleClass.Member1)].Update(obj[2]);
            Assert.Equal(obj[2], (string)dynNode.Member7[1].Member1);
            Assert.Equal(instance.Member7[1].Member1, (string)dynNode.Member7[1].Member1);
        }
Esempio n. 8
0
        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 listener = new GraphNodeChangeListener(rootNode);
            var node     = rootNode.GetChild(nameof(ComplexClass.Member4));
            var path     = new GraphNodePath(rootNode).PushMember(nameof(ComplexClass.Member4));

            Assert.AreEqual("aa", node.GetChild(nameof(Struct.Member1)).Content.Retrieve());
            TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[0], obj[1], path, () => node.Content.Update(obj[1]));
            Assert.AreEqual("bb", node.GetChild(nameof(Struct.Member1)).Content.Retrieve());
            TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[1], obj[2], path, () => node.Content.Update(obj[2]));
            Assert.AreEqual("cc", node.GetChild(nameof(Struct.Member1)).Content.Retrieve());
            TestContentChange(listener, node.GetChild(nameof(Struct.Member1)), ContentChangeType.ValueChange, Index.Empty, "cc", "dd", path.PushMember(nameof(Struct.Member1)), () => node.GetChild(nameof(Struct.Member1)).Content.Update("dd"));
            Assert.AreEqual("dd", node.GetChild(nameof(Struct.Member1)).Content.Retrieve());
        }
Esempio n. 9
0
        public void TestInsertStructListItem()
        {
            var nodeContainer = new NodeContainer();
            var obj           = new[] { new Struct {
                                            Member1 = "aa"
                                        }, new Struct {
                                            Member1 = "bb"
                                        }, new Struct {
                                            Member1 = "cc"
                                        } };
            var instance = new ComplexClass {
                Member7 = new List <Struct> {
                    obj[0]
                }
            };
            var rootNode = nodeContainer.GetOrCreateNode(instance);
            var dynNode  = DynamicNode.FromNode(rootNode);

            Assert.AreEqual(instance.Member7[0], (Struct)dynNode.Member7[0]);
            Assert.AreEqual(obj[0], (Struct)dynNode.Member7[0]);
            dynNode.Member7.Insert(obj[1], new Index(0));
            Assert.AreEqual(instance.Member7[0], (Struct)dynNode.Member7[0]);
            Assert.AreEqual(instance.Member7[1], (Struct)dynNode.Member7[1]);
            Assert.AreEqual(obj[1], (Struct)dynNode.Member7[0]);
            Assert.AreEqual(obj[0], (Struct)dynNode.Member7[1]);
            rootNode.TryGetChild(nameof(ComplexClass.Member7)).Content.Add(obj[2], new Index(1));
            Assert.AreEqual(instance.Member7[0], (Struct)dynNode.Member7[0]);
            Assert.AreEqual(instance.Member7[1], (Struct)dynNode.Member7[1]);
            Assert.AreEqual(instance.Member7[2], (Struct)dynNode.Member7[2]);
            Assert.AreEqual(obj[1], (Struct)dynNode.Member7[0]);
            Assert.AreEqual(obj[2], (Struct)dynNode.Member7[1]);
            Assert.AreEqual(obj[0], (Struct)dynNode.Member7[2]);
        }
Esempio n. 10
0
        public void TestChangeReferenceListItemMember()
        {
            var nodeContainer = new NodeContainer();
            var obj           = new[] { 3, 4, 5 };
            var instance      = new ComplexClass {
                Member6 = new List <SimpleClass> {
                    new SimpleClass(), new SimpleClass {
                        Member1 = obj[0]
                    }
                }
            };
            var rootNode = nodeContainer.GetOrCreateNode(instance);
            var dynNode  = DynamicNode.FromNode(rootNode);

            Assert.AreEqual(instance.Member6[1].Member1, (int)dynNode.Member6[1].Member1);
            Assert.AreEqual(obj[0], (int)dynNode.Member6[1].Member1);
            dynNode.Member6[1].Member1 = obj[1];
            Assert.AreEqual(obj[1], (int)dynNode.Member6[1].Member1);
            Assert.AreEqual(instance.Member6[1].Member1, (int)dynNode.Member6[1].Member1);
            Index      index         = new Index(1);
            IGraphNode tempQualifier = rootNode.TryGetChild(nameof(ComplexClass.Member6));

            tempQualifier.IndexedTarget(index).TryGetChild(nameof(SimpleClass.Member1)).Content.Update(obj[2]);
            Assert.AreEqual(obj[2], (int)dynNode.Member6[1].Member1);
            Assert.AreEqual(instance.Member6[1].Member1, (int)dynNode.Member6[1].Member1);
        }
Esempio n. 11
0
        public void ClassWithConstructorArgumentsAndNoAspects()
        {
            String contents = "import AspectSharp.Tests.Classes in AspectSharp.Tests " +
                              " interceptors [" +
                              " \"key\" : DummyInterceptor " +
                              " ]" +
                              " mixins [" +
                              " \"key\" : DummyMixin " +
                              " ]" +
                              " " +
                              " aspect McBrother for DummyCustomer " +
                              "   include \"key\"" +
                              "   " +
                              "   pointcut method(*)" +
                              "     advice(\"key\")" +
                              "   end" +
                              "   " +
                              " end ";

            AspectEngineBuilder builder = new AspectLanguageEngineBuilder(contents);
            AspectEngine        engine  = builder.Build();

            ComplexClass instance = null;

            instance = engine.WrapClass(typeof(ComplexClass), "Eric Cartman") as ComplexClass;
            Assert.AreEqual("Eric Cartman", instance.Name);
            Assert.IsFalse(instance.Started);
        }
Esempio n. 12
0
        public void ClassWithConstructorArguments()
        {
            String contents = "import AspectSharp.Tests.Classes in AspectSharp.Tests " +
                              " " +
                              " aspect MyAspect for ComplexClass " +
                              "   " +
                              "   pointcut method|property(*)" +
                              "     advice(AspectSharp.Tests.Classes.LogInvocationInterceptor)" +
                              "   end" +
                              "   " +
                              " end ";

            AspectEngineBuilder builder = new AspectLanguageEngineBuilder(contents);
            AspectEngine        engine  = builder.Build();

            ComplexClass instance = null;

            instance = engine.WrapClass(typeof(ComplexClass), "Eric Cartman") as ComplexClass;
            Assert.AreEqual("Eric Cartman", instance.Name);
            Assert.IsFalse(instance.Started);
            InvokeAndAssert(instance);

            instance = engine.WrapClass(typeof(ComplexClass), "Kenny McKormick", true) as ComplexClass;
            Assert.AreEqual("Kenny McKormick", instance.Name);
            Assert.IsTrue(instance.Started);
            InvokeAndAssert(instance);

            String[] messages = LogInvocationInterceptor.Messages;
            Assert.AreEqual(20, messages.Length);
        }
Esempio n. 13
0
        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);
            Index      index         = new Index(1);
            IGraphNode tempQualifier = rootNode.TryGetChild(nameof(ComplexClass.Member7));

            tempQualifier.IndexedTarget(index).TryGetChild(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);
        }
Esempio n. 14
0
        public void TestRemoveStructListItem()
        {
            var nodeContainer = new NodeContainer();
            var obj           = new[] { new Struct {
                                            Member1 = "aa"
                                        }, new Struct {
                                            Member1 = "bb"
                                        }, new Struct {
                                            Member1 = "cc"
                                        } };
            var instance = new ComplexClass {
                Member7 = new List <Struct> {
                    obj[0], obj[1], obj[2]
                }
            };
            var rootNode = nodeContainer.GetOrCreateNode(instance);
            var dynNode  = DynamicNode.FromNode(rootNode);

            Assert.Equal(instance.Member7[0], (Struct)dynNode.Member7[0]);
            Assert.Equal(instance.Member7[1], (Struct)dynNode.Member7[1]);
            Assert.Equal(instance.Member7[2], (Struct)dynNode.Member7[2]);
            Assert.Equal(obj[0], (Struct)dynNode.Member7[0]);
            Assert.Equal(obj[1], (Struct)dynNode.Member7[1]);
            Assert.Equal(obj[2], (Struct)dynNode.Member7[2]);
            dynNode.Member7.Remove(obj[1], new NodeIndex(1));
            Assert.Equal(instance.Member7[0], (Struct)dynNode.Member7[0]);
            Assert.Equal(instance.Member7[1], (Struct)dynNode.Member7[1]);
            Assert.Equal(obj[0], (Struct)dynNode.Member7[0]);
            Assert.Equal(obj[2], (Struct)dynNode.Member7[1]);
            rootNode[nameof(ComplexClass.Member7)].Target.Remove(obj[2], new NodeIndex(1));
            Assert.Equal(instance.Member7[0], (Struct)dynNode.Member7[0]);
            Assert.Equal(obj[0], (Struct)dynNode.Member7[0]);
        }
Esempio n. 15
0
        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.GetChild(nameof(ComplexClass.Member4)).Content.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);
        }
Esempio n. 16
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 listener = new GraphNodeChangeListener(rootNode);
            var node     = rootNode.GetChild(nameof(ComplexClass.Member5));
            var path     = new GraphNodePath(rootNode).PushMember(nameof(ComplexClass.Member5));

            Assert.AreEqual("aa", node.Content.Retrieve(new Index(0)));
            TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[0], obj[1], path, () => node.Content.Update(obj[1]));
            Assert.AreEqual("bb", node.Content.Retrieve(new Index(0)));
            TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[1], obj[2], path, () => node.Content.Update(obj[2]));
            Assert.AreEqual("cc", node.Content.Retrieve(new Index(0)));
            TestContentChange(listener, node, ContentChangeType.ValueChange, new Index(0), "cc", "dd", path, () => node.Content.Update("dd", new Index(0)));
            Assert.AreEqual("dd", node.Content.Retrieve(new Index(0)));
        }
Esempio n. 17
0
        public void TestChangeStructList()
        {
            var nodeContainer = new NodeContainer();
            var obj           = new[] { new List <Struct> {
                                            new Struct()
                                        }, new List <Struct> {
                                            new Struct()
                                        }, new List <Struct> {
                                            new Struct()
                                        } };
            var instance = new ComplexClass {
                Member7 = obj[0]
            };
            var rootNode = nodeContainer.GetOrCreateNode(instance);
            var dynNode  = DynamicNode.FromNode(rootNode);

            Assert.Equal(instance.Member7, (List <Struct>)dynNode.Member7);
            Assert.Equal(obj[0], (List <Struct>)dynNode.Member7);
            dynNode.Member7 = obj[1];
            Assert.Equal(instance.Member7, (List <Struct>)dynNode.Member7);
            Assert.Equal(obj[1], (List <Struct>)dynNode.Member7);
            rootNode[nameof(ComplexClass.Member7)].Update(obj[2]);
            Assert.Equal(instance.Member7, (List <Struct>)dynNode.Member7);
            Assert.Equal(obj[2], (List <Struct>)dynNode.Member7);
        }
Esempio n. 18
0
        public void TestInsertPrimitiveListItem()
        {
            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.Equal(instance.Member5[0], (string)dynNode.Member5[0]);
            Assert.Equal(obj[0], (string)dynNode.Member5[0]);
            dynNode.Member5.Insert(obj[1], new NodeIndex(0));
            Assert.Equal(instance.Member5[0], (string)dynNode.Member5[0]);
            Assert.Equal(instance.Member5[1], (string)dynNode.Member5[1]);
            Assert.Equal(obj[1], (string)dynNode.Member5[0]);
            Assert.Equal(obj[0], (string)dynNode.Member5[1]);
            rootNode[nameof(ComplexClass.Member5)].Target.Add(obj[2], new NodeIndex(1));
            Assert.Equal(instance.Member5[0], (string)dynNode.Member5[0]);
            Assert.Equal(instance.Member5[1], (string)dynNode.Member5[1]);
            Assert.Equal(instance.Member5[2], (string)dynNode.Member5[2]);
            Assert.Equal(obj[1], (string)dynNode.Member5[0]);
            Assert.Equal(obj[2], (string)dynNode.Member5[1]);
            Assert.Equal(obj[0], (string)dynNode.Member5[2]);
        }
Esempio n. 19
0
        public void TestInsertReferenceListItem()
        {
            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.Equal(instance.Member6[0], (SimpleClass)dynNode.Member6[0]);
            Assert.Equal(obj[0], (SimpleClass)dynNode.Member6[0]);
            dynNode.Member6.Insert(obj[1], new NodeIndex(0));
            Assert.Equal(instance.Member6[0], (SimpleClass)dynNode.Member6[0]);
            Assert.Equal(instance.Member6[1], (SimpleClass)dynNode.Member6[1]);
            Assert.Equal(obj[1], (SimpleClass)dynNode.Member6[0]);
            Assert.Equal(obj[0], (SimpleClass)dynNode.Member6[1]);
            rootNode[nameof(ComplexClass.Member6)].Target.Add(obj[2], new NodeIndex(1));
            Assert.Equal(instance.Member6[0], (SimpleClass)dynNode.Member6[0]);
            Assert.Equal(instance.Member6[1], (SimpleClass)dynNode.Member6[1]);
            Assert.Equal(instance.Member6[2], (SimpleClass)dynNode.Member6[2]);
            Assert.Equal(obj[1], (SimpleClass)dynNode.Member6[0]);
            Assert.Equal(obj[2], (SimpleClass)dynNode.Member6[1]);
            Assert.Equal(obj[0], (SimpleClass)dynNode.Member6[2]);
        }
Esempio n. 20
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 listener = new GraphNodeChangeListener(rootNode);

            listener.Initialize();
            var node = rootNode[nameof(ComplexClass.Member5)];

            Assert.Equal("aa", node.Retrieve(new NodeIndex(0)));
            TestContentChange(listener, () => rootNode[nameof(ComplexClass.Member5)], ContentChangeType.ValueChange, NodeIndex.Empty, obj[0], obj[1], x => x.Update(obj[1]));
            Assert.Equal("bb", node.Retrieve(new NodeIndex(0)));
            Assert.Equal(node, rootNode[nameof(ComplexClass.Member5)]);
            TestContentChange(listener, () => rootNode[nameof(ComplexClass.Member5)], ContentChangeType.ValueChange, NodeIndex.Empty, obj[1], obj[2], x => x.Update(obj[2]));
            Assert.Equal("cc", node.Retrieve(new NodeIndex(0)));
            Assert.Equal(node, rootNode[nameof(ComplexClass.Member5)]);
            TestItemChange(listener, () => rootNode[nameof(ComplexClass.Member5)].Target, ContentChangeType.CollectionUpdate, new NodeIndex(0), "cc", "dd", x => x.Update("dd", new NodeIndex(0)));
            Assert.Equal("dd", node.Retrieve(new NodeIndex(0)));
            Assert.Equal(node, rootNode[nameof(ComplexClass.Member5)]);
        }
Esempio n. 21
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.GetChild(nameof(ComplexClass.Member6)).Content.Update(obj[2]);
            Assert.AreEqual(instance.Member6, (List <SimpleClass>)dynNode.Member6);
            Assert.AreEqual(obj[2], (List <SimpleClass>)dynNode.Member6);
        }
Esempio n. 22
0
        public void TestChangeStructListItem()
        {
            var nodeContainer = new NodeContainer();
            var obj           = new[] { new Struct {
                                            Member1 = "aa"
                                        }, new Struct {
                                            Member1 = "bb"
                                        }, new Struct {
                                            Member1 = "cc"
                                        } };
            var instance = new ComplexClass {
                Member7 = new List <Struct> {
                    obj[0]
                }
            };
            var rootNode = nodeContainer.GetOrCreateNode(instance);
            var listener = new GraphNodeChangeListener(rootNode);

            listener.Initialize();
            var node     = rootNode[nameof(ComplexClass.Member7)];
            var itemNode = rootNode[nameof(ComplexClass.Member7)].Target.IndexedTarget(new NodeIndex(0));

            Assert.Equal(obj[0], node.Retrieve(new NodeIndex(0)));
            TestItemChange(listener, () => rootNode[nameof(ComplexClass.Member7)].Target, ContentChangeType.CollectionUpdate, new NodeIndex(0), obj[0], obj[1], x => x.Update(obj[1], new NodeIndex(0)));
            Assert.Equal(obj[1], node.Retrieve(new NodeIndex(0)));
            Assert.Equal(node, rootNode[nameof(ComplexClass.Member7)]);
            // TODO: would be nice to be able to keep the same boxed node!
            Assert.Equal(itemNode, rootNode[nameof(ComplexClass.Member7)].Target.IndexedTarget(new NodeIndex(0)));
            TestItemChange(listener, () => rootNode[nameof(ComplexClass.Member7)].Target, ContentChangeType.CollectionUpdate, new NodeIndex(0), obj[1], obj[2], x => x.Update(obj[2], new NodeIndex(0)));
            Assert.Equal(obj[2], node.Retrieve(new NodeIndex(0)));
            Assert.Equal(node, rootNode[nameof(ComplexClass.Member7)]);
            // TODO: would be nice to be able to keep the same boxed node!
            Assert.Equal(itemNode, rootNode[nameof(ComplexClass.Member7)].Target.IndexedTarget(new NodeIndex(0)));
        }
Esempio n. 23
0
        public void TestChangeStructList()
        {
            var nodeContainer = new NodeContainer();
            var obj           = new[] { new List <Struct> {
                                            new Struct()
                                        }, new List <Struct> {
                                            new Struct()
                                        }, new List <Struct> {
                                            new Struct()
                                        } };
            var instance = new ComplexClass {
                Member7 = obj[0]
            };
            var rootNode = nodeContainer.GetOrCreateNode(instance);
            var listener = new GraphNodeChangeListener(rootNode);

            listener.Initialize();
            var node = rootNode[nameof(ComplexClass.Member7)];

            Assert.Equal(obj[0][0], node.Retrieve(new NodeIndex(0)));
            TestContentChange(listener, () => rootNode[nameof(ComplexClass.Member7)], ContentChangeType.ValueChange, NodeIndex.Empty, obj[0], obj[1], x => x.Update(obj[1]));
            Assert.Equal(obj[1][0], node.Retrieve(new NodeIndex(0)));
            Assert.Equal(node, rootNode[nameof(ComplexClass.Member7)]);
            TestContentChange(listener, () => rootNode[nameof(ComplexClass.Member7)], ContentChangeType.ValueChange, NodeIndex.Empty, obj[1], obj[2], x => x.Update(obj[2]));
            Assert.Equal(obj[2][0], node.Retrieve(new NodeIndex(0)));
            var newItem = new Struct();

            Assert.Equal(node, rootNode[nameof(ComplexClass.Member7)]);
            var itemNode = rootNode[nameof(ComplexClass.Member7)].Target.IndexedTarget(new NodeIndex(0));

            TestItemChange(listener, () => rootNode[nameof(ComplexClass.Member7)].Target, ContentChangeType.CollectionUpdate, new NodeIndex(0), obj[2][0], newItem, x => x.Update(newItem, new NodeIndex(0)));
            Assert.Equal(newItem, node.Retrieve(new NodeIndex(0)));
            Assert.Equal(node, rootNode[nameof(ComplexClass.Member7)]);
            Assert.Equal(itemNode, rootNode[nameof(ComplexClass.Member7)].Target.IndexedTarget(new NodeIndex(0)));
        }
Esempio n. 24
0
        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 listener = new GraphNodeChangeListener(rootNode);

            listener.Initialize();
            NodeIndex index = new NodeIndex(1);
            var       node  = rootNode[nameof(ComplexClass.Member7)].Target.IndexedTarget(index)[nameof(SimpleClass.Member1)];

            Assert.Equal(obj[0], node.Retrieve());
            TestContentChange(listener, () => rootNode[nameof(ComplexClass.Member7)].Target.IndexedTarget(index)[nameof(SimpleClass.Member1)], ContentChangeType.ValueChange, NodeIndex.Empty, obj[0], obj[1], x => x.Update(obj[1]));
            Assert.Equal(obj[1], node.Retrieve());
            Assert.Equal(node, rootNode[nameof(ComplexClass.Member7)].Target.IndexedTarget(new NodeIndex(1))[nameof(SimpleClass.Member1)]);
            TestContentChange(listener, () => rootNode[nameof(ComplexClass.Member7)].Target.IndexedTarget(index)[nameof(SimpleClass.Member1)], ContentChangeType.ValueChange, NodeIndex.Empty, obj[1], obj[2], x => x.Update(obj[2]));
            Assert.Equal(obj[2], node.Retrieve());
            Assert.Equal(node, rootNode[nameof(ComplexClass.Member7)].Target.IndexedTarget(new NodeIndex(1))[nameof(SimpleClass.Member1)]);
        }
Esempio n. 25
0
        public void TestRemoveStructListItem()
        {
            var nodeContainer = new NodeContainer();
            var obj           = new[] { new Struct {
                                            Member1 = "aa"
                                        }, new Struct {
                                            Member1 = "bb"
                                        }, new Struct {
                                            Member1 = "cc"
                                        } };
            var instance = new ComplexClass {
                Member7 = new List <Struct> {
                    obj[0], obj[1], obj[2]
                }
            };
            var rootNode = nodeContainer.GetOrCreateNode(instance);
            var listener = new GraphNodeChangeListener(rootNode);

            listener.Initialize();
            var node = rootNode[nameof(ComplexClass.Member7)];

            Assert.Equal(obj[0], node.Retrieve(new NodeIndex(0)));
            Assert.Equal(obj[1], node.Retrieve(new NodeIndex(1)));
            Assert.Equal(obj[2], node.Retrieve(new NodeIndex(2)));
            TestItemChange(listener, () => rootNode[nameof(ComplexClass.Member7)].Target, ContentChangeType.CollectionRemove, new NodeIndex(1), obj[1], null, x => x.Remove(obj[1], new NodeIndex(1)));
            Assert.Equal(obj[0], node.Retrieve(new NodeIndex(0)));
            Assert.Equal(obj[2], node.Retrieve(new NodeIndex(1)));
            Assert.Equal(node, rootNode[nameof(ComplexClass.Member7)]);
            TestItemChange(listener, () => rootNode[nameof(ComplexClass.Member7)].Target, ContentChangeType.CollectionRemove, new NodeIndex(1), obj[2], null, x => x.Remove(obj[2], new NodeIndex(1)));
            Assert.Equal(obj[0], node.Retrieve(new NodeIndex(0)));
            Assert.Equal(node, rootNode[nameof(ComplexClass.Member7)]);
        }
Esempio n. 26
0
        public void TestDiscardedReferenceMember()
        {
            var nodeContainer = new NodeContainer();
            var obj           = new[] { new SimpleClass(), new SimpleClass() };
            var instance      = new ComplexClass {
                Member2 = obj[0]
            };
            var rootNode = nodeContainer.GetOrCreateNode(instance);
            var obj0Node = nodeContainer.GetOrCreateNode(obj[0]);
            var obj1Node = nodeContainer.GetOrCreateNode(obj[1]);
            var listener = new GraphNodeChangeListener(rootNode);

            listener.Initialize();
            int changingCount = 0;
            int changedCount  = 0;

            listener.ValueChanging += (sender, e) => ++ changingCount;
            listener.ValueChanged  += (sender, e) => ++ changedCount;
            obj0Node[nameof(SimpleClass.Member1)].Update(1);
            Assert.Equal(1, changingCount);
            Assert.Equal(1, changedCount);
            rootNode[nameof(ComplexClass.Member2)].Update(obj[1]);
            Assert.Equal(2, changingCount);
            Assert.Equal(2, changedCount);
            obj0Node[nameof(SimpleClass.Member1)].Update(2);
            Assert.Equal(2, changingCount);
            Assert.Equal(2, changedCount);
            obj1Node[nameof(SimpleClass.Member1)].Update(3);
            Assert.Equal(3, changingCount);
            Assert.Equal(3, changedCount);
        }
Esempio n. 27
0
 private static object[] CreateTestCase(
     ComplexClass value,
     ComplexClass other,
     bool expected)
 {
     return(new object[] { value, other, expected });
 }
Esempio n. 28
0
        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 listener = new GraphNodeChangeListener(rootNode);

            listener.Initialize();
            var node = rootNode[nameof(ComplexClass.Member4)];

            Assert.Equal("aa", node.Target[nameof(Struct.Member1)].Retrieve());
            TestContentChange(listener, () => rootNode[nameof(ComplexClass.Member4)], ContentChangeType.ValueChange, NodeIndex.Empty, obj[0], obj[1], x => x.Update(obj[1]));
            Assert.Equal("bb", node.Target[nameof(Struct.Member1)].Retrieve());
            Assert.Equal(node, rootNode[nameof(ComplexClass.Member4)]);
            TestContentChange(listener, () => rootNode[nameof(ComplexClass.Member4)], ContentChangeType.ValueChange, NodeIndex.Empty, obj[1], obj[2], x => x.Update(obj[2]));
            Assert.Equal("cc", node.Target[nameof(Struct.Member1)].Retrieve());
            Assert.Equal(node, rootNode[nameof(ComplexClass.Member4)]);
            TestContentChange(listener, () => rootNode[nameof(ComplexClass.Member4)].Target[nameof(Struct.Member1)], ContentChangeType.ValueChange, NodeIndex.Empty, "cc", "dd", x => x.Update("dd"));
            Assert.Equal("dd", node.Target[nameof(Struct.Member1)].Retrieve());
            Assert.Equal(node, rootNode[nameof(ComplexClass.Member4)]);
        }
Esempio n. 29
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.GetChild(nameof(ComplexClass.Member5)).Content.Update(obj[2]);
            Assert.AreEqual(instance.Member5, (List <string>)dynNode.Member5);
            Assert.AreEqual(obj[2], (List <string>)dynNode.Member5);
        }
Esempio n. 30
0
        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.GetChild(nameof(ComplexClass.Member5)).Content.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 TestChangeBoxedPrimitiveMember()
 {
     var nodeContainer = new NodeContainer();
     var instance = new ComplexClass { Member3 = 3 };
     var rootNode = nodeContainer.GetOrCreateNode(instance);
     var listener = new GraphNodeChangeListener(rootNode);
     var node = rootNode.TryGetChild(nameof(ComplexClass.Member3));
     TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, 3, 4, () => node.Content.Update(4));
     TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, 4, 5, () => node.Content.Update(5));
 }
 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 listener = new GraphNodeChangeListener(rootNode);
     var node = rootNode.TryGetChild(nameof(ComplexClass.Member2));
     TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[0], obj[1], () => node.Content.Update(obj[1]));
     TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[1], obj[2], () => node.Content.Update(obj[2]));
 }
Esempio n. 33
0
        public void SerializeComplexClass()
        {
            var complexClass = new ComplexClass<SimpleClass>(Guid.NewGuid());
            complexClass.Values = GenerateSimpleClassList();

            SerializerBuilder.Build(complexClass);

            var result = Serializer.DeepClone(complexClass);

            Assert.AreEqual(complexClass.Key, result.Key);
            Assert.AreEqual(complexClass.Values[100].Id, result.Values[100].Id);
            Assert.AreEqual(complexClass.Values[100].Name, result.Values[100].Name);
        }
Esempio n. 34
0
 public void TestChangePrimitiveMember()
 {
     var nodeContainer = new NodeContainer();
     var instance = new ComplexClass { Member1 = 3 };
     var rootNode = nodeContainer.GetOrCreateNode(instance);
     var dynNode = DynamicNode.FromNode(rootNode);
     Assert.AreEqual(instance.Member1, (int)dynNode.Member1);
     dynNode.Member1 = 4;
     Assert.AreEqual(4, instance.Member1);
     Assert.AreEqual(instance.Member1, (int)dynNode.Member1);
     rootNode.TryGetChild(nameof(ComplexClass.Member1)).Content.Update(5);
     Assert.AreEqual(5, instance.Member1);
     Assert.AreEqual(instance.Member1, (int)dynNode.Member1);
 }
Esempio n. 35
0
 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.TryGetChild(nameof(ComplexClass.Member2)).Content.Update(obj[2]);
     Assert.AreEqual(obj[2], instance.Member2);
     Assert.AreEqual(instance.Member2, (SimpleClass)dynNode.Member2);
 }
Esempio n. 36
0
        public void ComplexTest1()
        {
            var item = new ComplexClass();

            using (IDocumentStore store = NewDocumentStore())
            {
                using (var session = store.OpenSession())
                {
                    session.Store(item);
                    session.SaveChanges();
                }

                using (var session = store.OpenSession())
                {
                    var stored = session.Load<ComplexClass>(1);
                    Assert.NotNull(stored);
                    Assert.Equal("ComplexClasses/1", stored.Id);
                }
            }
        }
Esempio n. 37
0
        public void Complex()
        {
            var rand = new Random();
            var bs = new byte[16];
            rand.NextBytes(bs);

            var a =
                new ComplexClass
                {
                    Key = rand.Next(),
                    Value = Convert.ToBase64String(bs)
                };

            Action closeOver =
                () =>
                {
                    var cs = new byte[16];
                    rand.NextBytes(cs);

                    a.Key = rand.Next();
                    a.Value = Convert.ToBase64String(cs);
                };

            var ops = Sigil.Disassembler<Action>.Disassemble(closeOver);
            var usage = ops.Usage;

            var propAccess =
                usage
                    .Where(w =>
                        (w.ProducesResult.OpCode == OpCodes.Call || w.ProducesResult.OpCode == OpCodes.Callvirt) &&
                        ((MethodInfo)w.ProducesResult.Parameters.ElementAt(0)).DeclaringType == typeof(ComplexClass)
                    ).ToList();

            Assert.AreEqual(2, propAccess.Count);
            Assert.IsFalse(ops.CanEmit);
        }
 public void TestAddReferenceListItem()
 {
     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 listener = new GraphNodeChangeListener(rootNode);
     var node = rootNode.TryGetChild(nameof(ComplexClass.Member6));
     Assert.AreEqual(obj[0], node.Content.Retrieve(new Index(0)));
     TestContentChange(listener, node, ContentChangeType.CollectionAdd, new Index(1), null, obj[1], () => node.Content.Add(obj[1], new Index(1)));
     Assert.AreEqual(obj[1], node.Content.Retrieve(new Index(1)));
     TestContentChange(listener, node, ContentChangeType.CollectionAdd, new Index(2), null, obj[2], () => node.Content.Add(obj[2], new Index(2)));
     Assert.AreEqual(obj[2], node.Content.Retrieve(new Index(2)));
 }
Esempio n. 39
0
 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.TryGetChild(nameof(ComplexClass.Member6)).Content.Remove(obj[2], new Index(1));
     Assert.AreEqual(instance.Member6[0], (SimpleClass)dynNode.Member6[0]);
     Assert.AreEqual(obj[0], (SimpleClass)dynNode.Member6[0]);
 }
Esempio n. 40
0
 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.TryGetChild(nameof(ComplexClass.Member5)).Content.Remove(obj[2], new Index(1));
     Assert.AreEqual(instance.Member5[0], (string)dynNode.Member5[0]);
     Assert.AreEqual(obj[0], (string)dynNode.Member5[0]);
 }
Esempio n. 41
0
 public void TestChangeStructList()
 {
     var nodeContainer = new NodeContainer();
     var obj = new[] { new List<Struct> { new Struct() }, new List<Struct> { new Struct() }, new List<Struct> { new Struct() } };
     var instance = new ComplexClass { Member7 = obj[0] };
     var rootNode = nodeContainer.GetOrCreateNode(instance);
     var dynNode = DynamicNode.FromNode(rootNode);
     Assert.AreEqual(instance.Member7, (List<Struct>)dynNode.Member7);
     Assert.AreEqual(obj[0], (List<Struct>)dynNode.Member7);
     dynNode.Member7 = obj[1];
     Assert.AreEqual(instance.Member7, (List<Struct>)dynNode.Member7);
     Assert.AreEqual(obj[1], (List<Struct>)dynNode.Member7);
     rootNode.TryGetChild(nameof(ComplexClass.Member7)).Content.Update(obj[2]);
     Assert.AreEqual(instance.Member7, (List<Struct>)dynNode.Member7);
     Assert.AreEqual(obj[2], (List<Struct>)dynNode.Member7);
 }
Esempio n. 42
0
 public void TestChangeReferenceListItemMember()
 {
     var nodeContainer = new NodeContainer();
     var obj = new[] { 3, 4, 5 };
     var instance = new ComplexClass { Member6 = new List<SimpleClass> { new SimpleClass(), new SimpleClass { Member1 = obj[0] } } };
     var rootNode = nodeContainer.GetOrCreateNode(instance);
     var dynNode = DynamicNode.FromNode(rootNode);
     Assert.AreEqual(instance.Member6[1].Member1, (int)dynNode.Member6[1].Member1);
     Assert.AreEqual(obj[0], (int)dynNode.Member6[1].Member1);
     dynNode.Member6[1].Member1 = obj[1];
     Assert.AreEqual(obj[1], (int)dynNode.Member6[1].Member1);
     Assert.AreEqual(instance.Member6[1].Member1, (int)dynNode.Member6[1].Member1);
     Index index = new Index(1);
     IGraphNode tempQualifier = rootNode.TryGetChild(nameof(ComplexClass.Member6));
     tempQualifier.IndexedTarget(index).TryGetChild(nameof(SimpleClass.Member1)).Content.Update(obj[2]);
     Assert.AreEqual(obj[2], (int)dynNode.Member6[1].Member1);
     Assert.AreEqual(instance.Member6[1].Member1, (int)dynNode.Member6[1].Member1);
 }
Esempio n. 43
0
 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);
     Index index = new Index(1);
     IGraphNode tempQualifier = rootNode.TryGetChild(nameof(ComplexClass.Member7));
     tempQualifier.IndexedTarget(index).TryGetChild(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);
 }
Esempio n. 44
0
 public void TestRemoveStructListItem()
 {
     var nodeContainer = new NodeContainer();
     var obj = new[] { new Struct { Member1 = "aa" }, new Struct { Member1 = "bb" }, new Struct { Member1 = "cc" } };
     var instance = new ComplexClass { Member7 = new List<Struct> { obj[0], obj[1], obj[2] } };
     var rootNode = nodeContainer.GetOrCreateNode(instance);
     var dynNode = DynamicNode.FromNode(rootNode);
     Assert.AreEqual(instance.Member7[0], (Struct)dynNode.Member7[0]);
     Assert.AreEqual(instance.Member7[1], (Struct)dynNode.Member7[1]);
     Assert.AreEqual(instance.Member7[2], (Struct)dynNode.Member7[2]);
     Assert.AreEqual(obj[0], (Struct)dynNode.Member7[0]);
     Assert.AreEqual(obj[1], (Struct)dynNode.Member7[1]);
     Assert.AreEqual(obj[2], (Struct)dynNode.Member7[2]);
     dynNode.Member7.Remove(obj[1], new Index(1));
     Assert.AreEqual(instance.Member7[0], (Struct)dynNode.Member7[0]);
     Assert.AreEqual(instance.Member7[1], (Struct)dynNode.Member7[1]);
     Assert.AreEqual(obj[0], (Struct)dynNode.Member7[0]);
     Assert.AreEqual(obj[2], (Struct)dynNode.Member7[1]);
     rootNode.TryGetChild(nameof(ComplexClass.Member7)).Content.Remove(obj[2], new Index(1));
     Assert.AreEqual(instance.Member7[0], (Struct)dynNode.Member7[0]);
     Assert.AreEqual(obj[0], (Struct)dynNode.Member7[0]);
 }
Esempio n. 45
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.TryGetChild(nameof(ComplexClass.Member5)).Content.Update(obj[2]);
     Assert.AreEqual(instance.Member5, (List<string>)dynNode.Member5);
     Assert.AreEqual(obj[2], (List<string>)dynNode.Member5);
 }
Esempio n. 46
0
 public void TestChangeStructListItem()
 {
     var nodeContainer = new NodeContainer();
     var obj = new[] { new Struct { Member1 = "aa" }, new Struct { Member1 = "bb" }, new Struct { Member1 = "cc" } };
     var instance = new ComplexClass { Member7 = new List<Struct> { obj[0] } };
     var rootNode = nodeContainer.GetOrCreateNode(instance);
     var listener = new GraphNodeChangeListener(rootNode);
     var node = rootNode.GetChild(nameof(ComplexClass.Member7));
     var path = new GraphNodePath(rootNode).PushMember(nameof(ComplexClass.Member7));
     Assert.AreEqual(obj[0], node.Content.Retrieve(new Index(0)));
     TestContentChange(listener, node, ContentChangeType.ValueChange, new Index(0), obj[0], obj[1], path, () => node.Content.Update(obj[1], new Index(0)));
     Assert.AreEqual(obj[1], node.Content.Retrieve(new Index(0)));
     TestContentChange(listener, node, ContentChangeType.ValueChange, new Index(0), obj[1], obj[2], path, () => node.Content.Update(obj[2], new Index(0)));
     Assert.AreEqual(obj[2], node.Content.Retrieve(new Index(0)));
 }
 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 listener = new GraphNodeChangeListener(rootNode);
     var node = rootNode.TryGetChild(nameof(ComplexClass.Member4));
     Assert.AreEqual("aa", node.TryGetChild(nameof(Struct.Member1)).Content.Retrieve());
     TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[0], obj[1], () => node.Content.Update(obj[1]));
     Assert.AreEqual("bb", node.TryGetChild(nameof(Struct.Member1)).Content.Retrieve());
     TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[1], obj[2], () => node.Content.Update(obj[2]));
     Assert.AreEqual("cc", node.TryGetChild(nameof(Struct.Member1)).Content.Retrieve());
     TestContentChange(listener, node.TryGetChild(nameof(Struct.Member1)), ContentChangeType.ValueChange, Index.Empty, "cc", "dd", () => node.TryGetChild(nameof(Struct.Member1)).Content.Update("dd"));
     Assert.AreEqual("dd", node.TryGetChild(nameof(Struct.Member1)).Content.Retrieve());
 }
 public void TestChangeStructList()
 {
     var nodeContainer = new NodeContainer();
     var obj = new[] { new List<Struct> { new Struct() }, new List<Struct> { new Struct() }, new List<Struct> { new Struct() } };
     var instance = new ComplexClass { Member7 = obj[0] };
     var rootNode = nodeContainer.GetOrCreateNode(instance);
     var listener = new GraphNodeChangeListener(rootNode);
     var node = rootNode.TryGetChild(nameof(ComplexClass.Member7));
     Assert.AreEqual(obj[0][0], node.Content.Retrieve(new Index(0)));
     TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[0], obj[1], () => node.Content.Update(obj[1]));
     Assert.AreEqual(obj[1][0], node.Content.Retrieve(new Index(0)));
     TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[1], obj[2], () => node.Content.Update(obj[2]));
     Assert.AreEqual(obj[2][0], node.Content.Retrieve(new Index(0)));
     var newItem = new Struct();
     TestContentChange(listener, node, ContentChangeType.ValueChange, new Index(0), obj[2][0], newItem, () => node.Content.Update(newItem, new Index(0)));
     Assert.AreEqual(newItem, node.Content.Retrieve(new Index(0)));
 }
 public void TestRemoveStructListItem()
 {
     var nodeContainer = new NodeContainer();
     var obj = new[] { new Struct { Member1 = "aa" }, new Struct { Member1 = "bb" }, new Struct { Member1 = "cc" } };
     var instance = new ComplexClass { Member7 = new List<Struct> { obj[0], obj[1], obj[2] } };
     var rootNode = nodeContainer.GetOrCreateNode(instance);
     var listener = new GraphNodeChangeListener(rootNode);
     var node = rootNode.TryGetChild(nameof(ComplexClass.Member7));
     Assert.AreEqual(obj[0], node.Content.Retrieve(new Index(0)));
     Assert.AreEqual(obj[1], node.Content.Retrieve(new Index(1)));
     Assert.AreEqual(obj[2], node.Content.Retrieve(new Index(2)));
     TestContentChange(listener, node, ContentChangeType.CollectionRemove, new Index(1), obj[1], null, () => node.Content.Remove(obj[1], new Index(1)));
     Assert.AreEqual(obj[0], node.Content.Retrieve(new Index(0)));
     Assert.AreEqual(obj[2], node.Content.Retrieve(new Index(1)));
     TestContentChange(listener, node, ContentChangeType.CollectionRemove, new Index(1), obj[2], null, () => node.Content.Remove(obj[2], new Index(1)));
     Assert.AreEqual(obj[0], node.Content.Retrieve(new Index(0)));
 }
 public void TestDiscardedReferenceMember()
 {
     var nodeContainer = new NodeContainer();
     var obj = new[] { new SimpleClass(), new SimpleClass() };
     var instance = new ComplexClass { Member2 = obj[0] };
     var rootNode = nodeContainer.GetOrCreateNode(instance);
     var obj0Node = nodeContainer.GetOrCreateNode(obj[0]);
     var obj1Node = nodeContainer.GetOrCreateNode(obj[1]);
     var listener = new GraphNodeChangeListener(rootNode);
     int changingCount = 0;
     int changedCount = 0;
     listener.Changing += (sender, e) => ++changingCount;
     listener.Changed += (sender, e) => ++changedCount;
     obj0Node.TryGetChild(nameof(SimpleClass.Member1)).Content.Update(1);
     Assert.AreEqual(1, changingCount);
     Assert.AreEqual(1, changedCount);
     rootNode.TryGetChild(nameof(ComplexClass.Member2)).Content.Update(obj[1]);
     Assert.AreEqual(2, changingCount);
     Assert.AreEqual(2, changedCount);
     obj0Node.TryGetChild(nameof(SimpleClass.Member1)).Content.Update(2);
     Assert.AreEqual(2, changingCount);
     Assert.AreEqual(2, changedCount);
     obj1Node.TryGetChild(nameof(SimpleClass.Member1)).Content.Update(3);
     Assert.AreEqual(3, changingCount);
     Assert.AreEqual(3, changedCount);
 }
 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 listener = new GraphNodeChangeListener(rootNode);
     Index index = new Index(1);
     IGraphNode tempQualifier = rootNode.TryGetChild(nameof(ComplexClass.Member7));
     var node = tempQualifier.IndexedTarget(index).TryGetChild(nameof(SimpleClass.Member1));
     Assert.AreEqual(obj[0], node.Content.Retrieve());
     TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[0], obj[1], () => node.Content.Update(obj[1], Index.Empty));
     Assert.AreEqual(obj[1], node.Content.Retrieve());
     // TODO: would be nice to be able to keep the same boxed node!
     //Assert.AreEqual(node, rootNode.GetChild(nameof(ComplexClass.Member7)).GetTarget(new Index(1)).GetChild(nameof(SimpleClass.Member1)));
     TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[1], obj[2], () => node.Content.Update(obj[2], Index.Empty));
     Assert.AreEqual(obj[2], node.Content.Retrieve());
     //Assert.AreEqual(node, rootNode.GetChild(nameof(ComplexClass.Member7)).GetTarget(new Index(1)).GetChild(nameof(SimpleClass.Member1)));
 }
 public void TestChangeReferenceListItemMember()
 {
     var nodeContainer = new NodeContainer();
     var obj = new[] { 3, 4, 5 };
     var instance = new ComplexClass { Member6 = new List<SimpleClass> { new SimpleClass(), new SimpleClass { Member1 = obj[0] } } };
     var rootNode = nodeContainer.GetOrCreateNode(instance);
     var listener = new GraphNodeChangeListener(rootNode);
     Index index = new Index(1);
     IGraphNode tempQualifier = rootNode.TryGetChild(nameof(ComplexClass.Member6));
     var node = tempQualifier.IndexedTarget(index).TryGetChild(nameof(SimpleClass.Member1));
     Assert.AreEqual(obj[0], node.Content.Retrieve());
     TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[0], obj[1], () => node.Content.Update(obj[1], Index.Empty));
     Assert.AreEqual(obj[1], node.Content.Retrieve());
     TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[1], obj[2], () => node.Content.Update(obj[2], Index.Empty));
     Assert.AreEqual(obj[2], node.Content.Retrieve());
 }
Esempio n. 53
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.TryGetChild(nameof(ComplexClass.Member4)).TryGetChild(nameof(Struct.Member1)).Content.Update(obj[2]);
     Assert.AreEqual(obj[2], (string)dynNode.Member4.Member1);
     Assert.AreEqual(instance.Member4, (Struct)dynNode.Member4);
 }
Esempio n. 54
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 listener = new GraphNodeChangeListener(rootNode);
     var node = rootNode.GetChild(nameof(ComplexClass.Member4)).GetChild(nameof(Struct.Member1));
     var path = new GraphNodePath(rootNode).PushMember(nameof(ComplexClass.Member4)).PushMember(nameof(Struct.Member1));
     TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[0], obj[1], path, () => node.Content.Update(obj[1], Index.Empty));
     Assert.AreEqual(node, rootNode.GetChild(nameof(ComplexClass.Member4)).GetChild(nameof(Struct.Member1)));
     TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[1], obj[2], path, () => node.Content.Update(obj[2], Index.Empty));
     Assert.AreEqual(node, rootNode.GetChild(nameof(ComplexClass.Member4)).GetChild(nameof(Struct.Member1)));
 }
 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 listener = new GraphNodeChangeListener(rootNode);
     var node = rootNode.TryGetChild(nameof(ComplexClass.Member5));
     Assert.AreEqual(obj[0], node.Content.Retrieve(new Index(0)));
     TestContentChange(listener, node, ContentChangeType.ValueChange, new Index(0), obj[0], obj[1], () => node.Content.Update(obj[1], new Index(0)));
     Assert.AreEqual(obj[1], node.Content.Retrieve(new Index(0)));
     TestContentChange(listener, node, ContentChangeType.ValueChange, new Index(0), obj[1], obj[2], () => node.Content.Update(obj[2], new Index(0)));
     Assert.AreEqual(obj[2], node.Content.Retrieve(new Index(0)));
 }
Esempio n. 56
0
 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 listener = new GraphNodeChangeListener(rootNode);
     var node = rootNode.GetChild(nameof(ComplexClass.Member3));
     var path = new GraphNodePath(rootNode).PushMember(nameof(ComplexClass.Member3));
     TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[0], obj[1], path, () => node.Content.Update(obj[1]));
     TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[1], obj[2], path, () => node.Content.Update(obj[2]));
 }
Esempio n. 57
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 listener = new GraphNodeChangeListener(rootNode);
     var node = rootNode.GetChild(nameof(ComplexClass.Member5));
     var path = new GraphNodePath(rootNode).PushMember(nameof(ComplexClass.Member5));
     Assert.AreEqual("aa", node.Content.Retrieve(new Index(0)));
     TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[0], obj[1], path, () => node.Content.Update(obj[1]));
     Assert.AreEqual("bb", node.Content.Retrieve(new Index(0)));
     TestContentChange(listener, node, ContentChangeType.ValueChange, Index.Empty, obj[1], obj[2], path, () => node.Content.Update(obj[2]));
     Assert.AreEqual("cc", node.Content.Retrieve(new Index(0)));
     TestContentChange(listener, node, ContentChangeType.ValueChange, new Index(0), "cc", "dd", path, () => node.Content.Update("dd", new Index(0)));
     Assert.AreEqual("dd", node.Content.Retrieve(new Index(0)));
 }