| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,16 @@ | |||
| 1 | + using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
| 2 | + using Newtonsoft.Json; | ||
| 3 | + using Newtonsoft.Json.Serialization; | ||
| 4 | + using System; | ||
| 5 | + using System.Collections.Generic; | ||
| 6 | + using System.Linq; | ||
| 7 | + using System.Text; | ||
| 8 | + | ||
| 9 | + namespace GeoJSON.Net.Tests | ||
| 10 | + { | ||
| 11 | + [TestClass] | ||
| 12 | + public class DeserializationTest | ||
| 13 | + { | ||
| 14 | + | ||
| 15 | + } | ||
| 16 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,6 +46,7 @@ | |||
| 46 | 46 | </Reference> | |
| 47 | 47 | </ItemGroup> | |
| 48 | 48 | <ItemGroup> | |
| 49 | + <Compile Include="DeserializationTest.cs" /> | ||
| 49 | 50 | <Compile Include="MiscTest.cs" /> | |
| 50 | 51 | <Compile Include="Properties\AssemblyInfo.cs" /> | |
| 51 | 52 | <Compile Include="SerializationTest.cs" /> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,6 +42,22 @@ public void PolygonSerialization() | |||
| 42 | 42 | Assert.IsTrue(!serializedData.Contains("latitude")); | |
| 43 | 43 | } | |
| 44 | 44 | ||
| 45 | + [TestMethod] | ||
| 46 | + public void GeographicPositionSerialization() | ||
| 47 | + { | ||
| 48 | + var model = new GeoJSON.Net.Geometry.GeographicPosition(112.12, 10); | ||
| 49 | + | ||
| 50 | + var serialized = JsonConvert.SerializeObject(model, Formatting.Indented, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); | ||
| 51 | + | ||
| 52 | + var matches = Regex.Matches(serialized, @"(\d+.\d+)"); | ||
| 53 | + Assert.IsTrue(matches.Count == 2); | ||
| 54 | + double lng= 0; | ||
| 55 | + double.TryParse(matches[0].Value, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out lng); | ||
| 56 | + | ||
| 57 | + Assert.AreEqual(lng, 112.12); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + | ||
| 45 | 61 | [TestMethod] | |
| 46 | 62 | public void PolygonDeserialization() | |
| 47 | 63 | { | |
@@ -146,10 +162,8 @@ public void PointDeserialization() | |||
| 146 | 162 | ||
| 147 | 163 | Assert.IsTrue(coordinates.Longitude - 165.3173828125 < 0.0001); | |
| 148 | 164 | Assert.IsTrue(coordinates.Latitude + 52.379790828551016 < 0.0001); | |
| 149 | - | ||
| 150 | 165 | } | |
| 151 | 166 | ||
| 152 | - | ||
| 153 | 167 | [TestMethod] | |
| 154 | 168 | public void PointFeatureDeserialization() | |
| 155 | 169 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,7 @@ | |||
| 1 | 1 | using Newtonsoft.Json; | |
| 2 | 2 | namespace GeoJSON.Net.Geometry | |
| 3 | 3 | { | |
| 4 | - [JsonArray] | ||
| 4 | + //[JsonArray] | ||
| 5 | 5 | public interface IPosition | |
| 6 | 6 | { | |
| 7 | 7 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,7 +47,6 @@ public Point(IPosition coordinates) | |||
| 47 | 47 | ||
| 48 | 48 | [JsonProperty(PropertyName = "coordinates", Required = Required.Always)] | |
| 49 | 49 | [JsonConverter(typeof(PointConverter))] | |
| 50 | - | ||
| 51 | 50 | public IPosition Coordinates { get; set; } | |
| 52 | 51 | } | |
| 53 | 52 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments