public static async Task <ContentOperationContext> CreateAsync( IContentRepository contentRepository, ContentDomainObject content, ContentCommand command, IAppProvider appProvider, IAssetRepository assetRepository, IScriptEngine scriptEngine, Func <string> message) { var(appEntity, schemaEntity) = await appProvider.GetAppWithSchemaAsync(command.AppId.Id, command.SchemaId.Id); var context = new ContentOperationContext { appEntity = appEntity, assetRepository = assetRepository, contentRepository = contentRepository, content = content, command = command, message = message, schemaEntity = schemaEntity, scriptEngine = scriptEngine }; return(context); }
public static async Task <ContentOperationContext> CreateAsync( IContentRepository contentRepository, ContentDomainObject content, ContentCommand command, IAppProvider appProvider, IAssetRepository assetRepository, IScriptEngine scriptEngine, Func <string> message) { var a = content.Snapshot.AppId; var s = content.Snapshot.SchemaId; if (command is CreateContent createContent) { a = a ?? createContent.AppId; s = s ?? createContent.SchemaId; } var(appEntity, schemaEntity) = await appProvider.GetAppWithSchemaAsync(a.Id, s.Id); var context = new ContentOperationContext { appEntity = appEntity, appId = a.Id, assetRepository = assetRepository, contentRepository = contentRepository, content = content, command = command, message = message, schemaEntity = schemaEntity, scriptEngine = scriptEngine }; return(context); }
public ContentDomainObjectTests() { app = Mocks.App(AppNamedId, Language.DE); var scripts = new SchemaScripts { Change = "<change-script>", Create = "<create-script>", Delete = "<delete-script>", Update = "<update-script>" }; var schemaDef = new Schema("my-schema") .AddNumber(1, "my-field1", Partitioning.Invariant, new NumberFieldProperties { IsRequired = true }) .AddNumber(2, "my-field2", Partitioning.Invariant, new NumberFieldProperties { IsRequired = false }) .SetScripts(scripts); schema = Mocks.Schema(AppNamedId, SchemaNamedId, schemaDef); A.CallTo(() => appProvider.GetAppAsync(AppName, false)) .Returns(app); A.CallTo(() => appProvider.GetAppWithSchemaAsync(AppId, SchemaId, false)) .Returns((app, schema)); A.CallTo(() => scriptEngine.TransformAsync(A <ScriptVars> ._, A <string> ._, ScriptOptions())) .ReturnsLazily(x => Task.FromResult(x.GetArgument <ScriptVars>(0) !.Data !)); patched = patch.MergeInto(data); var validators = Enumerable.Repeat(new DefaultValidatorsFactory(), 1); var context = new ContentOperationContext(appProvider, validators, contentWorkflow, contentRepository, scriptEngine, A.Fake <ISemanticLog>()); sut = new ContentDomainObject(Store, A.Dummy <ISemanticLog>(), context); sut.Setup(Id); }
public ContentDomainObjectTests() { app = Mocks.App(AppNamedId, Language.DE); var scripts = new SchemaScripts { Change = "<change-script>", Create = "<create-script>", Delete = "<delete-script>", Update = "<update-script>" }; var schemaDef = new Schema("my-schema") .AddNumber(1, "my-field1", Partitioning.Invariant, new NumberFieldProperties { IsRequired = true }) .AddNumber(2, "my-field2", Partitioning.Invariant, new NumberFieldProperties { IsRequired = false }) .SetScripts(scripts); schema = Mocks.Schema(AppNamedId, SchemaNamedId, schemaDef); A.CallTo(() => appProvider.GetAppAsync(AppName)) .Returns(app); A.CallTo(() => appProvider.GetAppWithSchemaAsync(AppId, SchemaId)) .Returns((app, schema)); A.CallTo(() => scriptEngine.ExecuteAndTransform(A <ScriptContext> ._, A <string> ._)) .ReturnsLazily(x => x.GetArgument <ScriptContext>(0) !.Data !); patched = patch.MergeInto(data); sut = new ContentDomainObject(Store, A.Dummy <ISemanticLog>(), appProvider, A.Dummy <IAssetRepository>(), scriptEngine, contentWorkflow, contentRepository); sut.Setup(Id); }
private async Task <ContentOperationContext> CreateContext(ContentCommand command, ContentDomainObject content, Func <string> message) { var operationContext = await ContentOperationContext.CreateAsync( contentRepository, content, command, appProvider, assetRepository, scriptEngine, message); return(operationContext); }