public void PASS_Serialize() { FilteredQuery query = new FilteredQuery( new TermQuery("field", "value"), new TermFilter("field", "value") ); string json = JsonConvert.SerializeObject(query); Assert.IsNotNull(json); string expectedJson = "{\"filtered\":{\"query\":{\"term\":{\"field\":\"value\"}},\"filter\":{\"term\":{\"field\":\"value\"}}}}"; Assert.AreEqual(expectedJson, json); }
public void PASS_CreateQuery() { FilteredQuery query = new FilteredQuery( new TermQuery("field", "value"), new TermFilter("field", "value") ); Assert.IsNotNull(query); Assert.AreEqual("field", (query.Query as TermQuery).Field); Assert.AreEqual("value", (query.Query as TermQuery).Value); Assert.AreEqual("field", (query.Filter as TermFilter).Field); Assert.AreEqual("value", (query.Filter as TermFilter).Value); }
public void FAIL_CreateQuery_Filter() { try { FilteredQuery query = new FilteredQuery( new TermQuery("field", "value"), null ); Assert.Fail(); } catch (ArgumentNullException argEx) { Assert.AreEqual("filter", argEx.ParamName); } }