Merge pull request #1857 from slluis/fix-assembly-resolver
[mono.git] / mcs / class / System.XML / Test / System.Xml.Serialization / DeserializeTests.cs
index 459620cb13f8ee748e29c6b87d3aa3c5b2b3c983..ec13691da1c6f391354da03759db0b487818446c 100644 (file)
@@ -163,7 +163,8 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [Category ("NotDotNet")]
+               [Category ("MobileNotWorking")]
+               [ExpectedException (typeof (InvalidOperationException))]
                public void DeserializeArrayReferences ()
                {
                        string s = "<Sample xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">";
@@ -248,7 +249,6 @@ namespace MonoTests.System.XmlSerialization
                        ListDefaults d2 = (ListDefaults) Deserialize (typeof (ListDefaults), "<root/>");
 
                        Assert.IsNotNull (d2.list2, "#A1");
-                       Assert.IsNull (d2.list3, "#A2");
                        Assert.IsNull (d2.list4, "#A3");
                        Assert.IsNotNull (d2.list5, "#A4");
                        Assert.IsNotNull (d2.ed, "#A5");
@@ -257,7 +257,6 @@ namespace MonoTests.System.XmlSerialization
                        d2 = (ListDefaults) Deserialize (typeof (ListDefaults), "<root></root>");
 
                        Assert.IsNotNull (d2.list2, "#B1");
-                       Assert.IsNull (d2.list3, "#B2");
                        Assert.IsNull (d2.list4, "#B3");
                        Assert.IsNotNull (d2.list5, "#B4");
                        Assert.IsNotNull (d2.ed, "#B5");
@@ -280,7 +279,6 @@ namespace MonoTests.System.XmlSerialization
 
                #region GenericsDeseralizationTests
 
-#if NET_2_0
                [Test]
                public void TestDeserializeGenSimpleClassString ()
                {
@@ -512,7 +510,6 @@ namespace MonoTests.System.XmlSerialization
                        Assert.AreEqual ("six", complex.nestedinner.inner);
                        Assert.AreEqual (6, complex.nestedinner.something);
                }
-#endif
 
                #endregion //GenericsDeseralizationTests
 
@@ -821,7 +818,7 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [ExpectedException (typeof (InvalidOperationException))]
+               [Category ("MobileNotWorking")]
                public void TestDeserializeObjectWithReadonlyNulCollection ()
                {
                        string s3 = "";
@@ -832,7 +829,8 @@ namespace MonoTests.System.XmlSerialization
                        s3 += " </Collection1>";
                        s3 += "</Container>";
 
-                       Deserialize (typeof (ObjectWithReadonlyNulCollection), s3);
+                       var obj = (ObjectWithReadonlyNulCollection) Deserialize (typeof (ObjectWithReadonlyNulCollection), s3);
+                       Assert.IsNull (obj.Collection1);
                }
 
                [Test]
@@ -1062,7 +1060,7 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
-               [Category ("NotDotNet")] // MS.NET results in compilation error (probably it generates bogus source.)
+               [Category ("NotWorking")] // MS.NET results in compilation error (probably it generates bogus source.)
                public void TestDeserialize_Field_Encoded ()
                {
                        Field_Encoded f = null;
@@ -1549,11 +1547,12 @@ namespace MonoTests.System.XmlSerialization
                }
 
                [Test]
+               [Category ("MobileNotWorking")]
                public void NotExactDateParse ()
                {
                        XmlSerializer xs = new XmlSerializer (typeof (NotExactDateParseClass));
                        NotExactDateParseClass o = (NotExactDateParseClass) xs.Deserialize (new StringReader ("<NotExactDateParseClass xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><SomeDate xsi:type=\"xsd:date\">2012-02-05-09:00</SomeDate></NotExactDateParseClass>"));
-                       Assert.AreEqual (new DateTime (2012,2,5), o.SomeDate);
+                       Assert.AreEqual (new DateTime (2012,2,5,9,0,0,DateTimeKind.Utc), o.SomeDate.ToUniversalTime ());
                }
 
 
@@ -1621,5 +1620,63 @@ namespace MonoTests.System.XmlSerialization
                                Assert.IsNull(foobar.Baz);
                        }
                }
