using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
+#if !MOBILE
using Microsoft.CSharp;
-
+#endif
using NUnit.Framework;
using MonoTests.System.Xml.TestClasses;
-namespace MonoTests.System.XmlSerialization
+namespace MonoTests.System.Xml.Serialization
{
[TestFixture]
public class XmlSchemaImporterTests
Assert.AreEqual ("UInt16", map.TypeName, "#6");
}
+#if !MOBILE
+
[Test]
public void ImportTypeMapping_EnumSimpleContent ()
{
Assert.IsTrue (a.CheckSpecified, "#4-2");
#if NET_2_0
+ Assert.IsNull (map.TypeName, "#4-3"); // null at this state
+ Assert.IsNull (map.TypeNamespace, "#4-4"); // null at this state
+
CodeDomProvider p = new Microsoft.CSharp.CSharpCodeProvider ();
Assert.AreEqual ("System.Nullable`1[System.Int32]", bar.GenerateTypeName (p), "#5-1");
Assert.AreEqual ("System.Int32", baz.GenerateTypeName (p), "#5-2");
+
+ var table = new Hashtable ();
+ var exp = new XmlCodeExporter (new CodeNamespace ("foobar"), null, p, CodeGenerationOptions.None, table);
+ exp.ExportMembersMapping (map);
+ Assert.AreEqual (null, map.TypeName, "#5-3"); // filled after ExportExportMembersMapping().
+ Assert.AreEqual (null, map.TypeNamespace, "#5-4"); // filled after ExportMembersMapping().
+ // table contains some internal stuff that does not make sense in any public API.
#endif
}
return null;
}
- private static XmlSchemas ExportType (Type type)
- {
- XmlReflectionImporter ri = new XmlReflectionImporter ("NS" + type.Name);
- XmlSchemas schemas = new XmlSchemas ();
- XmlSchemaExporter sx = new XmlSchemaExporter (schemas);
- XmlTypeMapping tm = ri.ImportTypeMapping (type);
- sx.ExportTypeMapping (tm);
- return schemas;
- }
-
- private static ArrayList GetXmlQualifiedNames (XmlSchemas schemas)
- {
- ArrayList qnames = new ArrayList ();
-
- foreach (XmlSchema schema in schemas) {
- if (!schema.IsCompiled) schema.Compile (null);
- foreach (XmlSchemaObject ob in schema.Items)
- if (ob is XmlSchemaElement)
- qnames.Add (((XmlSchemaElement) ob).QualifiedName);
- }
-
- return qnames;
- }
-
[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void ImportTypeMappingNonExistent ()
xss.Add (XmlSchema.Read (new XmlTextReader (new StringReader (xsd)), null));
return new XmlSchemaImporter (xss);
}
+
+#endif
+
+ private static ArrayList GetXmlQualifiedNames (XmlSchemas schemas)
+ {
+ ArrayList qnames = new ArrayList ();
+
+ foreach (XmlSchema schema in schemas) {
+ if (!schema.IsCompiled) schema.Compile (null);
+ foreach (XmlSchemaObject ob in schema.Items)
+ if (ob is XmlSchemaElement)
+ qnames.Add (((XmlSchemaElement) ob).QualifiedName);
+ }
+
+ return qnames;
+ }
+
+ private static XmlSchemas ExportType (Type type)
+ {
+ XmlReflectionImporter ri = new XmlReflectionImporter ("NS" + type.Name);
+ XmlSchemas schemas = new XmlSchemas ();
+ XmlSchemaExporter sx = new XmlSchemaExporter (schemas);
+ XmlTypeMapping tm = ri.ImportTypeMapping (type);
+ sx.ExportTypeMapping (tm);
+ return schemas;
+ }
}
}