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); }
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); }
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); }
public void FAIL_CreateFilter_Query() { try { HasParentFilter filter = new HasParentFilter("child", (IQuery)null); Assert.Fail(); } catch (ArgumentNullException ex) { Assert.AreEqual("query", ex.ParamName); } }
public void FAIL_CreateFilter_ParentType() { try { HasParentFilter filter = new HasParentFilter(null, (IFilter)null); Assert.Fail(); } catch (ArgumentNullException ex) { Assert.AreEqual("parentType", ex.ParamName); } }