Test Json deserialization of a floating-point number as object.
authorMarcos Henrich <marcos.henrich@xamarin.com>
Thu, 25 Sep 2014 14:15:38 +0000 (15:15 +0100)
committerMarcos Henrich <marcos.henrich@xamarin.com>
Thu, 25 Sep 2014 14:15:38 +0000 (15:15 +0100)
Covers 21583.

mcs/class/System.ServiceModel.Web/Test/System.Runtime.Serialization.Json/JsonReaderTest.cs

index 0ca6f2fb050664813a9febe676ca4c71988908ee..de884aeac9affe6f8862702d74feceec931a54a5 100644 (file)
@@ -855,5 +855,16 @@ namespace MonoTests.System.Runtime.Serialization.Json
                        r.ReadStartElement ();
                        r.Read ();
                }
+
+               [Test]
+               public void ReadNumberAsObject ()
+               {
+                       const double testValue = 42.42D;
+                       var serializer = new DataContractJsonSerializer (typeof (object));
+                       var serializedStream = GetInput (testValue.ToString (CultureInfo.InvariantCulture));
+                       var deserializedValue = serializer.ReadObject (serializedStream);
+                       Assert.AreEqual (typeof (decimal), deserializedValue.GetType ());
+                       Assert.AreEqual (testValue, (decimal) deserializedValue);
+               }
        }
 }