public void PASS_Serialize_AllLatLon()
        {
            GeoPolygonFilter filter = new GeoPolygonFilter("field",
                new List<CoordinatePoint>(){
                    new CoordinatePoint(1.1, 1.1),
                    new CoordinatePoint(2.2, 2.2),
                    new CoordinatePoint(3.3, 3.3),
                });

            string json = JsonConvert.SerializeObject(filter);
            Assert.IsNotNull(json);

            string expectedJson = "{\"geo_polygon\":{\"field\":[{\"lat\":1.1,\"lon\":1.1},{\"lat\":2.2,\"lon\":2.2},{\"lat\":3.3,\"lon\":3.3}]}}";
            Assert.AreEqual(expectedJson, json);
        }
 public void FAIL_CreateFilter_Points()
 {
     try
     {
         GeoPolygonFilter filter = new GeoPolygonFilter("field",
         new List<CoordinatePoint>(){
             new CoordinatePoint(1.1, 1.1),
             null,
             new CoordinatePoint(3.3, 3.3),
         });
         Assert.Fail();
     }
     catch (ArgumentNullException ex)
     {
         Assert.AreEqual("polygonPoints", ex.ParamName);
     }
 }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            Dictionary<string, object> fieldDict = serializer.Deserialize<Dictionary<string, object>>(reader);
            if (fieldDict.ContainsKey(FilterTypeEnum.GeoPolygon.ToString()))
                fieldDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(fieldDict.First().Value.ToString());

            KeyValuePair<string, object> fieldKvp = fieldDict.FirstOrDefault(x => !_KnownFields.Contains(x.Key, StringComparer.OrdinalIgnoreCase));

            if (string.IsNullOrWhiteSpace(fieldKvp.Key))
                throw new RequiredPropertyMissingException("GeoPointProperty");

            IEnumerable<CoordinatePoint> points = CoordinatePointSerializer.DeserializeCollectionCoordinatePiont(fieldKvp.Value.ToString());

            GeoPolygonFilter filter = new GeoPolygonFilter(fieldKvp.Key, points);
            FilterSerializer.DeserializeBaseValues(filter, _CACHE_DEFAULT, fieldDict);

            return filter;
        }
        public void PASS_CreateFilter()
        {
            GeoPolygonFilter filter = new GeoPolygonFilter("field",
                new List<CoordinatePoint>(){
                    new CoordinatePoint(1.1, 1.1),
                    new CoordinatePoint(2.2, 2.2),
                    new CoordinatePoint(3.3, 3.3),
                });

            Assert.IsNotNull(filter);
            Assert.AreEqual("field", filter.Field);
            Assert.AreEqual(1.1, filter.PolygonPoints.First().Latitude);
            Assert.AreEqual(1.1, filter.PolygonPoints.First().Longitude);
            Assert.AreEqual(2.2, filter.PolygonPoints.ElementAt(1).Latitude);
            Assert.AreEqual(2.2, filter.PolygonPoints.ElementAt(1).Longitude);
            Assert.AreEqual(3.3, filter.PolygonPoints.Last().Latitude);
            Assert.AreEqual(3.3, filter.PolygonPoints.Last().Longitude);
        }
        public void PASS_Serialize_Mixed()
        {
            GeoPolygonFilter filter = new GeoPolygonFilter("field",
                new List<CoordinatePoint>(){
                    new CoordinatePoint(1.1, 1.1),
                    new CoordinatePoint("geohash"),
                    new CoordinatePoint(3.3, 3.3),
                });

            string json = JsonConvert.SerializeObject(filter);
            Assert.IsNotNull(json);

            string expectedJson = "{\"geo_polygon\":{\"field\":[\"1.1,1.1\",\"geohash\",\"3.3,3.3\"]}}";
            Assert.AreEqual(expectedJson, json);
        }