public void FAIL_CreateFilter_Script()
 {
     try
     {
         ScriptFilter filter = new ScriptFilter(null);
         Assert.Fail();
     }
     catch (ArgumentNullException ex)
     {
         Assert.AreEqual("script", ex.ParamName);
     }
 }
        public void PASS_Serializer()
        {
            ScriptFilter filter = new ScriptFilter(new Scripts.Script("script")
            {
                Parameters = new List<ScriptParameter>()
                {
                    new ScriptParameter("field", "value")
                }
            });

            string json = JsonConvert.SerializeObject(filter);
            Assert.IsNotNull(json);
            string expectedJson = "{\"script\":{\"script\":\"script\",\"params\":{\"field\":\"value\"}}}";
            Assert.AreEqual(expectedJson, json);
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            // why can script have the same name as its property... dumb.
            Dictionary<string, object> fieldDict = serializer.Deserialize<Dictionary<string, object>>(reader);
            if(fieldDict.ContainsKey(FilterTypeEnum.Script.ToString()))
            {
                try
                {
                    fieldDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(fieldDict.First().Value.ToString());
                }
                catch { }
            }

            ScriptFilter filter = new ScriptFilter(fieldDict.DeserializeObject<Bolay.Elastic.Scripts.Script>());

            FilterSerializer.DeserializeBaseValues(filter, _CACHE_DEFAULT, fieldDict);
            return filter;
        }
 public void PASS_CreateFilter()
 {
     ScriptFilter filter = new ScriptFilter(new Scripts.Script("script"));
     Assert.IsNotNull(filter);
     Assert.AreEqual("script", filter.Script.ScriptText);
 }