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