Пример #1
0
        public void GivenSortStrings_ContainsSortInstructions()
        {
            var query = new QueryStringCollectionQuery(new QueryStringConfiguration(), "sort=someDate+asc&sort=another+desc");

            Assert.Contains(query.SortInstructions, si => si.FieldName == "someDate" && si.Direction == SortDirection.Ascending);
            Assert.Contains(query.SortInstructions, si => si.FieldName == "another" && si.Direction == SortDirection.Descending);
        }
Пример #2
0
        public void GivenFilters_ContainsFilters()
        {
            var query = new QueryStringCollectionQuery(new QueryStringConfiguration(), "where=age>=25&where=age<45");

            Assert.Contains(query.FilterInstructions, fi => fi.FieldName == "age" && fi.Operator == FilterComparisonOperator.GreaterThanOrEquals && fi.ValueString == "25");
            Assert.Contains(query.FilterInstructions, fi => fi.FieldName == "age" && fi.Operator == FilterComparisonOperator.LessThan && fi.ValueString == "45");
        }
Пример #3
0
        public void GivenFieldsStringWithQuertionMark_ContainsFields()
        {
            var query = new QueryStringCollectionQuery(new QueryStringConfiguration(), "?fields=id,test,foo");

            Assert.Contains("id", query.SelectFields);
            Assert.Contains("test", query.SelectFields);
            Assert.Contains("foo", query.SelectFields);
        }
Пример #4
0
        public void SpecialKeysDisabled_GivenSpecialFilterKeys_DoesntContainFilters()
        {
            var query = new QueryStringCollectionQuery(new QueryStringConfiguration
            {
                SpecialFilterKeysEnabled = false
            }, "age>=25&age<45");

            Assert.Null(query.FilterInstructions);
        }
Пример #5
0
        public void SpecialKeysEnabled_GivenSpecialFilterKeys_ContainsFilters()
        {
            var query = new QueryStringCollectionQuery(new QueryStringConfiguration
            {
                SpecialFilterKeysEnabled = true
            }, "age>=25&age<45");

            Assert.Contains(query.FilterInstructions, fi => fi.FieldName == "age" && fi.Operator == FilterComparisonOperator.GreaterThanOrEquals && fi.ValueString == "25");
            Assert.Contains(query.FilterInstructions, fi => fi.FieldName == "age" && fi.Operator == FilterComparisonOperator.LessThan && fi.ValueString == "45");
        }
Пример #6
0
        public void GivenFieldsCollection_ContainsFields()
        {
            var query = new QueryStringCollectionQuery(new QueryStringConfiguration(), new NameValueCollection {
                { "fields", "test" },
                { "where", "age>25" },
            });

            Assert.Contains("test", query.SelectFields);
            Assert.Contains(query.FilterInstructions, fi => fi.FieldName == "age" && fi.Operator == FilterComparisonOperator.GreaterThan && fi.ValueString == "25");
        }
Пример #7
0
        public void GivenNoSpecificSortDirection_ContainsUnspecified()
        {
            var query = new QueryStringCollectionQuery(new QueryStringConfiguration(), "sort=column");

            Assert.Contains(query.SortInstructions, si => si.FieldName == "column" && si.Direction == SortDirection.Unspecified);
        }