Skip to content

Commit 791815b

Browse files
committed
Add missing test & address compiler warning
1 parent 50613f3 commit 791815b

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

test/JsonMapperTest.cs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class EmptyArrayInJsonDataTest
210210

211211
class EmptyArrayInJsonDataTestWrapper
212212
{
213-
public JsonData data;
213+
public JsonData data = null;
214214
}
215215

216216
[TestFixture]
@@ -321,13 +321,13 @@ public void ExportEnumsTest ()
321321
public void ExportEnumDictionaryTest()
322322
{
323323
Dictionary<Planets, int> planets = new Dictionary<Planets, int>();
324-
324+
325325
planets.Add(Planets.Jupiter, 5);
326326
planets.Add(Planets.Saturn, 6);
327327
planets.Add(Planets.Uranus, 7);
328328
planets.Add(Planets.Neptune, 8);
329329
planets.Add(Planets.Pluto, 9);
330-
330+
331331
string json = JsonMapper.ToJson(planets);
332332

333333
Assert.AreEqual("{\"Jupiter\":5,\"Saturn\":6,\"Uranus\":7,\"Neptune\":8,\"Pluto\":9}", json);
@@ -428,7 +428,7 @@ public void ExportValueTypesTest ()
428428
test.TestUInt = 90000000;
429429
test.TestULong = 0xFFFFFFFFFFFFFFFF; // = =18446744073709551615
430430
test.TestDateTimeOffset =
431-
new DateTimeOffset(2019, 9, 18, 16, 47,
431+
new DateTimeOffset(2019, 9, 18, 16, 47,
432432
50, 123, TimeSpan.FromHours(8)).AddTicks(4567);
433433

434434
string json = JsonMapper.ToJson (test);
@@ -882,7 +882,7 @@ public void ImportValueTypesTest ()
882882
Assert.AreEqual (90000000, test.TestUInt, "A8");
883883
Assert.AreEqual (18446744073709551615L, test.TestULong, "A9");
884884
Assert.AreEqual(
885-
new DateTimeOffset(2019, 9, 18, 16, 47,
885+
new DateTimeOffset(2019, 9, 18, 16, 47,
886886
50, 123, TimeSpan.FromHours(8)).AddTicks(4567),
887887
test.TestDateTimeOffset, "A10");
888888
}
@@ -1070,7 +1070,7 @@ public void NullableEnumExportTest()
10701070
expectedJson = "{\"TestEnum\":null}";
10711071
Assert.AreEqual(expectedJson, JsonMapper.ToJson(value));
10721072
}
1073-
1073+
10741074
[Test]
10751075
public void EmptyArrayInJsonDataExportTest()
10761076
{
@@ -1082,11 +1082,22 @@ public void EmptyArrayInJsonDataExportTest()
10821082
""name"": ""testName""
10831083
}
10841084
}";
1085-
1085+
10861086
var response = JsonMapper.ToObject<EmptyArrayInJsonDataTestWrapper>(testJson);
10871087
var toJsonResult = response.data.ToJson();
10881088
string expectedJson = "{\"array\":[],\"name\":\"testName\"}";
10891089
Assert.AreEqual(toJsonResult, expectedJson);
1090-
}
1090+
}
1091+
1092+
[Test]
1093+
public void EmptyArrayInJsonDataTest()
1094+
{
1095+
var toJsonResult = JsonMapper.ToJson(new EmptyArrayInJsonDataTest {
1096+
name = "testName",
1097+
array = new int[0]
1098+
});
1099+
string expectedJson = "{\"array\":[],\"name\":\"testName\"}";
1100+
Assert.AreEqual(toJsonResult, expectedJson);
1101+
}
10911102
}
10921103
}

0 commit comments

Comments
 (0)