Skip to content

Commit

Permalink
Add missing test & address compiler warning
Browse files Browse the repository at this point in the history
  • Loading branch information
devlead committed Jan 22, 2020
1 parent 50613f3 commit 791815b
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions test/JsonMapperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class EmptyArrayInJsonDataTest

class EmptyArrayInJsonDataTestWrapper
{
public JsonData data;
public JsonData data = null;
}

[TestFixture]
Expand Down Expand Up @@ -321,13 +321,13 @@ public void ExportEnumsTest ()
public void ExportEnumDictionaryTest()
{
Dictionary<Planets, int> planets = new Dictionary<Planets, int>();

planets.Add(Planets.Jupiter, 5);
planets.Add(Planets.Saturn, 6);
planets.Add(Planets.Uranus, 7);
planets.Add(Planets.Neptune, 8);
planets.Add(Planets.Pluto, 9);

string json = JsonMapper.ToJson(planets);

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

string json = JsonMapper.ToJson (test);
Expand Down Expand Up @@ -882,7 +882,7 @@ public void ImportValueTypesTest ()
Assert.AreEqual (90000000, test.TestUInt, "A8");
Assert.AreEqual (18446744073709551615L, test.TestULong, "A9");
Assert.AreEqual(
new DateTimeOffset(2019, 9, 18, 16, 47,
new DateTimeOffset(2019, 9, 18, 16, 47,
50, 123, TimeSpan.FromHours(8)).AddTicks(4567),
test.TestDateTimeOffset, "A10");
}
Expand Down Expand Up @@ -1070,7 +1070,7 @@ public void NullableEnumExportTest()
expectedJson = "{\"TestEnum\":null}";
Assert.AreEqual(expectedJson, JsonMapper.ToJson(value));
}

[Test]
public void EmptyArrayInJsonDataExportTest()
{
Expand All @@ -1082,11 +1082,22 @@ public void EmptyArrayInJsonDataExportTest()
""name"": ""testName""
}
}";

var response = JsonMapper.ToObject<EmptyArrayInJsonDataTestWrapper>(testJson);
var toJsonResult = response.data.ToJson();
string expectedJson = "{\"array\":[],\"name\":\"testName\"}";
Assert.AreEqual(toJsonResult, expectedJson);
}
}

[Test]
public void EmptyArrayInJsonDataTest()
{
var toJsonResult = JsonMapper.ToJson(new EmptyArrayInJsonDataTest {
name = "testName",
array = new int[0]
});
string expectedJson = "{\"array\":[],\"name\":\"testName\"}";
Assert.AreEqual(toJsonResult, expectedJson);
}
}
}

0 comments on commit 791815b

Please sign in to comment.