Beispiel #1
0
        public void CreateDraft_should_not_throw_exception()
        {
            var content = CreateContent(Status.Published);
            var command = new CreateContentDraft();

            GuardContent.CanCreateDraft(command, content);
        }
Beispiel #2
0
        public void CreateDraft_should_throw_exception_if_not_published()
        {
            CreateSchema(false);

            var content = CreateContent(Status.Draft);
            var command = new CreateContentDraft();

            Assert.Throws <DomainException>(() => GuardContent.CanCreateDraft(command, content));
        }
Beispiel #3
0
        public void CreateDraft_should_throw_exception_if_singleton()
        {
            var schema = CreateSchema(true);

            var content = CreateContent(Status.Published);
            var command = new CreateContentDraft();

            Assert.Throws <DomainException>(() => GuardContent.CanCreateDraft(command, schema, content));
        }
Beispiel #4
0
        public static void CanCreateDraft(CreateContentDraft command, ContentState content)
        {
            Guard.NotNull(command, nameof(command));

            if (content.Status != Status.Published)
            {
                throw new DomainException("You can only create a new version when the content is published.");
            }
        }
Beispiel #5
0
        public static void CanCreateDraft(CreateContentDraft command, ContentState content)
        {
            Guard.NotNull(command, nameof(command));

            if (content.Status != Status.Published)
            {
                throw new DomainException(T.Get("contents.draftNotCreateForUnpublished"));
            }
        }
Beispiel #6
0
        private async Task CreateDraftCore(CreateContentDraft c, ContentOperation operation)
        {
            operation.MustHavePermission(Permissions.AppContentsVersionCreate);
            operation.MustCreateDraft();

            var status = await operation.GetInitialStatusAsync();

            CreateDraft(c, status);
        }
        public async Task <IActionResult> CreateDraft(string app, string name, DomainId id)
        {
            var command = new CreateContentDraft {
                ContentId = id
            };

            var response = await InvokeCommandAsync(command);

            return(Ok(response));
        }
Beispiel #8
0
        public static void CanCreateDraft(CreateContentDraft command, IContentEntity content)
        {
            Guard.NotNull(command, nameof(command));

            CheckPermission(content, command, Permissions.AppContentsVersionCreate);

            if (content.Status != Status.Published)
            {
                throw new DomainException(T.Get("contents.draftNotCreateForUnpublished"));
            }
        }
Beispiel #9
0
        public async Task <IActionResult> CreateDraft(string app, string name, Guid id)
        {
            await contentQuery.GetSchemaOrThrowAsync(Context, name);

            var command = new CreateContentDraft {
                ContentId = id
            };

            var response = await InvokeCommandAsync(command);

            return(Ok(response));
        }
Beispiel #10
0
        public static void CanCreateDraft(CreateContentDraft command, ISchemaEntity schema, ContentState content)
        {
            Guard.NotNull(command);

            if (schema.SchemaDef.IsSingleton)
            {
                throw new DomainException("Singleton content cannot be updated.");
            }

            if (content.Status != Status.Published)
            {
                throw new DomainException("You can only create a new version when the content is published.");
            }
        }
Beispiel #11
0
        public async Task CreateDraft_should_create_events_and_update_new_state()
        {
            var command = new CreateContentDraft();

            await ExecuteCreateAsync();
            await ExecutePublishAsync();

            var result = await PublishAsync(command);

            result.ShouldBeEquivalent(sut.Snapshot);

            Assert.Equal(Status.Draft, sut.Snapshot.NewVersion?.Status);

            LastEvents
            .ShouldHaveSameEvents(
                CreateContentEvent(new ContentDraftCreated {
                Status = Status.Draft
            })
                );
        }
Beispiel #12
0
 private void CreateDraft(CreateContentDraft command, Status status)
 {
     Raise(command, new ContentDraftCreated {
         Status = status
     });
 }