private static void TestGeneratedXml(string classFileName, string xmlFileName, string contentTypeName, ParserFactory factory)
        {
            ContentType contentType;
            string expectedOutput;

            using (var goldReader = File.OpenText(@"..\..\TestFiles\" + xmlFileName + ".xml"))
            {
                expectedOutput = goldReader.ReadToEnd();
            }

            var contentTypeConfig = CodeGeneratorConfiguration.Create().Get(contentTypeName);
            contentTypeConfig.BaseClass = "Umbraco.Core.Models.TypedModelBase";

            using (var inputReader = File.OpenText(@"..\..\TestFiles\" + classFileName + ".cs"))
            {
                var codeParser = new CodeParser(contentTypeConfig, TestDataTypeProvider.All, factory);
                contentType = codeParser.Parse(inputReader).Single();
            }

            var serializer = new ContentTypeSerializer();
            var xml = serializer.Serialize(contentType);

            Console.WriteLine(xml);

            Assert.AreEqual(expectedOutput, xml);
        }
Esempio n. 2
0
		public CodeParser(
            ContentTypeConfiguration configuration, 
            IEnumerable<DataTypeDefinition> dataTypes,
            ParserFactory parserFactory
        )
		{
			this.configuration = configuration;
			this.dataTypes = dataTypes;
		    this.parserFactory = parserFactory;
		}