示例#1
0
        public void Should_use_existing_query()
        {
            var clrQuery = new ClrQuery();

            var parsed = sut.ParseQuery(requestContext, schema, Q.Empty.WithQuery(clrQuery));

            Assert.Same(parsed, clrQuery);
        }
        public ContentQueryServiceTests()
        {
            user = new ClaimsPrincipal(identity);

            app = Mocks.App(appId);

            requestContext = new Context(user, app);

            var schemaDef =
                new Schema(schemaId.Name)
                .ConfigureScripts(new SchemaScripts {
                Query = "<query-script>"
            });

            schema = Mocks.Schema(appId, schemaId, schemaDef);

            SetupEnricher();

            A.CallTo(() => queryParser.ParseQuery(requestContext, schema, A <Q> .Ignored))
            .Returns(new ClrQuery());

            sut = new ContentQueryService(
                appProvider,
                urlGenerator,
                contentEnricher,
                contentRepository,
                contentVersionLoader,
                scriptEngine,
                queryParser);
        }
示例#3
0
        public ContentQueryServiceTests()
        {
            var schemaDef =
                new Schema(schemaId.Name)
                .SetScripts(new SchemaScripts {
                Query = "<query-script>"
            });

            schema = Mocks.Schema(appId, schemaId, schemaDef);

            SetupEnricher();

            A.CallTo(() => appProvider.GetSchemaAsync(appId.Id, schemaId.Name))
            .Returns(schema);

            A.CallTo(() => queryParser.ParseQuery(A <Context> ._, schema, A <Q> ._))
            .Returns(new ClrQuery());

            sut = new ContentQueryService(
                appProvider,
                contentEnricher,
                contentRepository,
                contentVersionLoader,
                queryParser);
        }
        private async Task <IResultList <IContentEntity> > QueryByQueryAsync(Context context, ISchemaEntity schema, Q query)
        {
            var parsedQuery = queryParser.ParseQuery(context, schema, query);

            return(await QueryCoreAsync(context, schema, parsedQuery));
        }
示例#5
0
        public void Should_throw_if_odata_query_is_invalid()
        {
            var query = Q.Empty.WithODataQuery("$filter=invalid");

            Assert.Throws <ValidationException>(() => sut.ParseQuery(requestContext, schema, query));
        }
示例#6
0
        public void Should_apply_default_page_size()
        {
            var query = Q.Empty;

            var parsed = sut.ParseQuery(requestContext, schema, query);

            Assert.Equal("Take: 30; Sort: lastModified Descending", parsed.ToString());
        }