Esempio n. 1
0
 private ContentQueryContext Context()
 {
     return(new ContentQueryContext(QueryContext.Create(App, User)
                                    .WithLanguages(Request.Headers["X-Languages"]))
            .WithFlatten(Request.Headers.ContainsKey("X-Flatten"))
            .WithUnpublished(Request.Headers.ContainsKey("X-Unpublished")));
 }
Esempio n. 2
0
 private QueryContext Context()
 {
     return(QueryContext.Create(App, User)
            .WithAssetUrlsToResolve(Request.Headers["X-Resolve-Urls"])
            .WithFlatten(Request.Headers.ContainsKey("X-Flatten"))
            .WithLanguages(Request.Headers["X-Languages"])
            .WithUnpublished(Request.Headers.ContainsKey("X-Unpublished")));
 }
Esempio n. 3
0
        public GraphQLTestBase()
        {
            schemaDef =
                new Schema("my-schema")
                .AddJson(1, "my-json", Partitioning.Invariant,
                         new JsonFieldProperties())
                .AddString(2, "my-string", Partitioning.Language,
                           new StringFieldProperties())
                .AddNumber(3, "my-number", Partitioning.Invariant,
                           new NumberFieldProperties())
                .AddNumber(4, "my_number", Partitioning.Invariant,
                           new NumberFieldProperties())
                .AddAssets(5, "my-assets", Partitioning.Invariant,
                           new AssetsFieldProperties())
                .AddBoolean(6, "my-boolean", Partitioning.Invariant,
                            new BooleanFieldProperties())
                .AddDateTime(7, "my-datetime", Partitioning.Invariant,
                             new DateTimeFieldProperties())
                .AddReferences(8, "my-references", Partitioning.Invariant,
                               new ReferencesFieldProperties {
                SchemaId = schemaId
            })
                .AddReferences(9, "my-invalid", Partitioning.Invariant,
                               new ReferencesFieldProperties {
                SchemaId = Guid.NewGuid()
            })
                .AddGeolocation(10, "my-geolocation", Partitioning.Invariant,
                                new GeolocationFieldProperties())
                .AddTags(11, "my-tags", Partitioning.Invariant,
                         new TagsFieldProperties())
                .AddString(12, "my-localized", Partitioning.Language,
                           new StringFieldProperties())
                .AddArray(13, "my-array", Partitioning.Invariant, f => f
                          .AddBoolean(121, "nested-boolean")
                          .AddNumber(122, "nested-number")
                          .AddNumber(123, "nested_number"))
                .ConfigureScripts(new SchemaScripts {
                Query = "<query-script>"
            })
                .Publish();

            A.CallTo(() => app.Id).Returns(appId);
            A.CallTo(() => app.Name).Returns(appName);
            A.CallTo(() => app.LanguagesConfig).Returns(LanguagesConfig.Build(Language.DE, Language.GermanGermany));

            context = QueryContext.Create(app, user);

            A.CallTo(() => schema.Id).Returns(schemaId);
            A.CallTo(() => schema.SchemaDef).Returns(schemaDef);

            var allSchemas = new List <ISchemaEntity> {
                schema
            };

            A.CallTo(() => appProvider.GetSchemasAsync(appId)).Returns(allSchemas);

            sut = new CachingGraphQLService(cache, appProvider, assetQuery, contentQuery, new FakeUrlGenerator());
        }
Esempio n. 4
0
        public GraphQLTestBase()
        {
            schemaDef =
                new Schema("my-schema")
                .AddJson(1, "my-json", Partitioning.Invariant,
                         new JsonFieldProperties())
                .AddString(2, "my-string", Partitioning.Language,
                           new StringFieldProperties())
                .AddNumber(3, "my-number", Partitioning.Invariant,
                           new NumberFieldProperties())
                .AddAssets(4, "my-assets", Partitioning.Invariant,
                           new AssetsFieldProperties())
                .AddBoolean(5, "my-boolean", Partitioning.Invariant,
                            new BooleanFieldProperties())
                .AddDateTime(6, "my-datetime", Partitioning.Invariant,
                             new DateTimeFieldProperties())
                .AddReferences(7, "my-references", Partitioning.Invariant,
                               new ReferencesFieldProperties {
                SchemaId = schemaId
            })
                .AddReferences(9, "my-invalid", Partitioning.Invariant,
                               new ReferencesFieldProperties {
                SchemaId = Guid.NewGuid()
            })
                .AddGeolocation(10, "my-geolocation", Partitioning.Invariant,
                                new GeolocationFieldProperties())
                .AddTags(11, "my-tags", Partitioning.Invariant,
                         new TagsFieldProperties());

            A.CallTo(() => app.Id).Returns(appId);
            A.CallTo(() => app.Name).Returns(appName);
            A.CallTo(() => app.LanguagesConfig).Returns(LanguagesConfig.Build(Language.DE));

            context = QueryContext.Create(app, user);

            A.CallTo(() => schema.Id).Returns(schemaId);
            A.CallTo(() => schema.Name).Returns(schemaDef.Name);
            A.CallTo(() => schema.SchemaDef).Returns(schemaDef);
            A.CallTo(() => schema.IsPublished).Returns(true);
            A.CallTo(() => schema.ScriptQuery).Returns("<script-query>");

            var allSchemas = new List <ISchemaEntity> {
                schema
            };

            A.CallTo(() => appProvider.GetSchemasAsync(appId)).Returns(allSchemas);

            sut = new CachingGraphQLService(cache, appProvider, assetRepository, commandBus, contentQuery, new FakeUrlGenerator());
        }
Esempio n. 5
0
        public AssetQueryServiceTests()
        {
            var user = new ClaimsPrincipal(new ClaimsIdentity());

            A.CallTo(() => app.Id).Returns(appId.Id);
            A.CallTo(() => app.Name).Returns(appId.Name);
            A.CallTo(() => app.LanguagesConfig).Returns(LanguagesConfig.English);

            context = QueryContext.Create(app, user);

            var options = Options.Create(new AssetOptions {
                DefaultPageSize = 30
            });

            sut = new AssetQueryService(tagService, assetEnricher, assetRepository, options);
        }
        public AssetQueryServiceTests()
        {
            var user = new ClaimsPrincipal(identity);

            A.CallTo(() => app.Id).Returns(appId);
            A.CallTo(() => app.Name).Returns(appName);
            A.CallTo(() => app.LanguagesConfig).Returns(LanguagesConfig.English);

            context = QueryContext.Create(app, user);

            A.CallTo(() => tagService.DenormalizeTagsAsync(appId, TagGroups.Assets, A <HashSet <string> > .That.IsSameSequenceAs("id1", "id2", "id3")))
            .Returns(new Dictionary <string, string>
            {
                ["id1"] = "name1",
                ["id2"] = "name2",
                ["id3"] = "name3"
            });

            sut = new AssetQueryService(tagService, assetRepository);
        }
Esempio n. 7
0
 private QueryContext Context()
 {
     return(QueryContext.Create(App, User));
 }
Esempio n. 8
0
 private QueryContext Context()
 {
     return(QueryContext.Create(App, User, Request.Headers["X-Languages"]).WithFlatten(Request.Headers.ContainsKey("X-Flatten")));
 }