+
+               [Test] // bug #8468
+               public void TestUseSubclassDefaultNamespace ()
+               {
+                       XmlSerializer xs = new XmlSerializer (typeof (Bug8468Subclass));
+                       string msg = "<Test xmlns=\"http://test-namespace\"><Base>BaseValue</Base><Mid>MidValue</Mid></Test>";
+                       var res1 = (Bug8468Subclass)xs.Deserialize (new StringReader (msg));
+                       Assert.IsNotNull (res1);
+                       Assert.AreEqual ("BaseValue", res1.Base);
+                       Assert.AreEqual ("MidValue", res1.Mid);
+
+                       xs = new XmlSerializer (typeof (Bug8468SubclassNoNamespace), "http://test-namespace");
+                       var res2 = (Bug8468SubclassNoNamespace)xs.Deserialize (new StringReader (msg));
+                       Assert.IsNotNull (res2);
+                       Assert.AreEqual ("BaseValue", res2.Base);
+                       Assert.AreEqual ("MidValue", res2.Mid);
+
+                       xs = new XmlSerializer (typeof (Bug8468SubclassV2));
+                       var res3 = (Bug8468SubclassV2)xs.Deserialize (new StringReader (msg));
+                       Assert.IsNotNull (res3);
+                       Assert.IsNull (res3.Base);
+                       Assert.AreEqual ("MidValue", res3.Mid);
+
+                       xs = new XmlSerializer (typeof (Bug8468SubclassNoNamespaceV2), "http://test-namespace");
+                       var res4 = (Bug8468SubclassNoNamespaceV2)xs.Deserialize (new StringReader (msg));
+                       Assert.IsNotNull (res4);
+                       Assert.IsNull (res4.Base);
+                       Assert.AreEqual ("MidValue", res4.Mid);
+
+                       msg = "<Test xmlns=\"http://test-namespace\"><Base xmlns=\"\">BaseValue</Base><Mid>MidValue</Mid></Test>";
+
+                       xs = new XmlSerializer (typeof (Bug8468SubclassV2));
+                       var res5 = (Bug8468SubclassV2)xs.Deserialize (new StringReader (msg));
+                       Assert.IsNotNull (res5);
+                       Assert.AreEqual ("BaseValue", res5.Base);
+                       Assert.AreEqual ("MidValue", res5.Mid);
+
+                       xs = new XmlSerializer (typeof (Bug8468SubclassNoNamespaceV2), "http://test-namespace");
+                       var res6 = (Bug8468SubclassNoNamespaceV2)xs.Deserialize (new StringReader (msg));
+                       Assert.IsNotNull (res6);
+                       Assert.AreEqual ("BaseValue", res6.Base);
+                       Assert.AreEqual ("MidValue", res6.Mid); 
+               }
+               
+               [Test] // bug #9193
+               public void TestOrderedMapWithFlatList ()
+               {
+                       var d = (Bug9193Class) Deserialize (typeof(Bug9193Class), "<Test><Data>One</Data><Data>Two</Data><Data>Three</Data><Extra>a</Extra><Extra>b</Extra></Test>");
+                       Assert.IsNotNull (d);
+                       Assert.AreEqual (3, d.Data.Length);
+                       Assert.AreEqual ("One", d.Data[0]);
+                       Assert.AreEqual ("Two", d.Data[1]);
+                       Assert.AreEqual ("Three", d.Data[2]);
+
+                       Assert.AreEqual (2, d.Extra.Length);
+                       Assert.AreEqual ("a", d.Extra[0]);
+                       Assert.AreEqual ("b", d.Extra[1]);
+               }
        }
 }