コード例 #1
0
        public void PASS_Serialize_Filter()
        {
            HasParentFilter filter = new HasParentFilter("child", new TermFilter("field", "value"));
            string json = JsonConvert.SerializeObject(filter);
            Assert.IsNotNull(json);

            string expectedJson = "{\"has_parent\":{\"parent_type\":\"child\",\"filter\":{\"term\":{\"field\":\"value\"}}}}";
            Assert.AreEqual(expectedJson, json);
        }
コード例 #2
0
 public void PASS_CreateFilter_Query()
 {
     HasParentFilter filter = new HasParentFilter("child", new TermQuery("field", "value"));
     Assert.IsNotNull("child", filter.ParentType);
     Assert.IsTrue(filter.Query is TermQuery);
     TermQuery termQuery = filter.Query as TermQuery;
     Assert.AreEqual("field", termQuery.Field);
     Assert.AreEqual("value", termQuery.Value);
 }
コード例 #3
0
 public void PASS_CreateFilter_Filter()
 {
     HasParentFilter filter = new HasParentFilter("child", new TermFilter("field", "value"));
     Assert.IsNotNull("child", filter.ParentType);
     Assert.IsTrue(filter.Filter is TermFilter);
     TermFilter termFilter = filter.Filter as TermFilter;
     Assert.AreEqual("field", termFilter.Field);
     Assert.AreEqual("value", termFilter.Value);
 }
コード例 #4
0
 public void FAIL_CreateFilter_Query()
 {
     try
     {
         HasParentFilter filter = new HasParentFilter("child", (IQuery)null);
         Assert.Fail();
     }
     catch (ArgumentNullException ex)
     {
         Assert.AreEqual("query", ex.ParamName);
     }
 }
コード例 #5
0
 public void FAIL_CreateFilter_ParentType()
 {
     try
     {
         HasParentFilter filter = new HasParentFilter(null, (IFilter)null);
         Assert.Fail();
     }
     catch (ArgumentNullException ex)
     {
         Assert.AreEqual("parentType", ex.ParamName);
     }
 }