private GeographyPoint DeserializeAndExpectSuccess(string json) { JObject dynamicPoint = JsonConvert.DeserializeObject <JObject>(json); Assert.True( GeographyPointConverter.IsGeoJson(dynamicPoint), $"Expected given JSON to be recognized as Geo-JSON: <{json}>"); return(JsonConvert.DeserializeObject <GeographyPoint>(json, _jsonSettings)); }
private void DeserializeAndExpectFailure(string json) { JObject dynamicPoint = JsonConvert.DeserializeObject <JObject>(json); Assert.False( GeographyPointConverter.IsGeoJson(dynamicPoint), $"Expected given JSON to NOT be recognized as Geo-JSON: <{json}>"); Assert.Throws <JsonSerializationException>(() => JsonConvert.DeserializeObject <GeographyPoint>(json, _jsonSettings)); }
public void ReadNullReturnsNull() { const string Json = "null"; // This is the one case where you can deserialize something to a GeographyPoint that isn't recognized as Geo-JSON. JObject dynamicPoint = JsonConvert.DeserializeObject <JObject>(Json); Assert.Null(dynamicPoint); Assert.False(GeographyPointConverter.IsGeoJson(dynamicPoint), "Null should not be recognized as Geo-JSON"); var point = JsonConvert.DeserializeObject <GeographyPoint>(Json, _jsonSettings); Assert.Null(point); }