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); }
private static void TestGeneratedXml(string fileName, string contentTypeName) { ContentType contentType; string expectedOutput; using (var goldReader = File.OpenText(@"..\..\TestFiles\" + fileName + ".xml")) { expectedOutput = goldReader.ReadToEnd(); } var contentTypeConfig = new CodeGeneratorConfiguration().Get(contentTypeName); contentTypeConfig.BaseClass = "DocumentTypeBase"; using (var inputReader = File.OpenText(@"..\..\TestFiles\" + fileName + ".cs")) { var codeParser = new CodeParser(contentTypeConfig, TestDataTypeProvider.All, new DefaultParserFactory()); contentType = codeParser.Parse(inputReader).Single(); } var serializer = new ContentTypeSerializer(); var xml = serializer.Serialize(contentType); Console.WriteLine(xml); Assert.AreEqual(expectedOutput, xml); }