Save() public method

public Save ( ) : void
return void
Example #1
0
        public void ContentList_FieldNameCannotContainsADot()
        {
            string path = RepositoryPath.Combine(this._testRoot.Path, "Cars");
            if (Node.Exists(path))
                Node.ForceDelete(path);

            //---- valid
            string listTypeDef = @"<ContentListDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentListDefinition'>
	<Fields><ContentListField name='#Valid_Field_Name' type='ShortText'/></Fields>
</ContentListDefinition>
";
            var list = new ContentList(this._testRoot);
            list.Name = "Cars";
            list.ContentListDefinition = listTypeDef;
            list.Save();

            var validIsExist = Node.LoadNode(path) != null;
            if (validIsExist)
                Node.ForceDelete(path);
            Assert.IsTrue(validIsExist, "#1");

            //---- invalid
            listTypeDef = @"<ContentType name=""Valid_ContentType_Namee"" parentType=""GenericContent"" handler=""SenseNet.ContentRepository.GenericContent"" xmlns=""http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition"">
    <Fields><Field name=""Invalid.Field.Name"" type=""ShortText"" /></Fields>
</ContentType>";
            bool exceptionIsThrown = false;
            bool validExceptionIsThrown = false;
            try
            {
                list = new ContentList(this._testRoot);
                list.Name = "Cars";
                list.ContentListDefinition = listTypeDef;
                list.Save();
                exceptionIsThrown = false;
            }
            catch (ContentRegistrationException e)
            {
                exceptionIsThrown = true;
                validExceptionIsThrown = true;
            }
            catch (Exception e)
            {
                exceptionIsThrown = true;
            }
            var invalidIsExist = Node.LoadNode(path) != null;
            if (invalidIsExist)
                Node.ForceDelete(path);
            Assert.IsTrue(exceptionIsThrown, "#2");
            Assert.IsTrue(validExceptionIsThrown, "#3");
            Assert.IsFalse(invalidIsExist, "#4");
        }