Skip to content

Commit b48ec98

Browse files
Issue 44, Included GeoJSONObject Type property when DefaultValueHandling is set to Ignore
1 parent 673e939 commit b48ec98

3 files changed

Lines changed: 422 additions & 411 deletions

File tree

Lines changed: 85 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,86 @@
1-
using GeoJSON.Net.Geometry;
2-
using Newtonsoft.Json;
3-
using NUnit.Framework;
4-
5-
namespace GeoJSON.Net.Tests.Geometry
6-
{
7-
[TestFixture]
8-
public class PointTests : TestBase
9-
{
10-
[Test]
11-
public void Can_Serialize_With_Lat_Lon()
12-
{
13-
var point = new Point(new GeographicPosition(53.2455662, 90.65464646));
14-
15-
var expectedJson = "{\"coordinates\":[90.65464646,53.2455662],\"type\":\"Point\"}";
16-
17-
var actualJson = JsonConvert.SerializeObject(point);
18-
19-
JsonAssert.AreEqual(expectedJson, actualJson);
20-
}
21-
22-
[Test]
23-
public void Can_Serialize_With_Lat_Lon_Alt()
24-
{
25-
var point = new Point(new GeographicPosition(53.2455662, 90.65464646, 200.4567));
26-
27-
var expectedJson = "{\"coordinates\":[90.65464646,53.2455662,200.4567],\"type\":\"Point\"}";
28-
29-
var actualJson = JsonConvert.SerializeObject(point);
30-
31-
JsonAssert.AreEqual(expectedJson, actualJson);
32-
}
33-
34-
[Test]
35-
public void Can_Deserialize_With_Lat_Lon_Alt()
36-
{
37-
var json = "{\"coordinates\":[90.65464646,53.2455662,200.4567],\"type\":\"Point\"}";
38-
39-
var expectedPoint = new Point(new GeographicPosition(53.2455662, 90.65464646, 200.4567));
40-
41-
var actualPoint = JsonConvert.DeserializeObject<Point>(json);
42-
43-
Assert.AreEqual(expectedPoint, actualPoint);
44-
}
45-
46-
[Test]
47-
public void Can_Deserialize_With_Lat_Lon()
48-
{
49-
var json = "{\"coordinates\":[90.65464646,53.2455662],\"type\":\"Point\"}";
50-
51-
var expectedPoint = new Point(new GeographicPosition(53.2455662, 90.65464646));
52-
53-
var actualPoint = JsonConvert.DeserializeObject<Point>(json);
54-
55-
Assert.AreEqual(expectedPoint, actualPoint);
56-
}
57-
58-
[Test]
59-
public void Equals_GetHashCode_Contract()
60-
{
61-
var json = "{\"coordinates\":[90.65464646,53.2455662],\"type\":\"Point\"}";
62-
63-
var expectedPoint = new Point(new GeographicPosition(53.2455662, 90.65464646));
64-
65-
var actualPoint = JsonConvert.DeserializeObject<Point>(json);
66-
67-
Assert.AreEqual(expectedPoint, actualPoint);
68-
Assert.IsTrue(expectedPoint.Equals(actualPoint));
69-
Assert.IsTrue(actualPoint.Equals(expectedPoint));
70-
71-
Assert.AreEqual(expectedPoint.GetHashCode(), actualPoint.GetHashCode());
72-
}
73-
74-
}
1+
using GeoJSON.Net.Geometry;
2+
using Newtonsoft.Json;
3+
using NUnit.Framework;
4+
5+
namespace GeoJSON.Net.Tests.Geometry
6+
{
7+
[TestFixture]
8+
public class PointTests : TestBase
9+
{
10+
[Test]
11+
public void Can_Serialize_With_Lat_Lon()
12+
{
13+
var point = new Point(new GeographicPosition(53.2455662, 90.65464646));
14+
15+
var expectedJson = "{\"coordinates\":[90.65464646,53.2455662],\"type\":\"Point\"}";
16+
17+
var actualJson = JsonConvert.SerializeObject(point);
18+
19+
JsonAssert.AreEqual(expectedJson, actualJson);
20+
}
21+
22+
[Test]
23+
public void Can_Serialize_With_Lat_Lon_Alt()
24+
{
25+
var point = new Point(new GeographicPosition(53.2455662, 90.65464646, 200.4567));
26+
27+
var expectedJson = "{\"coordinates\":[90.65464646,53.2455662,200.4567],\"type\":\"Point\"}";
28+
29+
var actualJson = JsonConvert.SerializeObject(point);
30+
31+
JsonAssert.AreEqual(expectedJson, actualJson);
32+
}
33+
34+
[Test]
35+
public void Can_Deserialize_With_Lat_Lon_Alt()
36+
{
37+
var json = "{\"coordinates\":[90.65464646,53.2455662,200.4567],\"type\":\"Point\"}";
38+
39+
var expectedPoint = new Point(new GeographicPosition(53.2455662, 90.65464646, 200.4567));
40+
41+
var actualPoint = JsonConvert.DeserializeObject<Point>(json);
42+
43+
Assert.AreEqual(expectedPoint, actualPoint);
44+
}
45+
46+
[Test]
47+
public void Can_Deserialize_With_Lat_Lon()
48+
{
49+
var json = "{\"coordinates\":[90.65464646,53.2455662],\"type\":\"Point\"}";
50+
51+
var expectedPoint = new Point(new GeographicPosition(53.2455662, 90.65464646));
52+
53+
var actualPoint = JsonConvert.DeserializeObject<Point>(json);
54+
55+
Assert.AreEqual(expectedPoint, actualPoint);
56+
}
57+
58+
[Test]
59+
public void Equals_GetHashCode_Contract()
60+
{
61+
var json = "{\"coordinates\":[90.65464646,53.2455662],\"type\":\"Point\"}";
62+
63+
var expectedPoint = new Point(new GeographicPosition(53.2455662, 90.65464646));
64+
65+
var actualPoint = JsonConvert.DeserializeObject<Point>(json);
66+
67+
Assert.AreEqual(expectedPoint, actualPoint);
68+
Assert.IsTrue(expectedPoint.Equals(actualPoint));
69+
Assert.IsTrue(actualPoint.Equals(expectedPoint));
70+
71+
Assert.AreEqual(expectedPoint.GetHashCode(), actualPoint.GetHashCode());
72+
}
73+
74+
[Test]
75+
public void Can_Serialize_With_Lat_Lon_Alt_DefaultValueHandling_Ignore()
76+
{
77+
var point = new Point(new GeographicPosition(53.2455662, 90.65464646, 200.4567));
78+
79+
var expectedJson = "{\"coordinates\":[90.65464646,53.2455662,200.4567],\"type\":\"Point\"}";
80+
81+
var actualJson = JsonConvert.SerializeObject(point, new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore });
82+
83+
JsonAssert.AreEqual(expectedJson, actualJson);
84+
}
85+
}
7586
}

0 commit comments

Comments
 (0)