Skip to content

Commit 88291c6

Browse files
committed
Translate files for unit test
1 parent bffe20a commit 88291c6

File tree

5 files changed

+32
-33
lines changed

5 files changed

+32
-33
lines changed

src/Senparc.CO2NET.Tests/ExtensionEntities/SystemTimeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void NowTest()
3535
public void NowTicksTest()
3636
{
3737
var now = SystemTime.Now;
38-
Assert.IsTrue(TimeSpan.FromTicks(SystemTime.NowTicks - now.Ticks).TotalMilliseconds < 1);//由于分两次获取,小于一定的延迟
38+
Assert.IsTrue(TimeSpan.FromTicks(SystemTime.NowTicks - now.Ticks).TotalMilliseconds < 1);//Due to being obtained twice, less than a certain delay
3939
}
4040
}
4141
}

src/Senparc.CO2NET.Tests/Helpers/Maps/BaiduMap/BaiduMapHelperTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using Microsoft.VisualStudio.TestTools.UnitTesting;
44
using Senparc.CO2NET.Helpers;

src/Senparc.CO2NET.Tests/Helpers/Serializers/JsonSettingTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using Microsoft.VisualStudio.TestTools.UnitTesting;
44
using Senparc.CO2NET.Helpers;
@@ -9,7 +9,7 @@ namespace Senparc.CO2NET.Tests.Helpers
99
[TestClass]
1010
public class JsonSettingTests
1111
{
12-
#region JsonSetting ²âÊÔ
12+
#region JsonSetting Test
1313

1414
[Serializable]
1515
public class WeixinData
@@ -31,7 +31,7 @@ public void JsonSettingTest()
3131
UserName = "JeffreySu",
3232
Note = null,
3333
Sign = null,
34-
Sex = Sex.ÄÐ
34+
Sex = Sex.Male
3535
};
3636

3737
//string json = js.GetJsonString(weixinData);
@@ -55,7 +55,7 @@ public void NullAndEmptyTest()
5555
Console.WriteLine(json);
5656
Assert.AreEqual("{\"page\":\"pages/websocket/websocket\",\"width\":100,\"line_color\":\"red\",\"is_hyaline\":true}", json);
5757

58-
//²âÊÔ¿Õ×Ö·û´®
58+
//Test string
5959
data = new { scene = "", page = "pages/websocket/websocket", width = 100, line_color = "red", is_hyaline = true };
6060
json = SerializerHelper.GetJsonString(data, jsonSetting);
6161
Console.WriteLine(json);

