Exemplo n.º 1
0
        public void Range_query_must_transform_correclty_to_ES()
        {
            var query = new RangeQuery("date", "now-1d", "now");

            Assert.IsTrue(query.Field == "date");
            Assert.IsTrue(query.Values.From.Value.ToString() == "now-1d");
            Assert.IsTrue(query.Values.To.Value.ToString() == "now");

            string json = query.ToString();
            var    jo   = JsonObject.Parse(json);
            var    q    = jo.ToQuery();

            Assert.IsTrue(q.Type == QueryType.RangeQuery);
            query = q as RangeQuery;
            Assert.IsTrue(query.Field == "date");
            Assert.IsTrue(query.Values.From.Value.ToString() == "now-1d");
            Assert.IsTrue(query.Values.To.Value.ToString() == "now");

            query = new RangeQuery("date", new RangeValues(new RangeValue("now-1d", false), null));
            Assert.IsTrue(query.Field == "date");
            Assert.IsTrue(query.Values.From.Value.ToString() == "now-1d");
            Assert.IsFalse(query.Values.From.Include);

            json = query.ToString();
            jo   = JsonObject.Parse(json);
            q    = jo.ToQuery();
            Assert.IsTrue(q.Type == QueryType.RangeQuery);
            query = q as RangeQuery;
            Assert.IsTrue(query.Field == "date");
            Assert.IsTrue(query.Values.From.Value.ToString() == "now-1d");
            Assert.IsFalse(query.Values.From.Include);
        }
Exemplo n.º 2
0
 protected void ToString(List <string> toStringOutput)
 {
     toStringOutput.Add($"SortedAttributeQuery = {(SortedAttributeQuery == null ? "null" : SortedAttributeQuery.ToString())}");
     toStringOutput.Add($"ExactQuery = {(ExactQuery == null ? "null" : ExactQuery.ToString())}");
     toStringOutput.Add($"SetQuery = {(SetQuery == null ? "null" : SetQuery.ToString())}");
     toStringOutput.Add($"PrefixQuery = {(PrefixQuery == null ? "null" : PrefixQuery.ToString())}");
     toStringOutput.Add($"RangeQuery = {(RangeQuery == null ? "null" : RangeQuery.ToString())}");
     toStringOutput.Add($"TextQuery = {(TextQuery == null ? "null" : TextQuery.ToString())}");
     toStringOutput.Add($"ItemsForTaxQuery = {(ItemsForTaxQuery == null ? "null" : ItemsForTaxQuery.ToString())}");
     toStringOutput.Add($"ItemsForModifierListQuery = {(ItemsForModifierListQuery == null ? "null" : ItemsForModifierListQuery.ToString())}");
     toStringOutput.Add($"ItemsForItemOptionsQuery = {(ItemsForItemOptionsQuery == null ? "null" : ItemsForItemOptionsQuery.ToString())}");
     toStringOutput.Add($"ItemVariationsForItemOptionValuesQuery = {(ItemVariationsForItemOptionValuesQuery == null ? "null" : ItemVariationsForItemOptionValuesQuery.ToString())}");
 }