public void PASS_CreateQuery() { TermsQuery query = new TermsQuery("field", new List<object>() { "value1", "value2" }); Assert.IsNotNull(query); Assert.AreEqual("field", query.Field); Assert.AreEqual(2, query.Values.Count()); Assert.AreEqual(1, query.MinimumShouldMatch.GetValue()); }
public void PASS_Serialize() { TermsQuery query = new TermsQuery("field", new List<object>() { "value1", "value2" }); string json = JsonConvert.SerializeObject(query); Assert.IsNotNull(json); string expectedJson = "{\"terms\":{\"field\":[\"value1\",\"value2\"]}}"; Assert.AreEqual(expectedJson, json); }
public void FAIL_CreateQuery_Values() { try { TermsQuery query = new TermsQuery("field", null); Assert.Fail(); } catch (ArgumentNullException ex) { Assert.AreEqual("values", ex.ParamName); } }