Skip to content

Commit

Permalink
JsonOptions.FullTime单元测试通过,默认false
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed May 21, 2024
1 parent a28cc8e commit 87f33a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion NewLife.Core/Serialization/Json/JsonOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public class JsonOptions
/// <summary>缩进。默认false</summary>
public Boolean WriteIndented { get; set; }

/// <summary>使用完整的时间格式。如:2022-11-29T14:13:17.8763881+08:00</summary>
/// <summary>使用完整的时间格式。如:2022-11-29T14:13:17.8763881+08:00,默认false</summary>
public Boolean FullTime { get; set; }
}
10 changes: 5 additions & 5 deletions XUnitTest.Core/Serialization/JsonWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ public void FullTime_Setting(Boolean fullTime)

var str2 = dic["time"];
// +08:00
Assert.EndsWith(dto.Offset.ToString(), str2 + "");
Assert.Equal(dt.ToUniversalTime().ToFullString() + " UTC", str2);
Assert.EndsWith(dto.Offset.ToString(), str2 + ":00");
Assert.Equal($"{dt:yyyy-MM-ddTHH:mm:ss.fffffff}+{dto.Offset.Hours:00}:00", str2);

var dt2 = dic["time"].ToDateTime();
Assert.Equal(DateTimeKind.Utc, dt2.Kind);
Assert.Equal(dt.ToUniversalTime().Trim(), dt2.Trim());
Assert.Equal(DateTimeKind.Local, dt2.Kind);
Assert.Equal(dt.Trim(), dt2.Trim());
}
else
{
Expand All @@ -114,7 +114,7 @@ public void FullTime_Setting(Boolean fullTime)
Assert.Equal(dt.ToFullString(), str2);

var dt2 = dic["time"].ToDateTime();
Assert.NotEqual(DateTimeKind.Utc, dt2.Kind);
Assert.Equal(DateTimeKind.Unspecified, dt2.Kind);
Assert.Equal(dt.Trim(), dt2.Trim());
}
}
Expand Down

0 comments on commit 87f33a6

Please sign in to comment.