private CheckFieldResult CheckField(string contentTypeName, string fieldName, string fieldType) { var result = CheckFieldResult.NoError; try { ContentTypeInstaller.InstallContentType($@"<?xml version='1.0' encoding='utf-8'?> <ContentType name='{contentTypeName}' parentType='GenericContent' handler='{typeof(GenericContent).FullName}' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'> <Fields> <Field name='{fieldName}' type='{fieldType}'/> </Fields> </ContentType> "); } catch (Exception e) { result = CheckFieldResult.CtdError; } var contentType = ContentType.GetByName(contentTypeName); if (contentType != null) { ContentTypeInstaller.RemoveContentType(contentTypeName); } return(result); }
public void CrossDomain_ContentType_InstallAndRemove() { DistributedApplication.ClusterChannel.Purge(); if (ContentType.GetByName("CrossTestType") != null) { ContentTypeInstaller.RemoveContentType("CrossTestType"); } var a = AllEngine_GetContentTypeCount(); ContentTypeInstaller.InstallContentType(@"<?xml version='1.0' encoding='utf-8'?> <ContentType name='CrossTestType' parentType='GenericContent' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'> </ContentType>" ); var b = AllEngine_GetContentTypeCount(); ContentTypeInstaller.RemoveContentType("CrossTestType"); var c = AllEngine_GetContentTypeCount(); DistributedApplication.ClusterChannel.Purge(); Assert.IsTrue(a.Distinct().Count <int>() == 1, "#1"); Assert.IsTrue(b.Distinct().Count <int>() == 1, "#2"); Assert.IsTrue(c.Distinct().Count <int>() == 1, "#3"); Assert.IsTrue(a[0] == b[0] - 1, "#4"); Assert.IsTrue(a[0] == c[0], "#5"); }
public static void DestroyPlayground() { try { if (Node.Exists(_testRootPath)) { Node.ForceDelete(_testRootPath); } if (ActiveSchema.NodeTypes["TestNode11"] != null) { ContentTypeInstaller.RemoveContentType(ContentType.GetByName("TestNode11")); } if (ActiveSchema.NodeTypes["TestNode10"] != null) { ContentTypeInstaller.RemoveContentType(ContentType.GetByName("TestNode10")); } ContentType ct; ct = ContentType.GetByName("TestNode11"); if (ct != null) { ContentTypeInstaller.RemoveContentType(ct); } ct = ContentType.GetByName("TestNode10"); if (ct != null) { ContentTypeInstaller.RemoveContentType(ct); } ct = ContentType.GetByName("DataTypeCollisionTestHandler1"); if (ct != null) { ContentTypeInstaller.RemoveContentType(ct); } ct = ContentType.GetByName("DataTypeCollisionTestHandler"); if (ct != null) { ContentTypeInstaller.RemoveContentType(ct); } ct = ContentType.GetByName("TestSurvey"); if (ct != null) { ContentTypeInstaller.RemoveContentType(ct); } ct = ContentType.GetByName("ForMultiPagingSearch"); if (ct != null) { ContentTypeInstaller.RemoveContentType(ct); } } catch (Exception e) { //throw; } }
public override void Execute(ExecutionContext context) { var names = ResolveVariable(Name, context); context.AssertRepositoryStarted(); using (new SystemAccount()) { var rootTypeNames = GetRootTypeNames(names); var rootTypeNamesText = string.Join(", ", rootTypeNames); var plural = rootTypeNames.Length > 1; if (!rootTypeNames.Any()) { Logger.LogMessage("There is no content type to delete."); return; } var dependencies = GetDependencies(rootTypeNames); Logger.LogMessage($"DELETING CONTENT TYPE{(plural ? "S" : "")}: " + rootTypeNamesText); PrintDependencies(dependencies); if (Delete == Mode.No) { Logger.LogMessage($"The content type{(plural ? "s are" : " is")} not removed, this step provides only information."); return; } if (Delete == Mode.IfNotUsed) { if (dependencies.HasDependency) { var deps = dependencies.InheritedTypeNames.Length + dependencies.InstanceCount; Logger.LogMessage($"The content type{(plural ? "s were" : " was")} not removed because it have {deps} dependenc{(deps < 2 ? "y" : "ies")}."); return; } Logger.LogMessage($"The content type{(plural ? "s have" : " has")} no any dependencies."); } if (dependencies.InstanceCount > 0) { DeleteInstances(rootTypeNames); } DeleteRelatedItems(dependencies); RemoveAllowedTypes(dependencies); foreach (var rootTypeName in rootTypeNames) { ContentTypeInstaller.RemoveContentType(rootTypeName); } Logger.LogMessage($"The content type{(plural ? "s are" : " is")} successfuly removed."); } }
public static void DestroyPlayground() { if (Node.Exists(_testRootPath)) { Node.ForceDelete(_testRootPath); } if (ActiveSchema.NodeTypes["RepositoryTest_TestNodeWithBinaryProperty"] != null) { ContentTypeInstaller.RemoveContentType(ContentType.GetByName("RepositoryTest_TestNodeWithBinaryProperty")); } }
public static void DestroyPlayGround() { if (Node.Exists(__testRootPath)) { Node.ForceDelete(__testRootPath); } if (ActiveSchema.NodeTypes[EventTestNode.DefaultNodeTypeName] != null) { ContentTypeInstaller.RemoveContentType(ContentType.GetByName(EventTestNode.DefaultNodeTypeName)); } }
public override void Execute(ExecutionContext context) { var name = ResolveVariable(Name, context); context.AssertRepositoryStarted(); using (new SystemAccount()) { var currentContentType = ContentType.GetByName(name); if (null == currentContentType) { Logger.LogMessage("Content type is already deleted: " + name); return; } var dependencies = GetDependencies(currentContentType); Logger.LogMessage("DELETING CONTENT TYPE: " + name); PrintDependencies(dependencies); if (Delete == Mode.No) { Logger.LogMessage($"The {name} content type is not removed, this step provides only information."); return; } if (Delete == Mode.IfNotUsed) { if (dependencies.HasDependency) { var deps = dependencies.InheritedTypeNames.Length + dependencies.InstanceCount; Logger.LogMessage($"The {name} content type was not removed because it has {deps} dependenc{(deps < 2 ? "y" : "ies")}."); return; } Logger.LogMessage($"The {name} content type has no depencencies."); } if (dependencies.InstanceCount > 0) { DeleteInstances(name); } DeleteRelatedItems(dependencies); RemoveAllowedTypes(dependencies); ContentTypeInstaller.RemoveContentType(name); Logger.LogMessage($"The {name} content type removed successfully."); } }
public static void DestroyPlayground() { if (Node.Exists(_testRootPath)) { Node.ForceDelete(_testRootPath); } if (ContentType_Car1 != null) { ContentTypeInstaller.RemoveContentType(ContentType_Car1); } if (ContentType_Car2 != null) { ContentTypeInstaller.RemoveContentType(ContentType_Car2); } }
public static void DestroyPlayground() { if (Node.Exists(_testRootPath)) { Node.ForceDelete(_testRootPath); } ContentType ct; ct = ContentType.GetByName("TestNode11"); if (ct != null) { ContentTypeInstaller.RemoveContentType(ct); } }
public void ContentType_FullInstall_DataTypeCollision_Inherited() { var ct = ContentType.GetByName("DataTypeCollisionTestHandler"); if (ct != null) { ContentTypeInstaller.RemoveContentType(ct); } string ctd1 = @"<?xml version='1.0' encoding='utf-8'?> <ContentType name='DataTypeCollisionTestHandler' parentType='GenericContent' handler='SenseNet.ContentRepository.Tests.ContentHandlers.DataTypeCollisionTestHandler' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'> <Fields> <Field name='TestString' type='ShortText'> <Bind property='TestString' /> </Field> </Fields> </ContentType>" ; string ctd2 = @"<?xml version='1.0' encoding='utf-8'?> <ContentType name='DataTypeCollisionTestHandler1' parentType='DataTypeCollisionTestHandler' handler='SenseNet.ContentRepository.Tests.ContentHandlers.DataTypeCollisionTestHandler' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'> <Fields> <Field name='TestString' type='LongText'> <Bind property='TestString' /> </Field> </Fields> </ContentType>" ; ContentTypeInstaller installer = ContentTypeInstaller.CreateBatchContentTypeInstaller(); installer.AddContentType(ctd2); installer.AddContentType(ctd1); var thrown = false; try { installer.ExecuteBatch(); } catch (RegistrationException) { thrown = true; } catch (ContentRegistrationException) { thrown = true; } Assert.IsTrue(thrown); }
public void SupportDynamicProperties_2() { ContentTypeInstaller.InstallContentType(@"<ContentType name='Class2' parentType='GenericContent' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'><Fields /></ContentType>"); try { var handler = new Class2(TestRoot); Content content; handler.IsStartupMode = false; handler.IsRuntimeMode = false; content = Content.Create(handler); Assert.IsFalse(content.Fields.ContainsKey("RuntimeProperty"), "#1"); Assert.IsFalse(content.Fields.ContainsKey("StartupProperty"), "#2"); handler.IsStartupMode = false; handler.IsRuntimeMode = true; content = Content.Create(handler); Assert.IsFalse(content.Fields.ContainsKey("StartupProperty"), "#3"); Assert.IsTrue(content.Fields.ContainsKey("RuntimeProperty"), "#4"); handler.IsStartupMode = true; handler.IsRuntimeMode = false; content = Content.Create(handler); Assert.IsTrue(content.Fields.ContainsKey("StartupProperty"), "#5"); Assert.IsFalse(content.Fields.ContainsKey("RuntimeProperty"), "#6"); handler.IsStartupMode = true; handler.IsRuntimeMode = true; content = Content.Create(handler); Assert.IsTrue(content.Fields.ContainsKey("StartupProperty"), "#7"); Assert.IsTrue(content.Fields.ContainsKey("RuntimeProperty"), "#8"); } finally { ContentTypeInstaller.RemoveContentType("Class2"); } }
public static void DestroyPlayground() { if (Node.Exists(_testRootPath)) { Node.ForceDelete(_testRootPath); } ContentType ct; ct = ContentType.GetByName(typeof(WaitForMultipleContentWorkflow).Name); if (ct != null) { ContentTypeInstaller.RemoveContentType(ct); } ct = ContentType.GetByName(typeof(WaitForMultipleTasksWorkflow).Name); if (ct != null) { ContentTypeInstaller.RemoveContentType(ct); } ct = ContentType.GetByName(typeof(DelayTestWorkflow).Name); if (ct != null) { ContentTypeInstaller.RemoveContentType(ct); } }
public void Aspect_AddingAspectDoesNotResetDefaultValuesOfTheOriginalFields() { Test(() => { var testRoot = CreateTestRoot(); var contentTypeName = "Aspect_AddingAspectDoesNotResetDefaultValuesOfTheOriginalFields"; var shortTextFieldName = "ShortText"; var displayName2Name = "DisplayName2"; var int32FieldName = "Int32"; var referenceFieldName = "GeneralReference"; var shortText2FieldName = "ShortText2"; var shortTextDefault = "Forty four"; var displayName2Default = "Friendly name"; var int32Default = 42; var referenceDefault = "/Root,/Root/IMS"; ContentTypeInstaller.InstallContentType(@"<?xml version='1.0' encoding='utf-8'?> <ContentType name='" + contentTypeName + @"' parentType='GenericContent' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'> <DisplayName>AddAspectAndFieldDefaultValueTest</DisplayName> <Description>AddAspectAndFieldDefaultValueTest</Description> <Fields> <Field name='" + shortTextFieldName + @"' type='ShortText'> <Configuration> <Compulsory>true</Compulsory> <DefaultValue>" + shortTextDefault + @"</DefaultValue> </Configuration> </Field> <Field name='" + int32FieldName + @"' type='Integer'> <Configuration> <Compulsory>true</Compulsory> <DefaultValue>" + int32Default + @"</DefaultValue> </Configuration> </Field> <Field name='" + referenceFieldName + @"' type='Reference'> <Configuration> <Compulsory>true</Compulsory> <AllowMultiple>true</AllowMultiple> <Compulsory>false</Compulsory> <DefaultValue>" + referenceDefault + @"</DefaultValue> </Configuration> </Field> <Field name='" + displayName2Name + @"' type='ShortText'> <Bind property='HiddenField'/> <Configuration> <Compulsory>true</Compulsory> <DefaultValue>" + displayName2Default + @"</DefaultValue> </Configuration> </Field> <Field name='" + shortText2FieldName + @"' type='ShortText' /> </Fields> </ContentType>"); var aspect1Name = contentTypeName + "_Aspect1"; var aspect2Name = contentTypeName + "_Aspect2"; var aspect3Name = contentTypeName + "_Aspect3"; var aspectShortTextFieldName = aspect1Name + ".ShortText"; var aspectDisplayName2FieldName = aspect1Name + ".DisplayName2"; var aspectInt32FieldName = aspect2Name + ".Int32"; var aspectReferenceFieldName = aspect3Name + ".GeneralReference"; var aspect1 = EnsureAspect(aspect1Name); aspect1.AspectDefinition = @"<AspectDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/AspectDefinition'> <Fields> <AspectField name='" + shortTextFieldName + @"' type='ShortText'> <Configuration> <Compulsory>true</Compulsory> <DefaultValue>" + shortTextDefault + @"</DefaultValue> </Configuration> </AspectField> <AspectField name='" + displayName2Name + @"' type='ShortText'> <Bind property='HiddenField'/> <Configuration> <Compulsory>true</Compulsory> <DefaultValue>" + displayName2Default + @"</DefaultValue> </Configuration> </AspectField> </Fields> </AspectDefinition>"; aspect1.Save(); var aspect2 = EnsureAspect(aspect2Name); aspect2.AspectDefinition = @"<AspectDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/AspectDefinition'> <Fields> <AspectField name='" + int32FieldName + @"' type='Integer'> <Configuration> <Compulsory>true</Compulsory> <DefaultValue>" + int32Default + @"</DefaultValue> </Configuration> </AspectField> </Fields> </AspectDefinition>"; aspect2.Save(); var aspect3 = EnsureAspect(aspect3Name); aspect3.AspectDefinition = @"<AspectDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/AspectDefinition'> <Fields> <AspectField name='" + referenceFieldName + @"' type='Reference'> <Configuration> <Compulsory>true</Compulsory> <AllowMultiple>true</AllowMultiple> <Compulsory>false</Compulsory> <DefaultValue>" + referenceDefault + @"</DefaultValue> </Configuration> </AspectField> </Fields> </AspectDefinition>"; aspect3.Save(); Content content = null; try { // #1 check not saved content = Content.CreateNew(contentTypeName, testRoot, Guid.NewGuid().ToString()); Assert.AreEqual(shortTextDefault, content[shortTextFieldName]); Assert.AreEqual(null, content[shortText2FieldName]); Assert.AreEqual(null, content[displayName2Name]); Assert.AreEqual(int32Default, content[int32FieldName]); Assert.AreEqual(referenceDefault, String.Join(",", ((IEnumerable <Node>)content[referenceFieldName]).Select(n => n.Path))); content.Save(); var contentId = content.Id; // #2 check reloaded content = Content.Load(contentId); Assert.AreEqual(shortTextDefault, content[shortTextFieldName]); Assert.AreEqual(null, content[shortText2FieldName]); Assert.AreEqual(null, content[displayName2Name]); Assert.AreEqual(int32Default, content[int32FieldName]); Assert.AreEqual(referenceDefault, String.Join(",", ((IEnumerable <Node>)content[referenceFieldName]).Select(n => n.Path))); // #3 add aspect1 and aspect2 with separated instruction without save content.AddAspects(aspect1); content.AddAspects(aspect2); // #4 check with 2 aspects / not saved Assert.AreEqual(shortTextDefault, content[shortTextFieldName]); Assert.AreEqual(null, content[shortText2FieldName]); Assert.AreEqual(null, content[displayName2Name]); Assert.AreEqual(int32Default, content[int32FieldName]); Assert.AreEqual(referenceDefault, String.Join(",", ((IEnumerable <Node>)content[referenceFieldName]).Select(n => n.Path))); Assert.AreEqual(shortTextDefault, content[aspectShortTextFieldName]); Assert.AreEqual(null, content[aspectDisplayName2FieldName]); Assert.AreEqual(int32Default, content[aspectInt32FieldName]); content.Save(); // #5 check with 2 aspects / reloaded content = Content.Load(contentId); Assert.AreEqual(shortTextDefault, content[shortTextFieldName]); Assert.AreEqual(null, content[displayName2Name]); Assert.AreEqual(null, content[shortText2FieldName]); Assert.AreEqual(int32Default, content[int32FieldName]); Assert.AreEqual(referenceDefault, String.Join(",", ((IEnumerable <Node>)content[referenceFieldName]).Select(n => n.Path))); Assert.AreEqual(shortTextDefault, content[aspectShortTextFieldName]); Assert.AreEqual(null, content[aspectDisplayName2FieldName]); Assert.AreEqual(int32Default, content[aspectInt32FieldName]); // #6 add aspect3 without save content.AddAspects(aspect3); // #7 check with all aspects / not saved Assert.AreEqual(shortTextDefault, content[shortTextFieldName]); Assert.AreEqual(null, content[displayName2Name]); Assert.AreEqual(null, content[shortText2FieldName]); Assert.AreEqual(int32Default, content[int32FieldName]); Assert.AreEqual(referenceDefault, String.Join(",", ((IEnumerable <Node>)content[referenceFieldName]).Select(n => n.Path))); Assert.AreEqual(shortTextDefault, content[aspectShortTextFieldName]); Assert.AreEqual(null, content[aspectDisplayName2FieldName]); Assert.AreEqual(int32Default, content[aspectInt32FieldName]); Assert.AreEqual(referenceDefault, String.Join(",", ((IEnumerable <Node>)content[aspectReferenceFieldName]).Select(n => n.Path))); content.Save(); // #8 check with all aspects / reloaded content = Content.Load(contentId); Assert.AreEqual(shortTextDefault, content[shortTextFieldName]); Assert.AreEqual(null, content[displayName2Name]); Assert.AreEqual(null, content[shortText2FieldName]); Assert.AreEqual(int32Default, content[int32FieldName]); Assert.AreEqual(referenceDefault, String.Join(",", ((IEnumerable <Node>)content[referenceFieldName]).Select(n => n.Path))); Assert.AreEqual(shortTextDefault, content[aspectShortTextFieldName]); Assert.AreEqual(null, content[aspectDisplayName2FieldName]); Assert.AreEqual(int32Default, content[aspectInt32FieldName]); Assert.AreEqual(referenceDefault, String.Join(",", ((IEnumerable <Node>)content[aspectReferenceFieldName]).Select(n => n.Path))); } finally { content.ForceDelete(); if (ContentType.GetByName(contentTypeName) != null) { ContentTypeInstaller.RemoveContentType(contentTypeName); } } }); }
public static void DestroySandbox() { Node.ForceDelete(_testRootPath); ContentTypeInstaller.RemoveContentType("TestRepositoryEventHandlerNode"); ContentTypeInstaller.RemoveContentType("TestRepositoryCancelEventHandlerNode"); }
public void Indexing_RecoverStoredField() { var ctdTemplate = @"<?xml version='1.0' encoding='utf-8'?> <ContentType name='{0}' parentType='GenericContent' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'> <Fields> <Field name='BodyColorIndexingTests' type='Color'> <Indexing> {2} <IndexHandler>{1}</IndexHandler> </Indexing> </Field> </Fields> </ContentType>"; var ctdCleanTemplate = @"<?xml version='1.0' encoding='utf-8'?> <ContentType name='{0}' parentType='GenericContent' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'> </ContentType>"; var typeName = "TypeForIndexingTest"; var fieldHandlerName = typeof(ColorWithNameIndexHandler).FullName; Content content = null; ContentTypeInstaller.InstallContentType(String.Format(ctdTemplate, typeName, fieldHandlerName, "<Store>No</Store>")); var contentType = ContentType.GetByName(typeName); //-- typesystem load back var query = LucQuery.Parse("BodyColorIndexingTests:Red"); try { //-- without storing: there is query result but there is not value to recover content = Content.CreateNew(typeName, TestRoot, "car"); content["BodyColorIndexingTests"] = Color.Red; content.Save(); var doc = query.Execute().FirstOrDefault(); Assert.IsNotNull(doc, "Query result document is null"); Assert.IsTrue(!doc.Names.Contains("BodyColorIndexingTests"), "Document has BodyColorIndexingTests field."); //-- clean content.ForceDelete(); ContentTypeInstaller.InstallContentType(String.Format(ctdCleanTemplate, typeName)); contentType = ContentType.GetByName(typeName); //-- typesystem load back //-- with storing: there are query result and value to recover ContentTypeInstaller.InstallContentType(String.Format(ctdTemplate, typeName, fieldHandlerName, "<Store>Yes</Store>")); content = Content.CreateNew(typeName, TestRoot, "car"); content["BodyColorIndexingTests"] = Color.Red; content.Save(); doc = query.Execute().FirstOrDefault(); Assert.IsNotNull(doc, "Query result document is null"); var fieldValueColor = doc.Get <Color>("BodyColorIndexingTests"); var fieldValueObject = doc.Get("BodyColorIndexingTests"); Assert.IsTrue(SenseNet.ContentRepository.Fields.ColorField.ColorToString(fieldValueColor) == SenseNet.ContentRepository.Fields.ColorField.ColorToString(Color.Red), "Colors are not equal."); } finally { if (content != null) { content.ForceDelete(); } ContentTypeInstaller.RemoveContentType(typeName); } }
public void SupportDynamicProperties_1() { ContentTypeInstaller.InstallContentType(@"<ContentType name='Class2' parentType='GenericContent' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'><Fields /></ContentType>"); //-- Checks the contettype and indexing subsystem usability. Do not remove! var x = SenseNet.Search.ContentQuery.Query("Name:*admin* .SORT:Id .TOP:100"); string contentString1before = null; int contentInteger1before = 0; string contentString2before = null; int contentInteger2before = 0; DataType contentEnumBefore = DataType.Binary; string handlerString1after = null; int handlerInteger1after = 0; DataType handlerEnumAfter = DataType.Binary; string handlerString2after = null; int handlerInteger2after = 0; try { var handler = new Class2(TestRoot); handler.DynamicString = "Startup value"; handler.DynamicInteger = 12; handler.SetProperty("VeryDynamicString", "Initial"); handler.SetProperty("VeryDynamicInteger", 34); handler.RepoDataType = DataType.Int; var content = Content.Create(handler); contentString1before = (string)content["DynamicString"]; contentInteger1before = (int)content["DynamicInteger"]; contentEnumBefore = (DataType)Enum.Parse(typeof(DataType), ((List <string>)content["RepoDataType"])[0]); contentString2before = (string)content["VeryDynamicString"]; contentInteger2before = (int)content["VeryDynamicInteger"]; content["DynamicString"] = "New value"; content["DynamicInteger"] = 98; content["RepoDataType"] = new List <string>(new string[] { ((int)DataType.DateTime).ToString() }); content["VeryDynamicString"] = "Modified"; content["VeryDynamicInteger"] = 76; content.Save(); handlerString1after = handler.DynamicString; handlerInteger1after = handler.DynamicInteger; handlerEnumAfter = handler.RepoDataType; handlerString2after = (string)handler.PropertyBag["VeryDynamicString"]; handlerInteger2after = (int)handler.PropertyBag["VeryDynamicInteger"]; } finally { ContentTypeInstaller.RemoveContentType("Class2"); } Assert.IsTrue(contentString1before == "Startup value", "#1"); Assert.IsTrue(contentInteger1before == 12, "#2"); Assert.IsTrue(contentEnumBefore == DataType.Int, "#3"); Assert.IsTrue(contentString2before == "Initial", "#4"); Assert.IsTrue(contentInteger2before == 34, "#5"); Assert.IsTrue(handlerString1after == "New value", "#6"); Assert.IsTrue(handlerInteger1after == 98, "#7"); Assert.IsTrue(handlerEnumAfter == DataType.DateTime, "#8"); Assert.IsTrue(handlerString2after == "Modified", "#9"); Assert.IsTrue(handlerInteger2after == 76, "#10"); }
public void ContentList_AvailableFields() { ContentType c = ContentType.GetByName("CT_Root"); if (c != null) { ContentTypeInstaller.RemoveContentType(c); } ContentTypeManager.Reset(); ContentTypeInstaller installer = ContentTypeInstaller.CreateBatchContentTypeInstaller(); installer.AddContentType(@"<?xml version='1.0' encoding='utf-8'?> <ContentType name='CT_Root' parentType='GenericContent' handler='ContentRepository.GenericContent' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'> <Fields> <Field name='InheritanceTest' type='Integer'> <Configuration><MinValue>-5</MinValue><MaxValue>7</MaxValue></Configuration> </Field> </Fields> </ContentType>" ); installer.AddContentType("<ContentType name='CT_A' parentType='CT_Root' handler='ContentRepository.GenericContent' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>0</MinValue><MaxValue>10</MaxValue></Configuration></Field></Fields></ContentType>"); installer.AddContentType("<ContentType name='CT_A_A' parentType='CT_A' handler='ContentRepository.GenericContent' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>1</MinValue><MaxValue>20</MaxValue></Configuration></Field></Fields></ContentType>"); installer.AddContentType("<ContentType name='CT_B' parentType='CT_Root' handler='ContentRepository.GenericContent' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>2</MinValue><MaxValue>30</MaxValue></Configuration></Field></Fields></ContentType>"); installer.AddContentType("<ContentType name='CT_B_B' parentType='CT_B' handler='ContentRepository.GenericContent' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>3</MinValue><MaxValue>40</MaxValue></Configuration></Field></Fields></ContentType>"); installer.ExecuteBatch(); 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> "; var b = new bool[21]; ContentType CT_Root = ContentType.GetByName("CT_Root"); FieldSetting FS_Root = CT_Root.FieldSettings[0]; ContentType CT_A = ContentType.GetByName("CT_A"); ContentType CT_B = ContentType.GetByName("CT_B"); FieldSetting FS_A = CT_A.FieldSettings[0]; ContentType CT_A_A = ContentType.GetByName("CT_A_A"); FieldSetting FS_A_A = CT_A_A.FieldSettings[0]; string path = RepositoryPath.Combine(this.TestRoot.Path, "Cars"); if (Node.Exists(path)) { Node.ForceDelete(path); } var list = new ContentList(this.TestRoot); list.Name = "Cars"; list.ContentListDefinition = listDef; list.AllowedChildTypes = new[] { CT_A, CT_B }; list.Save(); b[0] = FS_Root.ParentFieldSetting == null; b[1] = FS_A.ParentFieldSetting == FS_Root; b[2] = FS_A_A.ParentFieldSetting == FS_A; var fields = list.GetAvailableFields(); }
public void SystemFlag_Move_FromFolderToSystemFolder_Descendant() { IntegrationTest(() => { var srcParent = new Folder(Repository.Root) { Name = "Source-" + Guid.NewGuid() }; srcParent.Save(); var target = new Folder(Repository.Root) { Name = "Target-" + Guid.NewGuid() }; target.Save(); if (ContentType.GetByName(nameof(TestSystemFolder)) == null) { ContentTypeInstaller.InstallContentType(TestSystemFolder.ContentTypeDefinition); } var nodeIds = CreateSourceStructure2(srcParent); Node f1, f2, s3, f4, s5, f6, f7, f8, f9, f10, f11, f12; try { f1 = Node.LoadNode(nodeIds["F1"]); f2 = Node.LoadNode(nodeIds["F2"]); s3 = Node.LoadNode(nodeIds["S3"]); f4 = Node.LoadNode(nodeIds["F4"]); s5 = Node.LoadNode(nodeIds["S5"]); f6 = Node.LoadNode(nodeIds["F6"]); f7 = Node.LoadNode(nodeIds["F7"]); f8 = Node.LoadNode(nodeIds["F8"]); f9 = Node.LoadNode(nodeIds["F9"]); f10 = Node.LoadNode(nodeIds["F10"]); f11 = Node.LoadNode(nodeIds["F11"]); f12 = Node.LoadNode(nodeIds["F12"]); Assert.IsFalse(f1.IsSystem, "F1"); Assert.IsFalse(f2.IsSystem, "F2"); Assert.IsTrue(s3.IsSystem, "S3"); Assert.IsFalse(f4.IsSystem, "F4"); Assert.IsTrue(s5.IsSystem, "S5"); Assert.IsFalse(f6.IsSystem, "F6"); Assert.IsTrue(f7.IsSystem, "F7"); Assert.IsTrue(f8.IsSystem, "F8"); Assert.IsFalse(f9.IsSystem, "F9"); Assert.IsFalse(f10.IsSystem, "F10"); Assert.IsTrue(f11.IsSystem, "F11"); Assert.IsTrue(f12.IsSystem, "F12"); f1.MoveTo(target); f1 = Node.LoadNode(nodeIds["F1"]); f2 = Node.LoadNode(nodeIds["F2"]); s3 = Node.LoadNode(nodeIds["S3"]); f4 = Node.LoadNode(nodeIds["F4"]); s5 = Node.LoadNode(nodeIds["S5"]); f6 = Node.LoadNode(nodeIds["F6"]); f7 = Node.LoadNode(nodeIds["F7"]); f8 = Node.LoadNode(nodeIds["F8"]); f9 = Node.LoadNode(nodeIds["F9"]); f10 = Node.LoadNode(nodeIds["F10"]); f11 = Node.LoadNode(nodeIds["F11"]); f12 = Node.LoadNode(nodeIds["F12"]); Assert.IsFalse(f1.IsSystem, "F1"); Assert.IsFalse(f2.IsSystem, "F2"); Assert.IsTrue(s3.IsSystem, "S3"); Assert.IsFalse(f4.IsSystem, "F4"); Assert.IsTrue(s5.IsSystem, "S5"); Assert.IsFalse(f6.IsSystem, "F6"); Assert.IsTrue(f7.IsSystem, "F7"); Assert.IsTrue(f8.IsSystem, "F8"); Assert.IsFalse(f9.IsSystem, "F9"); Assert.IsFalse(f10.IsSystem, "F10"); Assert.IsTrue(f11.IsSystem, "F11"); Assert.IsTrue(f12.IsSystem, "F12"); Assert.AreEqual(6, GetSystemFlagRelatedContentCount(false)); Assert.AreEqual(12, GetSystemFlagRelatedContentCount(true)); } finally { srcParent.ForceDelete(); target.ForceDelete(); ContentTypeInstaller.RemoveContentType(nameof(TestSystemFolder)); } }); }