Esempio n. 1
0
 private XDocument LoadXDocumentForTestfile(SchemaCorrectorTestFile testFile)
 {
     using (var fileStream = TestFilesFactory.GetStreamForTestFile(testFile))
     {
         var xDoc = XDocument.Load(fileStream);
         return(xDoc);
     }
 }
Esempio n. 2
0
 public void CanParseFile()
 {
     using (var xsdStream = TestFilesFactory.GetStreamForTestFile(_testFile))
     {
         var schemaParser = new XmlSchemaParser(xsdStream);
         var parsedFile   = schemaParser.GetSchema();
         Assert.NotNull(parsedFile);
     }
 }
Esempio n. 3
0
 private XmlSchema ParseSchema()
 {
     using (var xsdStream = TestFilesFactory.GetStreamForTestFile(_testFile))
     {
         var schemaParser = new XmlSchemaParser(xsdStream);
         var parsedFile   = schemaParser.GetSchema();
         return(parsedFile);
     }
 }
        public void ThrowsExceptionDueToInvalidSchema()
        {
            // A simpleContent element may not have elements defined within itself
            var xsdStream    = TestFilesFactory.GetStreamForTestFile(InvalidParserTestFile.SchemaWithComplexTypeWithSimpleContentButAlsoElementDefinition);
            var schemaParser = new XmlSchemaParser(xsdStream);

            Assert.Throws <InvalidDataException>(() =>
            {
                // ReSharper disable once UnusedVariable
                var parsedFile = schemaParser.GetSchema();
            });
        }
 public void InvalidDataExceptionWhenNoRootElementDefinedInSchema()
 {
     using (var stream = TestFilesFactory.GetStreamForTestFile(InvalidParserTestFile.SchemaWithoutRootElement))
     {
         Assert.Throws <InvalidDataException>(() =>
         {
             var schemaParser = new XmlSchemaParser(stream);
             // ReSharper disable once UnusedVariable
             var parsedSchema = schemaParser.GetSchema();
         });
     }
 }
Esempio n. 6
0
 public static string GetSchemaCorrectorCode(ParserTestFile testFile)
 {
     using (var schemaStream = TestFilesFactory.GetStreamForTestFile(testFile))
     {
         var xmlSchema      = new XmlTools.Parser.XmlSchemaParser(schemaStream).GetSchema();
         var codeGenOptions = new XmlTools.CodeGenerator.CodeGeneratorOptions
         {
             Namespace = GENERATED_CODE_NAMESPACE
         };
         var codeGen       = new XmlTools.CodeGenerator.XmlSchemaCorrectorGenerator(xmlSchema, codeGenOptions);
         var generatedCode = codeGen.GenerateCode();
         return(generatedCode);
     }
 }