public void TestReferenceListRemove() { var instance = new Types.ClassWithRefCollection { String = "aaa", List = { new Types.SimpleType { String = "bbb" }, new Types.SimpleType{ String = "ccc" }, new Types.SimpleType{ String = "ddd" }, new Types.SimpleType{ String = "eee" }, new Types.SimpleType{ String = "fff" }, } }; var context = BuildContext(instance); var presenter = context.Factory.CreateNodeHierarchy(context.RootNode, new GraphNodePath(context.RootNode)); presenter.Children[1].RemoveItem(instance.List[4], new Index(4)); Assert.Equal(typeof(List <Types.SimpleType>), presenter.Children[1].Type); Assert.Equal(4, presenter.Children[1].Children.Count); Assert.Equal(instance.List, presenter.Children[1].Value); Assert.Equal("0", presenter.Children[1].Children[0].Name); Assert.Equal("1", presenter.Children[1].Children[1].Name); Assert.Equal("bbb", presenter.Children[1].Children[0].Children[0].Value); Assert.Equal("ccc", presenter.Children[1].Children[1].Children[0].Value); Assert.Equal("ddd", presenter.Children[1].Children[2].Children[0].Value); Assert.Equal("eee", presenter.Children[1].Children[3].Children[0].Value); Assert.Equal(typeof(Types.SimpleType), presenter.Children[1].Children[0].Type); Assert.Equal(typeof(Types.SimpleType), presenter.Children[1].Children[1].Type); Assert.Equal(typeof(Types.SimpleType), presenter.Children[1].Children[2].Type); Assert.Equal(typeof(Types.SimpleType), presenter.Children[1].Children[3].Type); Assert.Equal(typeof(string), presenter.Children[1].Children[0].Children[0].Type); Assert.Equal(typeof(string), presenter.Children[1].Children[1].Children[0].Type); Assert.Equal(typeof(string), presenter.Children[1].Children[2].Children[0].Type); Assert.Equal(typeof(string), presenter.Children[1].Children[3].Children[0].Type); Assert.Equal(instance.List[0], presenter.Children[1].Children[0].Value); Assert.Equal(instance.List[1], presenter.Children[1].Children[1].Value); Assert.Equal(instance.List[2], presenter.Children[1].Children[2].Value); Assert.Equal(instance.List[3], presenter.Children[1].Children[3].Value); presenter.Children[1].RemoveItem("bbb", new Index(0)); Assert.Equal(typeof(List <Types.SimpleType>), presenter.Children[1].Type); Assert.Equal(3, presenter.Children[1].Children.Count); Assert.Equal(instance.List, presenter.Children[1].Value); Assert.Equal("0", presenter.Children[1].Children[0].Name); Assert.Equal("1", presenter.Children[1].Children[1].Name); Assert.Equal("2", presenter.Children[1].Children[2].Name); Assert.Equal("ccc", presenter.Children[1].Children[0].Children[0].Value); Assert.Equal("ddd", presenter.Children[1].Children[1].Children[0].Value); Assert.Equal("eee", presenter.Children[1].Children[2].Children[0].Value); Assert.Equal(typeof(Types.SimpleType), presenter.Children[1].Children[0].Type); Assert.Equal(typeof(Types.SimpleType), presenter.Children[1].Children[1].Type); Assert.Equal(typeof(Types.SimpleType), presenter.Children[1].Children[2].Type); Assert.Equal(typeof(string), presenter.Children[1].Children[0].Children[0].Type); Assert.Equal(typeof(string), presenter.Children[1].Children[1].Children[0].Type); Assert.Equal(typeof(string), presenter.Children[1].Children[2].Children[0].Type); Assert.Equal(instance.List[0], presenter.Children[1].Children[0].Value); Assert.Equal(instance.List[1], presenter.Children[1].Children[1].Value); Assert.Equal(instance.List[2], presenter.Children[1].Children[2].Value); presenter.Children[1].RemoveItem("ddd", new Index(1)); Assert.Equal(typeof(List <Types.SimpleType>), presenter.Children[1].Type); Assert.Equal(2, presenter.Children[1].Children.Count); Assert.Equal(instance.List, presenter.Children[1].Value); Assert.Equal("0", presenter.Children[1].Children[0].Name); Assert.Equal("1", presenter.Children[1].Children[1].Name); Assert.Equal("ccc", presenter.Children[1].Children[0].Children[0].Value); Assert.Equal("eee", presenter.Children[1].Children[1].Children[0].Value); Assert.Equal(typeof(Types.SimpleType), presenter.Children[1].Children[0].Type); Assert.Equal(typeof(Types.SimpleType), presenter.Children[1].Children[1].Type); Assert.Equal(typeof(string), presenter.Children[1].Children[0].Children[0].Type); Assert.Equal(typeof(string), presenter.Children[1].Children[1].Children[0].Type); Assert.Equal(instance.List[0], presenter.Children[1].Children[0].Value); Assert.Equal(instance.List[1], presenter.Children[1].Children[1].Value); presenter.Children[1].RemoveItem("eee", new Index(1)); Assert.Equal(typeof(List <Types.SimpleType>), presenter.Children[1].Type); Assert.Equal(1, presenter.Children[1].Children.Count); Assert.Equal(instance.List, presenter.Children[1].Value); Assert.Equal("0", presenter.Children[1].Children[0].Name); Assert.Equal("ccc", presenter.Children[1].Children[0].Children[0].Value); Assert.Equal(typeof(Types.SimpleType), presenter.Children[1].Children[0].Type); Assert.Equal(typeof(string), presenter.Children[1].Children[0].Children[0].Type); Assert.Equal(instance.List[0], presenter.Children[1].Children[0].Value); presenter.Children[1].RemoveItem("ccc", new Index(0)); Assert.Equal(typeof(List <Types.SimpleType>), presenter.Children[1].Type); Assert.Equal(0, presenter.Children[1].Children.Count); Assert.Equal(instance.List, presenter.Children[1].Value); }
public void TestReferenceListUpdate() { var instance = new Types.ClassWithRefCollection { String = "aaa", List = { new Types.SimpleType { String = "bbb" }, new Types.SimpleType{ String = "ccc" } } }; var context = BuildContext(instance); var presenter = context.Factory.CreateNodeHierarchy(context.RootNode, new GraphNodePath(context.RootNode)); presenter[nameof(Types.ClassWithRefCollection.List)].Children[1].UpdateValue(new Types.SimpleType { String = "ddd" }); Assert.Equal(typeof(List <Types.SimpleType>), presenter.Children[1].Type); Assert.Equal(instance.List, presenter.Children[1].Value); Assert.Equal(2, presenter.Children[1].Children.Count); Assert.Equal("0", presenter.Children[1].Children[0].Name); Assert.Equal("1", presenter.Children[1].Children[1].Name); Assert.Equal("bbb", presenter.Children[1].Children[0].Children[0].Value); Assert.Equal("ddd", presenter.Children[1].Children[1].Children[0].Value); Assert.Equal(typeof(Types.SimpleType), presenter.Children[1].Children[0].Type); Assert.Equal(typeof(Types.SimpleType), presenter.Children[1].Children[1].Type); Assert.Equal(typeof(string), presenter.Children[1].Children[0].Children[0].Type); Assert.Equal(typeof(string), presenter.Children[1].Children[1].Children[0].Type); Assert.Equal(instance.List[0], presenter.Children[1].Children[0].Value); Assert.Equal(instance.List[1], presenter.Children[1].Children[1].Value); presenter[nameof(Types.ClassWithRefCollection.List)].Children[1].UpdateValue(new Types.SimpleType { String = "eee" }); Assert.Equal(typeof(List <Types.SimpleType>), presenter.Children[1].Type); Assert.Equal(instance.List, presenter.Children[1].Value); Assert.Equal(2, presenter.Children[1].Children.Count); Assert.Equal("0", presenter.Children[1].Children[0].Name); Assert.Equal("1", presenter.Children[1].Children[1].Name); Assert.Equal("bbb", presenter.Children[1].Children[0].Children[0].Value); Assert.Equal("eee", presenter.Children[1].Children[1].Children[0].Value); Assert.Equal(typeof(Types.SimpleType), presenter.Children[1].Children[0].Type); Assert.Equal(typeof(Types.SimpleType), presenter.Children[1].Children[1].Type); Assert.Equal(typeof(string), presenter.Children[1].Children[0].Children[0].Type); Assert.Equal(typeof(string), presenter.Children[1].Children[1].Children[0].Type); Assert.Equal(instance.List[0], presenter.Children[1].Children[0].Value); Assert.Equal(instance.List[1], presenter.Children[1].Children[1].Value); presenter[nameof(Types.ClassWithRefCollection.List)].Children[0].UpdateValue(new Types.SimpleType { String = "fff" }); Assert.Equal(typeof(List <Types.SimpleType>), presenter.Children[1].Type); Assert.Equal(instance.List, presenter.Children[1].Value); Assert.Equal(2, presenter.Children[1].Children.Count); Assert.Equal("0", presenter.Children[1].Children[0].Name); Assert.Equal("1", presenter.Children[1].Children[1].Name); Assert.Equal("fff", presenter.Children[1].Children[0].Children[0].Value); Assert.Equal("eee", presenter.Children[1].Children[1].Children[0].Value); Assert.Equal(typeof(Types.SimpleType), presenter.Children[1].Children[0].Type); Assert.Equal(typeof(Types.SimpleType), presenter.Children[1].Children[1].Type); Assert.Equal(typeof(string), presenter.Children[1].Children[0].Children[0].Type); Assert.Equal(typeof(string), presenter.Children[1].Children[1].Children[0].Type); Assert.Equal(instance.List[0], presenter.Children[1].Children[0].Value); Assert.Equal(instance.List[1], presenter.Children[1].Children[1].Value); }