Пример #1
0
        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);
        }
Пример #2
0
        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);
        }