public void PASS_Create()
 {
     MissingAggregate agg = new MissingAggregate("missing-name", "field");
     Assert.IsNotNull(agg);
     Assert.AreEqual("missing-name", agg.Name);
     Assert.AreEqual("field", agg.Field);
 }
        public void PASS_Serialize()
        {
            MissingAggregate agg = new MissingAggregate("missing-name", "field");
            string json = JsonConvert.SerializeObject(agg);
            Assert.IsNotNull(json);

            string expectedJson = "{\"missing-name\":{\"missing\":{\"field\":\"field\"}}}";
            Assert.AreEqual(expectedJson, json);
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            Dictionary<string, object> wholeDict = serializer.Deserialize<Dictionary<string, object>>(reader);
            Dictionary<string, object> aggDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(wholeDict.First().Value.ToString());
            Dictionary<string, object> missingDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(aggDict.GetString(AggregationTypeEnum.Missing.ToString()));

            MissingAggregate agg = new MissingAggregate(wholeDict.First().Key, missingDict.GetString(_FIELD));
            agg.SubAggregations = BucketAggregationBase.DeserializeSubAggregations(aggDict);
            return agg;
        }
        public void PASS_Serialize_Aggs()
        {
            MissingAggregate agg = new MissingAggregate("missing-name", "field")
            {
                SubAggregations = new List<IAggregation>() 
                { 
                    new SumAggregate("sum-name", "field")
                }
            };
            string json = JsonConvert.SerializeObject(agg);
            Assert.IsNotNull(json);

            string expectedJson = "{\"missing-name\":{\"missing\":{\"field\":\"field\"},\"aggregations\":{\"sum-name\":{\"sum\":{\"field\":\"field\"}}}}}";
            Assert.AreEqual(expectedJson, json);
        }