public void ContentList_UpdateField() { string listDef = @"<?xml version='1.0' encoding='utf-8'?> <ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'> <DisplayName>Cars title</DisplayName> <Description>Cars description</Description> <Icon>automobile.gif</Icon> <Fields> <ContentListField name='#ListField1' type='ShortText'> <DisplayName>ContentListField1</DisplayName> <Description>ContentListField1 Description</Description> <Icon>icon.gif</Icon> <Configuration> <MaxLength>100</MaxLength> </Configuration> </ContentListField> <ContentListField name='#ListField2' type='WhoAndWhen'> <DisplayName>ContentListField2</DisplayName> <Description>ContentListField2 Description</Description> <Icon>icon.gif</Icon> <Configuration> </Configuration> </ContentListField> <ContentListField name='#ListField3' type='ShortText'> <DisplayName>ContentListField3</DisplayName> <Description>ContentListField3 Description</Description> <Icon>icon.gif</Icon> <Configuration> <MaxLength>200</MaxLength> </Configuration> </ContentListField> </Fields> </ContentListDefinition> "; string path = RepositoryPath.Combine(this.TestRoot.Path, "Cars"); if (Node.Exists(path)) { Node.ForceDelete(path); } var list = new ContentList(this.TestRoot) { Name = "Cars", ContentListDefinition = listDef, AllowedChildTypes = new ContentType[] { ContentType.GetByName("Car") } }; list.Save(); Node car = new GenericContent(list, "Car"); car.Name = "Kispolszki"; car["#String_0"] = "ABC 34-78"; car.Save(); var fs = Content.Create(car).Fields["#ListField1"].FieldSetting; fs.DisplayName = "New TITLE"; list.UpdateField(fs); var cc = Content.Load(car.Path); Assert.IsTrue(cc.Fields["#ListField1"].FieldSetting.DisplayName.CompareTo("New TITLE") == 0); }
public void ContentList_UpdateField() { string listDef = @"<?xml version='1.0' encoding='utf-8'?> <ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'> <DisplayName>Cars title</DisplayName> <Description>Cars description</Description> <Icon>automobile.gif</Icon> <Fields> <ContentListField name='#ListField1' type='ShortText'> <DisplayName>ContentListField1</DisplayName> <Description>ContentListField1 Description</Description> <Icon>icon.gif</Icon> <Configuration> <MaxLength>100</MaxLength> </Configuration> </ContentListField> <ContentListField name='#ListField2' type='WhoAndWhen'> <DisplayName>ContentListField2</DisplayName> <Description>ContentListField2 Description</Description> <Icon>icon.gif</Icon> <Configuration> </Configuration> </ContentListField> <ContentListField name='#ListField3' type='ShortText'> <DisplayName>ContentListField3</DisplayName> <Description>ContentListField3 Description</Description> <Icon>icon.gif</Icon> <Configuration> <MaxLength>200</MaxLength> </Configuration> </ContentListField> </Fields> </ContentListDefinition> "; string path = RepositoryPath.Combine(this.TestRoot.Path, "Cars"); if (Node.Exists(path)) Node.ForceDelete(path); var list = new ContentList(this.TestRoot) { Name = "Cars", ContentListDefinition = listDef, AllowedChildTypes = new ContentType[] { ContentType.GetByName("Car") } }; list.Save(); Node car = new GenericContent(list, "Car"); car.Name = "Kispolszki"; car["#String_0"] = "ABC 34-78"; car.Save(); var fs = Content.Create(car).Fields["#ListField1"].FieldSetting; fs.DisplayName = "New TITLE"; list.UpdateField(fs); var cc = Content.Load(car.Path); Assert.IsTrue(cc.Fields["#ListField1"].FieldSetting.DisplayName.CompareTo("New TITLE") == 0); }