protected void TestBuildCode(string classFileName, DocumentType contentType, string contentTypeName)
        {
            string expectedOutput;
            using (var goldReader = File.OpenText(@"..\..\TestFiles\" + classFileName + ".cs"))
            {
                expectedOutput = goldReader.ReadToEnd();
            }

            var configuration = CodeGeneratorConfiguration.Create();
            var typeConfig = configuration.Get(contentTypeName);
            typeConfig.BaseClass = "Umbraco.Core.Models.TypedModelBase";
            typeConfig.Namespace = "Umbraco.CodeGen.Models";

            configuration.TypeMappings.Add(new TypeMapping("Umbraco.Integer", "Int32"));

            OnConfiguring(configuration, contentTypeName);

            var sb = new StringBuilder();
            var writer = new StringWriter(sb);

            var dataTypeProvider = new TestDataTypeProvider();
            var generator = new CodeGenerator(typeConfig, dataTypeProvider, CreateGeneratorFactory());

            generator.Generate(contentType, writer);

            writer.Flush();
            Console.WriteLine(sb.ToString());

            Assert.AreEqual(expectedOutput, sb.ToString());
        }
 public void SetUp()
 {
     Configuration = CodeGeneratorConfiguration.Create().DocumentTypes;
     Candidate = Type = new CodeTypeDeclaration();
     Generator = new InterfaceNameGenerator(Configuration);
     documentType = new DocumentType { Info = { Alias = "aMixin" } };
     EntityDescription = documentType.Info;
 }
 public void SetUp()
 {
     Configuration = new CodeGeneratorConfiguration().MediaTypes;
     Candidate = Type = new CodeTypeDeclaration();
     generator = new DocumentTypeInfoGenerator(Configuration);
     documentType = new DocumentType { Info = { Alias = "aClass" } };
     info = (DocumentTypeInfo)documentType.Info;
 }
 public void SetUp()
 {
     Configuration = new CodeGeneratorConfiguration().MediaTypes;
     Candidate = Type = new CodeTypeDeclaration();
     Generator = new EntityDescriptionGenerator(Configuration);
     documentType = new DocumentType { Info = { Alias = "anEntity" } };
     EntityDescription = documentType.Info;
 }
 public void SetUp()
 {
     Configuration = CodeGeneratorConfiguration.Create().MediaTypes;
     Parser = new DocumentTypeInfoParser(Configuration);
     ContentType = new DocumentType();
     Info = ContentType.Info;
     typedInfo = (DocumentTypeInfo) Info;
 }
 public void SetUp()
 {
     Configuration = CodeGeneratorConfiguration.Create().MediaTypes;
     attribute = new CodeAttributeDeclaration();
     Generator = new EntityDescriptionGenerator(Configuration);
     documentType = new DocumentType { Info = { Alias = "anEntity" } };
     EntityDescription = documentType.Info;
 }
 public void SetUp()
 {
     Configuration = CodeGeneratorConfiguration.Create().DocumentTypes;
     Generator = new InterfaceGenerator(
         Configuration
         );
     ContentType = new DocumentType { Info = { Alias = "Mixin" } };
     ns = new CodeNamespace("ANamespace");
 }
 public void SetUp()
 {
     Configuration = CodeGeneratorConfiguration.Create().MediaTypes;
     attribute = new CodeAttributeDeclaration("DocumentType");
     generator = new DocumentTypeInfoGenerator(Configuration);
     documentType = new DocumentType
     {
         Info = info = new DocumentTypeInfo {Alias = "aClass"}
     };
 }
Пример #9
0
        private static ContentType MapDocumentType(IContentTypeBase contentType)
        {
            var type = new DocumentType();
            var umbracoContentType = (IContentType)contentType;

            MapContentTypeBase(contentType, type);
            MapDocumentTypeInfo(umbracoContentType, type.Info);
            MapComposition(umbracoContentType, type);
            
            return type;
        }
 private static DocumentType CreateInterfaceType()
 {
     var expected = new DocumentType
     {
         Info = new DocumentTypeInfo()
         {
             Alias = "Mixin"
         },
         Tabs = new List<Tab> { new Tab { Caption = "Mixin tab" } },
         GenericProperties = new List<GenericProperty>
         {
             new GenericProperty
             {
                 Alias = "mixinProp",
                 Name = "Mixin prop",
                 Type = "Umbraco.Integer",
                 Tab = "Mixin tab"
             }
         }
     };
     return expected;
 }
 private void SetupDocumentType()
 {
     ContentType = new DocumentType();
     Generator = new AttributeCodeGenerator("DocumentType", Configuration);
     Candidate = new CodeTypeDeclaration();
 }
 private static DocumentType CreateCodeGenDocumentType()
 {
     var expected = new DocumentType
     {
         Info = new DocumentTypeInfo
         {
             Alias = "SomeDocumentType",
             AllowAtRoot = true,
             AllowedTemplates = new List<string> { "ATemplate", "AnotherTemplate" },
             DefaultTemplate = "ATemplate",
             Description = "A description of some document type",
             Icon = "privateMemberIcon.gif",
             Master = "",
             Name = "Some document type",
             Thumbnail = "privateMemberThumb.png"
         },
         Tabs = new List<Tab>
         {
             new Tab {Caption = "A tab"},
             new Tab()
         },
         Structure = new List<string>
         {
             "SomeOtherDocType"
         },
         Composition = new List<ContentType>
         {
             new ContentType
             {
                 Info = new Info
                 {
                     Alias = "Mixin"
                 },
                 Tabs = new List<Tab>{new Tab{Caption="Mixin tab"}},
                 GenericProperties = new List<GenericProperty>
                 {
                     new GenericProperty
                     {
                         Alias = "mixinProp",
                         Name = "Mixin prop",
                         Type = "Umbraco.Integer",
                         Tab = "Mixin tab"
                     }
                 }
             }
         },
         GenericProperties = new List<GenericProperty>
         {
             new GenericProperty
             {
                 Alias = "someProperty",
                 Definition = null,
                 Description = "A description",
                 Name = "Some property",
                 Tab = "A tab",
                 Type = "Umbraco.Richtext"
             },
             new GenericProperty
             {
                 Alias = "anotherProperty",
                 Definition = null,
                 Description = "Another description",
                 Name = "Another property",
                 Tab = "A tab",
                 Type = "Umbraco.Richtext"
             },
             new GenericProperty
             {
                 Alias = "tablessProperty",
                 Definition = null,
                 Name = "Tabless property",
                 Type = "Umbraco.Integer"
             },
         }
     };
     return expected;
 }
        public void Setup()
        {
            MockSettings();

            expected = CreateCodeGenDocumentType();
            umbracoContentType = CreateUmbracoContentType();
        }