Merge pull request #925 from ermshiperete/novell-bug-602934
[mono.git] / mcs / class / System.XML / Test / System.Xml.Serialization / XmlSchemaImporterTests.cs
index 44cedb063d6c05657f9737bebd91dc1af58ff355..fe4838cb2e9d8184999494e9a45d2809f8550f8f 100644 (file)
@@ -39,13 +39,14 @@ using System.IO;
 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
@@ -891,6 +892,8 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual ("UInt16", map.TypeName, "#6");
                }
 
+#if !MOBILE
+
                [Test]
                public void ImportTypeMapping_EnumSimpleContent ()
                {
@@ -1035,9 +1038,19 @@ namespace MonoTests.System.XmlSerialization
                        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
                }
                
@@ -1065,30 +1078,6 @@ namespace MonoTests.System.XmlSerialization
                        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 ()
@@ -1228,5 +1217,31 @@ namespace MonoTests.System.XmlSerialization
                                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;
+               }
        }
 }