コード例 #1
0
 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());
 }
コード例 #2
0
        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);
        }
コード例 #3
0
 public void FAIL_CreateQuery_Values()
 {
     try
     {
         TermsQuery query = new TermsQuery("field", null);
         Assert.Fail();
     }
     catch (ArgumentNullException ex)
     {
         Assert.AreEqual("values", ex.ParamName);
     }
 }