Beispiel #1
0
        public void CanPublish_should_throw_exception_if_already_published()
        {
            var command = new PublishSchema();

            var schema_1 = schema_0.Publish();

            Assert.Throws <DomainException>(() => GuardSchema.CanPublish(schema_1, command));
        }
        public async Task <IActionResult> PublishSchema(string app, string name)
        {
            var command = new PublishSchema();

            var response = await InvokeCommandAsync(command);

            return(Ok(response));
        }
Beispiel #3
0
        public SchemaDomainObject Publish(PublishSchema command)
        {
            VerifyCreatedAndNotDeleted();

            RaiseEvent(SimpleMapper.Map(command, new SchemaPublished()));

            return(this);
        }
Beispiel #4
0
        public static void CanPublish(Schema schema, PublishSchema command)
        {
            Guard.NotNull(command, nameof(command));

            if (schema.IsPublished)
            {
                throw new DomainException("Schema is already published.");
            }
        }
        protected Task On(PublishSchema command, CommandContext context)
        {
            return(handler.UpdateSyncedAsync <SchemaDomainObject>(context, s =>
            {
                GuardSchema.CanPublish(s.Snapshot.SchemaDef, command);

                s.Publish(command);
            }));
        }
        public SchemaDomainObject Publish(PublishSchema command)
        {
            Guard.NotNull(command, nameof(command));

            VerifyCreatedAndNotDeleted();

            SchemaGuard.GuardCanPublish(schema);

            RaiseEvent(SimpleMapper.Map(command, new SchemaPublished()));

            return(this);
        }
Beispiel #7
0
        public async Task Publish_should_create_events_and_update_state()
        {
            var command = new PublishSchema();

            await ExecuteCreateAsync();

            var result = await sut.ExecuteAsync(CreateCommand(command));

            result.ShouldBeEquivalent(new EntitySavedResult(1));

            Assert.True(sut.Snapshot.SchemaDef.IsPublished);

            LastEvents
            .ShouldHaveSameEvents(
                CreateEvent(new SchemaPublished())
                );
        }
        public async Task Publish_should_create_events_and_update_published_flag()
        {
            var command = new PublishSchema();

            await ExecuteCreateAsync();

            var result = await PublishIdempotentAsync(command);

            result.ShouldBeEquivalent(sut.Snapshot);

            Assert.True(sut.Snapshot.SchemaDef.IsPublished);

            LastEvents
            .ShouldHaveSameEvents(
                CreateEvent(new SchemaPublished())
                );
        }
Beispiel #9
0
 public void Publish(PublishSchema command)
 {
     RaiseEvent(SimpleMapper.Map(command, new SchemaPublished()));
 }
Beispiel #10
0
 public static void CanPublish(PublishSchema command)
 {
     Guard.NotNull(command, nameof(command));
 }
Beispiel #11
0
        public void CanPublish_should_not_throw_exception_if_not_published()
        {
            var command = new PublishSchema();

            GuardSchema.CanPublish(schema_0, command);
        }
Beispiel #12
0
 public void Publish(PublishSchema command)
 {
     RaiseEvent(command, new SchemaPublished());
 }
 protected Task On(PublishSchema command, CommandContext context)
 {
     return(handler.UpdateAsync <SchemaDomainObject>(context, s => s.Publish(command)));
 }
 private void Publish(PublishSchema command)
 {
     Raise(command, new SchemaPublished());
 }