public void PASS_Serialize()
        {
            SpanNotQuery query = new SpanNotQuery(
                new SpanTermQuery("field", "value"),
                new SpanTermQuery("field2", "value"));

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

            string expectedJson = "{\"span_not\":{\"include\":{\"span_term\":{\"field\":\"value\"}},\"exclude\":{\"span_term\":{\"field2\":\"value\"}}}}";
            Assert.AreEqual(expectedJson, json);
        }
 public void FAIL_CreateQuery_Exclude()
 {
     try
     {
         SpanNotQuery query = new SpanNotQuery(new SpanTermQuery("field", "value"), null);
         Assert.Fail();
     }
     catch (ArgumentNullException ex)
     {
         Assert.AreEqual("exclude", ex.ParamName);
     }
 }
 public void FAIL_CreateQuery_Include()
 {
     try
     {
         SpanNotQuery query = new SpanNotQuery(null, null);
         Assert.Fail();
     }
     catch (ArgumentNullException ex)
     {
         Assert.AreEqual("include", 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(SpanQueryTypeEnum.Not.ToString()))
                fieldDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(fieldDict.First().Value.ToString());

            SpanNotQuery query = new SpanNotQuery(
                JsonConvert.DeserializeObject<SpanQueryBase>(fieldDict.GetString(_INCLUDE)),
                JsonConvert.DeserializeObject<SpanQueryBase>(fieldDict.GetString(_EXCLUDE)));

            query.QueryName = fieldDict.GetStringOrDefault(QuerySerializer._QUERY_NAME);

            return query;
        }
        public void PASS_CreateQuery()
        {
            SpanNotQuery query = new SpanNotQuery(
                new SpanTermQuery("field", "value"),
                new SpanTermQuery("field2", "value"));

            Assert.IsNotNull(query);
            Assert.IsTrue(query.Include is SpanTermQuery);
            Assert.IsTrue(query.Exclude is SpanTermQuery);
            SpanTermQuery include = query.Include as SpanTermQuery;
            SpanTermQuery exclude = query.Exclude as SpanTermQuery;
            Assert.AreEqual("field", include.Field);
            Assert.AreEqual("value", include.Value);
            Assert.AreEqual("field2", exclude.Field);
            Assert.AreEqual("value", exclude.Value);
        }