public async Task Should_not_enrich_references_if_not_api_user() { var contents = new[] { CreateContent(new[] { DomainId.NewGuid() }, Array.Empty <DomainId>()) }; var ctx = new Context(Mocks.ApiUser(), Mocks.App(appId)); await sut.EnrichAsync(ctx, contents, schemaProvider, default); Assert.Null(contents[0].ReferenceData); A.CallTo(() => contentQuery.QueryAsync(A <Context> ._, A <Q> ._, A <CancellationToken> ._)) .MustNotHaveHappened(); }
public async Task Should_not_enrich_references_if_not_api_user() { var contents = new[] { CreateContent(new[] { Guid.NewGuid() }, new Guid[0]) }; var ctx = new Context(Mocks.ApiUser(), Mocks.App(appId)); await sut.EnrichAsync(ctx, contents, schemaProvider); Assert.Null(contents[0].ReferenceData); A.CallTo(() => contentQuery.QueryAsync(A <Context> ._, A <List <Guid> > ._)) .MustNotHaveHappened(); }
public async Task Should_not_call_script_engine_if_no_script_configured() { var ctx = new Context(Mocks.ApiUser(), Mocks.App(appId)); var(provider, schemaId) = CreateSchema( queryPre: "my-pre-query"); var content = new ContentEntity { Data = new ContentData(), SchemaId = schemaId }; await sut.EnrichAsync(ctx, new[] { content }, provider, default); A.CallTo(() => scriptEngine.TransformAsync(A <DataScriptVars> ._, A <string> ._, ScriptOptions(), A <CancellationToken> ._)) .MustNotHaveHappened(); }
public ConvertDataTests() { requestContext = new Context(Mocks.ApiUser(), Mocks.App(appId)); var schemaDef = new Schema("my-schema") .AddReferences(1, "references", Partitioning.Invariant) .AddAssets(2, "assets", Partitioning.Invariant) .AddArray(3, "array", Partitioning.Invariant, a => a .AddAssets(31, "nested")); schema = Mocks.Schema(appId, schemaId, schemaDef); schemaProvider = x => Task.FromResult(schema); sut = new ConvertData(assetUrlGenerator, assetRepository, contentRepository); }
public async Task Should_not_enrich_content_with_can_update_if_disabled_in_context() { requestContext.WithResolveFlow(false); var content = new ContentEntity { SchemaId = schemaId }; var ctx = new Context(Mocks.ApiUser(), Mocks.App(appId)).WithResolveFlow(false); await sut.EnrichAsync(ctx, new[] { content }, null !); Assert.False(content.CanUpdate); A.CallTo(() => contentWorkflow.CanUpdateAsync(content, A <Status> ._, requestContext.User)) .MustNotHaveHappened(); }
public EnrichWithWorkflowsTests() { requestContext = new Context(Mocks.ApiUser(), Mocks.App(appId)); sut = new EnrichWithWorkflows(contentWorkflow); }