Ejemplo n.º 1
0
        public void Should_invert_notequals_not_filter()
        {
            var source = ClrFilter.Not(ClrFilter.Ne("path", 1));

            var result = Optimizer <ClrValue> .Optimize(source);

            Assert.Equal("path == 1", result.ToString());
        }
Ejemplo n.º 2
0
        public void Should_not_convert_number_operator()
        {
            var source = ClrFilter.Not(ClrFilter.Lt("path", 1));

            var result = Optimizer <ClrValue> .Optimize(source);

            Assert.Equal("!(path < 1)", result.ToString());
        }
Ejemplo n.º 3
0
        public void Should_return_null_when_filter_of_negation_get_optimized_away()
        {
            var source = ClrFilter.Not(ClrFilter.And());

            var result = Optimizer <ClrValue> .Optimize(source);

            Assert.Null(result);
        }
Ejemplo n.º 4
0
        public void Should_add_fields_from_filters()
        {
            var query = new ClrQuery
            {
                Filter =
                    ClrFilter.And(
                        ClrFilter.Not(
                            ClrFilter.Eq("field1", 1)),
                        ClrFilter.Or(
                            ClrFilter.Eq("field2", 2),
                            ClrFilter.Eq("field2", 4)))
            };

            var fields = query.GetAllFields();

            var expected = new HashSet <string>
            {
                "field1",
                "field2"
            };

            Assert.Equal(expected, fields);
        }