public async Task CanCreate_should_throw_exception_if_data_is_null() { var command = new CreateContent(); await ValidationAssert.ThrowsAsync(() => GuardContent.CanCreate(command, workflow, schema), new ValidationError("Data is required.", "Data")); }
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() { var content = CreateContent(Status.Draft); var command = CreateCommand(new CreateContentDraft()); Assert.Throws <DomainException>(() => GuardContent.CanCreateDraft(command, content)); }
public void CanCreate_should_throw_exception_if_data_is_null() { var command = new CreateContent(); ValidationAssert.Throws(() => GuardContent.CanCreate(command, schema), new ValidationError("Data is required.", "Data")); }
public void CheckPermission_should_not_throw_exception_if_content_is_from_current_user() { var content = CreateContent(status: Status.Published); var command = CreateCommand(new DeleteContent()); GuardContent.CheckPermission(content, command, Permissions.AppContentsDelete); }
public void CanDeleteDraft_should_not_throw_exception() { var content = CreateDraftContent(Status.Draft); var command = new DeleteContentDraft(); GuardContent.CanDeleteDraft(command, content); }
public async Task CanCreate_should_not_throw_exception_if_singleton_and_id_is_schema_id() { var command = new CreateContent { Data = new ContentData(), ContentId = schema.Id }; await GuardContent.CanCreate(command, workflow, schema); }
public void CanCreate_should_not_throw_exception_if_data_is_not_null() { var command = new CreateContent { Data = new ContentData() }; GuardContent.CanCreate(command, schema); }
public void CanDeleteDraft_should_throw_exception_if_no_draft_found() { var content = CreateContent(Status.Published); var command = CreateCommand(new DeleteContentDraft()); Assert.Throws <DomainException>(() => GuardContent.CanDeleteDraft(command, content)); }
public async Task CanDelete_should_throw_exception_if_singleton() { var content = CreateContent(Status.Published); var command = CreateCommand(new DeleteContent()); await Assert.ThrowsAsync <DomainException>(() => GuardContent.CanDelete(command, content, contentRepository, singleton)); }
public void CanCreate_should_throw_exception_if_singleton() { var command = new CreateContent { Data = new ContentData() }; Assert.Throws <DomainException>(() => GuardContent.CanCreate(command, singleton)); }
public async Task CanCreate_should_not_throw_exception_if_data_is_not_null() { var command = new CreateContent { Data = new ContentData() }; await GuardContent.CanCreate(command, workflow, schema); }
public async Task CanCreate_should_throw_exception_if_singleton() { var command = new CreateContent { Data = new ContentData() }; await Assert.ThrowsAsync <DomainException>(() => GuardContent.CanCreate(command, workflow, singleton)); }
public void CanCreate_should_not_throw_exception_if_singleton_and_id_is_schema_id() { var command = new CreateContent { Data = new ContentData(), ContentId = schema.Id }; GuardContent.CanCreate(command, schema); }
public async Task CanDelete_should_not_throw_exception() { var content = CreateContent(Status.Published); var command = CreateCommand(new DeleteContent()); await GuardContent.CanDelete(command, content, contentRepository, schema); }
public async Task CanUpdate_should_throw_exception_if_data_is_null() { var content = CreateContent(Status.Draft); var command = CreateCommand(new UpdateContent()); await ValidationAssert.ThrowsAsync(() => GuardContent.CanUpdate(command, content, workflow), new ValidationError("Data is required.", "Data")); }
public async Task CanPatch_should_throw_exception_if_data_is_null() { SetupCanUpdate(true); var content = CreateContent(Status.Draft); var command = new PatchContent(); await ValidationAssert.ThrowsAsync(() => GuardContent.CanPatch(command, content, contentWorkflow), new ValidationError("Data is required.", "Data")); }
public async Task CanCreate_should_throw_exception_if_singleton() { var schema = CreateSchema(true); var command = new CreateContent { Data = new NamedContentData() }; await Assert.ThrowsAsync <DomainException>(() => GuardContent.CanCreate(command, contentWorkflow, schema)); }
public async Task CanChangeStatus_should_throw_exception_if_singleton() { var content = CreateContent(Status.Published); var command = CreateCommand(new ChangeContentStatus { Status = Status.Draft }); await Assert.ThrowsAsync <DomainException>(() => GuardContent.CanChangeStatus(command, content, workflow, contentRepository, singleton)); }
public async Task CanCreate_should_not_throw_exception_if_publishing_allowed() { SetupCanCreatePublish(true); var command = new CreateContent { Data = new ContentData(), Publish = true }; await Assert.ThrowsAsync <DomainException>(() => GuardContent.CanCreate(command, workflow, schema)); }
public async Task CanChangeStatus_should_not_throw_exception_if_singleton_is_published() { var content = CreateDraftContent(Status.Draft); var command = CreateCommand(new ChangeContentStatus { Status = Status.Published }); await GuardContent.CanChangeStatus(command, content, workflow, contentRepository, singleton); }
public async Task CanPatch_should_throw_exception_if_workflow_blocks_it() { SetupCanUpdate(false); var content = CreateContent(Status.Draft); var command = new PatchContent { Data = new NamedContentData() }; await Assert.ThrowsAsync <DomainException>(() => GuardContent.CanPatch(command, content, contentWorkflow)); }
public async Task CanPatch_should_not_throw_exception_if_data_is_not_null() { SetupCanUpdate(true); var content = CreateContent(Status.Draft); var command = new PatchContent { Data = new NamedContentData(), User = user }; await GuardContent.CanPatch(command, content, contentWorkflow); }
public async Task CanUpdate_should_not_throw_exception_if_data_is_not_null() { SetupCanUpdate(true); var content = CreateContent(Status.Draft); var command = CreateCommand(new UpdateContent { Data = new ContentData() }); await GuardContent.CanUpdate(command, content, contentWorkflow); }
public void CheckPermission_should_exception_if_content_is_from_another_user_and_user_has_no_permission() { var content = CreateContent(Status.Published); var commandActor = RefToken.User("456"); var command = CreateCommand(new DeleteContent { Actor = commandActor }); Assert.Throws <DomainForbiddenException>(() => GuardContent.CheckPermission(content, command, Permissions.AppContentsDelete)); }
public async Task CanDelete_should_throw_exception_if_referenced() { var schema = CreateSchema(true); var content = CreateContent(Status.Published); var command = new DeleteContent(); A.CallTo(() => contentRepository.HasReferrersAsync(appId.Id, content.Id, SearchScope.All)) .Returns(true); await Assert.ThrowsAsync <DomainException>(() => GuardContent.CanDelete(command, content, contentRepository, schema)); }
public async Task CanCreate_should_not_throw_exception_publishing_allowed() { var schema = CreateSchema(false); SetupCanCreatePublish(schema, true); var command = new CreateContent { Data = new NamedContentData(), Publish = true }; await Assert.ThrowsAsync <DomainException>(() => GuardContent.CanCreate(command, contentWorkflow, schema)); }
public async Task CanUpdate_should_throw_exception_if_workflow_blocks_it_but_check_is_disabled() { SetupCanUpdate(false); var content = CreateContent(Status.Draft); var command = CreateCommand(new UpdateContent { Data = new ContentData(), DoNotValidateWorkflow = true }); await GuardContent.CanUpdate(command, content, workflow); }
public async Task CanChangeStatus_should_not_throw_exception_if_status_flow_valid() { var content = CreateContent(Status.Draft); var command = CreateCommand(new ChangeContentStatus { Status = Status.Published }); A.CallTo(() => workflow.CanMoveToAsync(content, content.Status, command.Status, user)) .Returns(true); await GuardContent.CanChangeStatus(command, content, workflow, contentRepository, schema); }
public void CheckPermission_should_not_throw_exception_if_user_is_null() { var content = CreateContent(Status.Published); var commandActor = RefToken.User("456"); var command = CreateCommand(new DeleteContent { Actor = commandActor }); command.User = null; GuardContent.CheckPermission(content, command, Permissions.AppContentsDelete); }