public void CreateDraft_should_not_throw_exception() { var content = CreateContent(Status.Published); var command = new CreateContentDraft(); GuardContent.CanCreateDraft(command, content); }
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)); }
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)); }
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."); } }
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")); } }
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)); }
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")); } }
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)); }
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."); } }
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 }) ); }
private void CreateDraft(CreateContentDraft command, Status status) { Raise(command, new ContentDraftCreated { Status = status }); }