Example #1
0
        public void Filter_ShouldFilterWhenEmpty(int number)
        {
            var Filter   = FilterTests.CreateFilter("");
            var selected = FilterTests.CreateCollection(number).AsQueryable <FilterTests.SimpleType>().Where <FilterTests.SimpleType>(Filter);

            Assert.Equal <int>(number, selected.Count <FilterTests.SimpleType>());
            Assert.Equal <string>("0", selected.First <FilterTests.SimpleType>().String);
        }
Example #2
0
        public void Filter_ShouldFindIntegerConstraintInSimpleNode(int number, int selection)
        {
            // WHERE /SimpleType/Integer==selection
            // simpleTypes.Integer==selection
            string constraint = string.Format(
                CultureInfo.InvariantCulture,
                "<ogc:PropertyIsEqualTo><ogc:PropertyName>/SimpleType/Integer</ogc:PropertyName><ogc:Literal>{0}</ogc:Literal></ogc:PropertyIsEqualTo>",
                selection
                );

            var Filter   = FilterTests.CreateFilter(constraint);
            var selected = FilterTests.CreateCollection(number).AsQueryable <FilterTests.SimpleType>().Where <FilterTests.SimpleType>(Filter);

            Assert.Equal <int>(1, selected.Count <FilterTests.SimpleType>());
            Assert.Equal <int>(selection, selected.First <FilterTests.SimpleType>().Integer);
        }
Example #3
0
        public void Filter_ShouldFindIntegerConstraint(string constraint, int elements, int threshold, int expectedNumber)
        {
            string c = string.Format(
                CultureInfo.InvariantCulture,
                "<ogc:PropertyIsGreaterThan><ogc:PropertyName>/SimpleType/Integer</ogc:PropertyName><ogc:Literal>{0}</ogc:Literal></ogc:PropertyIsGreaterThan>",
                threshold
                );

            var filter   = FilterTests.CreateFilter(c);
            var selected = FilterTests.CreateCollection(elements).AsQueryable <FilterTests.SimpleType>().Where <FilterTests.SimpleType>(filter);

            Assert.Equal <int>(expectedNumber, selected.Count <FilterTests.SimpleType>());
            foreach (FilterTests.SimpleType s in selected)
            {
                Assert.True(s.Integer > threshold);
            }
        }
Example #4
0
        public void Filter_ShouldFindIntegerConstraintInEnumerableNode(int number, int selection, int expectedNumber)
        {
            // WHERE /SimpleType/IntegerList==selection
            // simpleTypes.IntegerList.Any<int>(i => i==selection)
            string constraint = string.Format(
                CultureInfo.InvariantCulture,
                "<ogc:PropertyIsEqualTo><ogc:PropertyName>/SimpleType/IntegerList</ogc:PropertyName><ogc:Literal>{0}</ogc:Literal></ogc:PropertyIsEqualTo>",
                selection
                );

            var Filter   = FilterTests.CreateFilter(constraint);
            var selected = FilterTests.CreateCollection(number).AsQueryable <FilterTests.SimpleType>().Where <FilterTests.SimpleType>(Filter);

            Assert.Equal <int>(expectedNumber, selected.Count <FilterTests.SimpleType>());
            foreach (FilterTests.SimpleType t in selected)
            {
                Assert.True(t.IntegerList.Contains <int>(selection));
            }
        }