Exemplo n.º 1
0
        public void Should_return_filter_When_logical_filter_has_one_child()
        {
            var source = ClrFilter.And(ClrFilter.Eq("path", 1), ClrFilter.Or());

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

            Assert.Equal("path == 1", result.ToString());
        }
Exemplo n.º 2
0
        public void Should_not_convert_optimize_valid_logical_filter()
        {
            var source = ClrFilter.Or(ClrFilter.Eq("path", 2), ClrFilter.Eq("path", 3));

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

            Assert.Equal("(path == 2 || path == 3)", result.ToString());
        }
Exemplo n.º 3
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);
        }