public void 自定义序列化测试2() { var m = new MyClass2(1, "zzj"); var str = m.ToJsonString(); //"x":{"ID":0},"y":100 Assert.AreEqual("[1,\"zzj\"]", str); }
public void ToJsonString_Not_Normalize_DateTime_Test() { Clock.Provider = ClockProviders.Utc; var model1 = new MyClass1 { Date = new DateTime(2016, 03, 16, 14, 0, 0, DateTimeKind.Local) }; var model1AsString = model1.ToJsonString(); var date1 = model1AsString.Replace("{\"Date\":", "").Replace("\"}", "").Replace("\"", ""); date1.ShouldNotEndWith("00Z"); var model2 = new MyClass2 { Date = new DateTime(2016, 03, 16, 14, 0, 0, DateTimeKind.Local) }; var model2AsString = model2.ToJsonString(); var date2 = model2AsString.Replace("{\"Date\":", "").Replace("\"}", "").Replace("\"", ""); date2.ShouldNotEndWith("00Z"); }