Esempio n. 1
0
        public void ShouldGenerateWithXmlSerializerImporterFromData()
        {
            MyArtifactLinkWithXmlImporterFromData link     = new MyArtifactLinkWithXmlImporterFromData("SampleData\\SimpleSchema1.xsd", "element1");
            XmlSchemaCodeGenerationStrategy       strategy = new XmlSchemaCodeGenerationStrategy();
            CodeGenerationResults content = strategy.Generate(link);

            Assert.AreEqual <int>(3, content.Count);
            Assert.AreEqual <int>(0, strategy.Errors.Count);
            CompilerResults results = DynamicCompilation.CompileAssemblyFromSource(JoinContent(content), ((List <string>)strategy.AssemblyReferences).ToArray());

            TypeAsserter.AssertAttribute <XmlRootAttribute>(results.CompiledAssembly.GetType("element1"));
        }
		public void ShouldHandleCircularRefSchema()
		{
			MyArtifactLinkWithXmlImporterFromData link = new MyArtifactLinkWithXmlImporterFromData("SampleData\\CircularRefSchema.xsd", "element1");
			XmlSchemaCodeGenerationStrategy strategy = new XmlSchemaCodeGenerationStrategy();
			CodeGenerationResults content = strategy.Generate(link);

			Assert.AreEqual<int>(3, content.Count);
			Assert.AreEqual<int>(0, strategy.Errors.Count);
			CompilerResults results = DynamicCompilation.CompileAssemblyFromSource(JoinContent(content), ((List<string>)strategy.AssemblyReferences).ToArray());
			TypeAsserter.AssertAttribute<XmlRootAttribute>(results.CompiledAssembly.GetType("element1"));
			TypeAsserter.AssertAttribute<XmlTypeAttribute>(results.CompiledAssembly.GetType("complexType1"));
			TypeAsserter.AssertAttribute<XmlTypeAttribute>(results.CompiledAssembly.GetType("complexType2"));
		}