Rebel.Tests.Extensions.HiveModelCreationHelper.MockEntitySchema C# (CSharp) Method

MockEntitySchema() public static method

public static MockEntitySchema ( string testDoctypeAlias, string testDoctypeName ) : EntitySchema
testDoctypeAlias string
testDoctypeName string
return EntitySchema
        public static EntitySchema MockEntitySchema(string testDoctypeAlias, string testDoctypeName)
        {
            AttributeGroup groupDefinition = CreateAttributeGroup("tab-1", "Tab 1", 0);
            var generalGroup = FixedGroupDefinitions.GeneralGroup;

            AttributeType typeDefinition = CreateAttributeType(TypeAlias1,
                                                               "test-type-name",
                                                               "test-type-description");
            AttributeType typeDefinition2 = CreateAttributeType(TypeAlias2,
                                                                "test-type-name2",
                                                                "test-type-description2");

            AttributeDefinition attribDef1 = CreateAttributeDefinition("def-alias-1-with-type-1", "name-1", "test-description", typeDefinition, generalGroup);
            AttributeDefinition attribDef2 = CreateAttributeDefinition("def-alias-2-with-type-1", "name-2", "test-description", typeDefinition, groupDefinition);
            AttributeDefinition attribDef3 = CreateAttributeDefinition("def-alias-3-with-type-2", "name-3", "test-description", typeDefinition2, groupDefinition);
            AttributeDefinition attribDef4 = CreateAttributeDefinition("def-alias-4-with-type-2", "name-4", "test-description", typeDefinition2, groupDefinition);


            var schema = CreateEntitySchema(testDoctypeAlias, testDoctypeName,
                                      new[] { attribDef1, attribDef2, attribDef3, attribDef4 });

            schema.TryAddAttributeDefinition(
                CreateAttributeDefinition(NodeNameAttributeDefinition.AliasValue, "Name", "",
                                                                  new AttributeType("nodeName", "Name", "", new StringSerializationType()) {RenderTypeProvider = CorePluginConstants.NodeNamePropertyEditorId}, null));
            schema.TryAddAttributeDefinition(
                CreateAttributeDefinition(SelectedTemplateAttributeDefinition.AliasValue, "Name", "",
                                                                  new AttributeType("selectedTemplate", "Selected Template", "", new StringSerializationType()) { RenderTypeProvider = CorePluginConstants.SelectedTemplatePropertyEditorId }, null));

            //re-order the attribute defs
            foreach(var g in schema.AttributeGroups)
            {
                var attDefs = schema.AttributeDefinitions.Where(x => x.AttributeGroup.Id == g.Id).ToArray();
                for(var i = 0;i<attDefs.Count();i++)
                {
                    attDefs[i].Ordinal = i;
                }
            }

            schema.SetXmlConfigProperty("thumb", "thumb");
            schema.SetXmlConfigProperty("icon", "thumb");

            return schema;
        }