src/Senparc.CO2NET.Tests/Helpers/Serializers/SerializerHelperTests.Json.cs

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Dynamic;
44
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -10,8 +10,7 @@ namespace Senparc.CO2NET.Tests.Helpers
1010
[TestClass]
1111
public class SerializerHelperJsonTests
1212
{
13-
#region 复杂条件下的序列化测试:忽略null、特定值值、特定属性测试(微信接口中尤其重要)
14-
[TestMethod]
13+
#region Serialization Test Under Complex Conditions: Ignore null, specific values, specific properties (especially important in WeChat interfaces) [TestMethod]
1514
public void GetJsonStringTest_Null()
1615
{
1716
var obj =
@@ -37,7 +36,7 @@ public void GetJsonStringTest_Null()
3736
var dt1 = SystemTime.Now;
3837

3938
{
40-
//不进行任何设置,返回原始JSON
39+
// Do not modify any properties, keep the original JSON
4140
var json = SerializerHelper.GetJsonString(obj, jsonSetting: null);
4241
Console.WriteLine(json);
4342
var exceptedJson = "{\"X\":{\"A\":\"Jeffrey\",\"B\":31,\"C\":null,\"ElementClassA\":{\"A\":\"Jeffrey\",\"B\":null,\"RootClass\":null},\"ElementClassB\":null,\"ElementClass2\":null},\"Y\":{\"O\":\"0\",\"Z\":null}}";
@@ -46,15 +45,15 @@ public void GetJsonStringTest_Null()
4645

4746

4847
{
49-
//不忽略任何属性
48+
// Do not modify any properties
5049
var json = SerializerHelper.GetJsonString(obj, new JsonSetting(false));
5150
Console.WriteLine(json);
5251
var exceptedJson = "{\"X\":{\"A\":\"Jeffrey\",\"B\":31,\"ElementClassA\":{\"A\":\"Jeffrey\",\"B\":null,\"RootClass\":null},\"ElementClassB\":null,\"ElementClass2\":null},\"Y\":{\"O\":\"0\",\"Z\":null}}";
5352
Assert.AreEqual(exceptedJson, json);
5453
}
5554

5655
{
57-
//忽略所有为null的属性
56+
// If the property is null, ignore it
5857
var json = SerializerHelper.GetJsonString(obj, new JsonSetting(true));
5958
Console.WriteLine(json);
6059
var exceptedJson = "{\"X\":{\"A\":\"Jeffrey\",\"B\":31,\"ElementClassA\":{\"A\":\"Jeffrey\"}},\"Y\":{\"O\":\"0\"}}";
@@ -80,75 +79,75 @@ public void GetJsonStringTest_Null()
8079
}
8180

8281
{
83-
//忽略特定为null的属性
82+
// If the property is null, ignore it
8483
var json = SerializerHelper.GetJsonString(obj,
85-
new JsonSetting(false, new List<string>(new[] { "Z" })));//Z属性会被忽略
84+
new JsonSetting(false, new List<string>(new[] { "Z" })));// Z property will be ignored
8685
Console.WriteLine(json);
8786
var exceptedJson = "{\"X\":{\"A\":\"Jeffrey\",\"B\":31,\"ElementClassA\":{\"A\":\"Jeffrey\",\"B\":null,\"RootClass\":null},\"ElementClassB\":null,\"ElementClass2\":null},\"Y\":{\"O\":\"0\"}}";
8887
Assert.AreEqual(exceptedJson, json);
8988
}
9089

9190
{
92-
//忽略特定值测试(忽略特定值,以及忽略null)
91+
// The property value is optional, it can be the property value itself or null
9392
var obj4 = new RootClass()
9493
{
95-
A = "IGNORE",//会被忽略
94+
A = "IGNORE",// Will be ignored
9695
B = 31,
9796
C = null,
9897
ElementClassA = null,
9998
ElementClassB = null,
10099
ElementClass2 = null
101100
};
102-
var json = SerializerHelper.GetJsonString(obj4, new JsonSetting(true));//Z属性会被忽略
101+
var json = SerializerHelper.GetJsonString(obj4, new JsonSetting(true));// Z property will be ignored
103102
Console.WriteLine(json);
104103
var exceptedJson = "{\"B\":31}";
105104
Assert.AreEqual(exceptedJson, json);
106105
}
107106

108107
{
109-
//忽略特定值测试(只忽略特定值,不忽略null)
108+
// The property value is optional, only the property value itself or null
110109
var obj4 = new RootClass()
111110
{
112-
A = "IGNORE",//会被忽略
111+
A = "IGNORE",// Will be ignored
113112
B = 31,
114113
C = null,
115114
ElementClassA = null,
116115
ElementClassB = null,
117116
ElementClass2 = null
118117
};
119-
var json = SerializerHelper.GetJsonString(obj4, new JsonSetting(false));//Z属性会被忽略
118+
var json = SerializerHelper.GetJsonString(obj4, new JsonSetting(false));// Z property will be ignored
120119
Console.WriteLine(json);
121120
var exceptedJson = "{\"B\":31,\"ElementClassA\":null,\"ElementClassB\":null,\"ElementClass2\":null}";
122121
Assert.AreEqual(exceptedJson, json);
123122
}
124123

125124
{
126-
//忽略特定值测试(不匹配,因此不忽略)
125+
// The property value is optional, match it, but it is not required
127126
var obj4 = new RootClass()
128127
{
129-
A = "DO NET IGNORE",//不会被忽略
128+
A = "DO NET IGNORE",// Will be ignored
130129
B = 31,
131130
C = null,
132131
ElementClassA = null,
133132
ElementClassB = null,
134133
ElementClass2 = null
135134
};
136-
var json = SerializerHelper.GetJsonString(obj4, new JsonSetting(true));//Z属性会被忽略
135+
var json = SerializerHelper.GetJsonString(obj4, new JsonSetting(true));// Z property will be ignored
137136
Console.WriteLine(json);
138137
var exceptedJson = "{\"A\":\"DO NET IGNORE\",\"B\":31}";
139138
Assert.AreEqual(exceptedJson, json);
140139
}
141140

142141
{
143-
//忽略特定类型为null的属性
142+
// If the property value is null, ignore it
144143
var obj3 = new RootClass()
145144
{
146145
A = "Jeffrey",
147146
B = 31,
148147
C = null,
149148
ElementClassA = new ElementClass() { A = "Jeffrey", B = null },
150149
ElementClassB = null,
151-
ElementClass2 = null//将会被忽略
150+
ElementClass2 = null// Will be ignored
152151
};
153152

154153
var json3 = SerializerHelper.GetJsonString(obj3,
@@ -198,7 +197,7 @@ public class ElementClass2
198197
#endregion
199198

200199

201-
#region 复杂(嵌套类型)反序列化测试
200+
#region Complex (Nested Type) Deserialization Test
202201

203202
[TestMethod]
204203
public void GetObjectTest()
@@ -219,7 +218,7 @@ public void GetObjectTest()
219218
#endregion
220219

221220

222-
#region 简单序列化/反序列化测试
221+
#region Simple Serialization/Deserialization Test
223222

224223
[TestMethod]
225224
public void Simple_GetJsonStringTest()
@@ -266,7 +265,7 @@ public class Data
266265

267266
#endregion
268267

269-
#region ExpandoObject类型转换测试
268+
#region ExpandoObject Type Conversion Test
270269

271270
[TestMethod]
272271
public void GetJsonStringTest_Expando()

src/Senparc.CO2NET/Enums.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ public enum CacheType
8383
public enum Sex
8484
{
8585
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
86-
未知 = 0,
87-
未设置 = 0,
88-
= 1,
89-
= 2,
90-
其他 = 3
86+
Unknow = 0,
87+
Unset = 0,
88+
Male = 1,
89+
Female = 2,
90+
Other = 3
9191
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
9292
}
9393

0 commit comments

Comments
 (0)