[WCF] fixed a couple of DateTime related tests that also failed on .NET IN JST.
authorAtsushi Eno <atsushieno@gmail.com>
Mon, 20 Apr 2015 08:31:07 +0000 (17:31 +0900)
committerAtsushi Eno <atsushieno@gmail.com>
Fri, 24 Apr 2015 05:36:58 +0000 (14:36 +0900)
Those tests were added without considering TimeZone difference. They cause
several kind of errors (SerializationException etc.) in JST (+09:00) or any
timezone that is earlier than UTC.

We likely had some "working" implementation, but was incompatible with .NET.

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

index eb16f0cde146b2cb78e18d73e8d314e25529dbfd..21eef3451a0525b3894e0f86a7b46ec9adf1c068 100644 (file)
@@ -1360,8 +1360,8 @@ namespace MonoTests.System.Runtime.Serialization.Json
                        var ms = new MemoryStream ();
                        DataContractJsonSerializer serializer = new DataContractJsonSerializer (typeof (Query));
                        Query query = new Query () {
-                               StartDate = new DateTime (2010, 3, 4, 5, 6, 7),
-                               EndDate = new DateTime (2010, 4, 5, 6, 7, 8)
+                               StartDate = DateTime.SpecifyKind (new DateTime (2010, 3, 4, 5, 6, 7), DateTimeKind.Utc),
+                               EndDate = DateTime.SpecifyKind (new DateTime (2010, 4, 5, 6, 7, 8), DateTimeKind.Utc)
                                };
                        serializer.WriteObject (ms, query);
                        Assert.AreEqual ("{\"StartDate\":\"\\/Date(1267679167000)\\/\",\"EndDate\":\"\\/Date(1270447628000)\\/\"}", Encoding.UTF8.GetString (ms.ToArray ()), "#1");
@@ -1386,14 +1386,14 @@ namespace MonoTests.System.Runtime.Serialization.Json
                [Test]
                public void BugXamarin163 ()
                {
-                       string json = @"{""should_have_value"":""\/Date(1277355600000-0500)\/""}";
+                       string json = @"{""should_have_value"":""\/Date(1277355600000)\/""}";
 
                        byte[] bytes = global::System.Text.Encoding.UTF8.GetBytes(json);
                        Stream inputStream = new MemoryStream(bytes);
                        
                        DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(DateTest));
                        DateTest t = serializer.ReadObject(inputStream) as DateTest;
-                       Assert.AreEqual (634129344000000000, t.ShouldHaveValue.Value.Ticks, "#1");
+                       Assert.AreEqual (634129524000000000, t.ShouldHaveValue.Value.Ticks, "#1");
                }
 
                [Test]
@@ -2069,6 +2069,7 @@ namespace MonoTests.System.Runtime.Serialization.Json
                void Init ()
                {
                        C = true;
+                       ServerTimeUTC = DateTime.SpecifyKind (DateTime.MinValue, DateTimeKind.Utc);
                }
 
                [OnDeserializing]