public void CouldSerializeDateTimePropertyAsString() {
     var t = new TypeWithDateTimeSerializedAsString();
     var now = DateTime.Now;
     t.AsString = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);
     var j = t.ToJson();
     Console.WriteLine(j);
     var t2 = j.FromJson<TypeWithDateTimeDeSerializedAsString>();
     Assert.AreEqual(t.AsString.Value.ToString("HHmmss"), t2.AsString);
     var t1 = j.FromJson<TypeWithDateTimeSerializedAsString>();
     Assert.AreEqual(t.AsString, t1.AsString);
 }
Esempio n. 2
0
        public void CouldSerializeDateTimePropertyAsString()
        {
            var t   = new TypeWithDateTimeSerializedAsString();
            var now = DateTime.Now;

            t.AsString = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);
            var j = t.ToJson();

            Console.WriteLine(j);
            var t2 = j.FromJson <TypeWithDateTimeDeSerializedAsString>();

            Assert.AreEqual(t.AsString.Value.ToString("HHmmss"), t2.AsString);
            var t1 = j.FromJson <TypeWithDateTimeSerializedAsString>();

            Assert.AreEqual(t.AsString, t1.AsString);
        }