public void PASS_Serialize()
        {
            GeoShapeFilter filter = new GeoShapeFilter("field", new Point(new CoordinatePoint(1.1, 2.2)));
            string json = JsonConvert.SerializeObject(filter);
            Assert.IsNotNull(json);

            string expectedJson = "{\"geo_shape\":{\"field\":{\"shape\":{\"type\":\"point\",\"coordinates\":[2.2,1.1]}}}}";
            Assert.AreEqual(expectedJson, json);
        }
 public void PASS_CreateQuery()
 {
     GeoShapeFilter filter = new GeoShapeFilter("field", new Point(new CoordinatePoint(1.1, 2.2)));
     Assert.IsNotNull(filter);
     Assert.AreEqual("field", filter.Field);
     Assert.IsTrue(filter.GeoShape is Point);
     Assert.AreEqual(1.1, (filter.GeoShape as Point).Coordinate.Latitude);
     Assert.AreEqual(2.2, (filter.GeoShape as Point).Coordinate.Longitude);
 }
 public void FAIL_CreateQuery_GeoShape()
 {
     try
     {
         GeoShapeFilter query = new GeoShapeFilter("field", null);
         Assert.Fail();
     }
     catch (ArgumentNullException argEx)
     {
         Assert.AreEqual("geoShape", argEx.ParamName);
     }
 }
 public void FAIL_CreateQuery_Field()
 {
     try
     {
         GeoShapeFilter filter = new GeoShapeFilter(null, new Point(new CoordinatePoint(1.1, 2.2)));
         Assert.Fail();
     }
     catch (ArgumentNullException argEx)
     {
         Assert.AreEqual("field", argEx.ParamName);
     }
 }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            Dictionary<string, object> shapeDict = serializer.Deserialize<Dictionary<string, object>>(reader);
            if (shapeDict.ContainsKey(_GEO_SHAPE))
                shapeDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(shapeDict.First().Value.ToString());

            string fieldName = shapeDict.First().Key;
            GeoShapeBase shape = JsonConvert.DeserializeObject<GeoShapeBase>(shapeDict.First().Value.ToString());

            GeoShapeFilter filter = new GeoShapeFilter(fieldName, shape); 
            FilterSerializer.DeserializeBaseValues(filter, _CACHE_DEFAULT, shapeDict);
            return filter;
        }