コード例 #1
0
        public async Task Should_return_result_to_schema_and_contents_if_matching_and_permission_given()
        {
            var permission = Permissions.ForApp(Permissions.AppContentsRead, appId.Name, "schemaA2");

            var ctx = ContextWithPermission(permission.Id);

            var schema1 = CreateSchema("schemaA1", false);
            var schema2 = CreateSchema("schemaA2", false);
            var schema3 = CreateSchema("schemaB2", false);

            A.CallTo(() => appProvider.GetSchemasAsync(appId.Id))
            .Returns(new List <ISchemaEntity> {
                schema1, schema2, schema3
            });

            A.CallTo(() => urlGenerator.SchemaUI(appId, schema1.NamedId()))
            .Returns("schemaA1-url");

            A.CallTo(() => urlGenerator.SchemaUI(appId, schema2.NamedId()))
            .Returns("schemaA2-url");

            A.CallTo(() => urlGenerator.ContentsUI(appId, schema2.NamedId()))
            .Returns("schemaA2-contents-url");

            var result = await sut.SearchAsync("schemaA", ctx);

            result.Should().BeEquivalentTo(
                new SearchResults()
                .Add("schemaA1 Schema", SearchResultType.Schema, "schemaA1-url")
                .Add("schemaA2 Schema", SearchResultType.Schema, "schemaA2-url")
                .Add("schemaA2 Contents", SearchResultType.Content, "schemaA2-contents-url", "schemaA2"));
        }
コード例 #2
0
        public async Task Should_always_return_contents_result_if_matching()
        {
            var ctx = ContextWithPermission();

            A.CallTo(() => urlGenerator.ContentsUI(appId))
            .Returns("contents-url");

            var result = await sut.SearchAsync("content", ctx);

            result.Should().BeEquivalentTo(
                new SearchResults()
                .Add("Contents", SearchResultType.Content, "contents-url"));
        }
コード例 #3
0
        private void AddContentsUrl(SearchResults result, NamedId <DomainId> appId, ISchemaEntity schema, NamedId <DomainId> schemaId, string name)
        {
            if (schema.SchemaDef.Type == SchemaType.Singleton)
            {
                var contentUrl = urlGenerator.ContentUI(appId, schemaId, schemaId.Id);

                result.Add(T.Get("search.contentResult", new { name }), SearchResultType.Content, contentUrl, name);
            }
            else
            {
                var contentUrl = urlGenerator.ContentsUI(appId, schemaId);

                result.Add(T.Get("search.contentsResult", new { name }), SearchResultType.Content, contentUrl, name);
            }
        }
コード例 #4
0
ファイル: SchemasSearchSource.cs プロジェクト: teksoi/squidex
        private void AddContentsUrl(SearchResults result, NamedId <Guid> appId, ISchemaEntity schema, NamedId <Guid> schemaId, string name)
        {
            if (schema.SchemaDef.IsSingleton)
            {
                var contentUrl = urlGenerator.ContentUI(appId, schemaId, schemaId.Id);

                result.Add($"{name} Content", SearchResultType.Content, contentUrl, name);
            }
            else
            {
                var contentUrl = urlGenerator.ContentsUI(appId, schemaId);

                result.Add($"{name} Contents", SearchResultType.Content, contentUrl, name);
            }
        }