Пример #1
0
        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"));
        }
Пример #2
0
        public void CreateDraft_should_not_throw_exception()
        {
            var content = CreateContent(Status.Published);
            var command = new CreateContentDraft();

            GuardContent.CanCreateDraft(command, content);
        }
Пример #3
0
        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));
        }
Пример #4
0
        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"));
        }
Пример #5
0
        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);
        }
Пример #6
0
        public void CanDeleteDraft_should_not_throw_exception()
        {
            var content = CreateDraftContent(Status.Draft);
            var command = new DeleteContentDraft();

            GuardContent.CanDeleteDraft(command, content);
        }
Пример #7
0
        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);
        }
Пример #8
0
        public void CanCreate_should_not_throw_exception_if_data_is_not_null()
        {
            var command = new CreateContent {
                Data = new ContentData()
            };

            GuardContent.CanCreate(command, schema);
        }
Пример #9
0
        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));
        }
Пример #10
0
        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));
        }
Пример #11
0
        public void CanCreate_should_throw_exception_if_singleton()
        {
            var command = new CreateContent {
                Data = new ContentData()
            };

            Assert.Throws <DomainException>(() => GuardContent.CanCreate(command, singleton));
        }
Пример #12
0
        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);
        }
Пример #13
0
        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));
        }
Пример #14
0
        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);
        }
Пример #15
0
        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);
        }
Пример #16
0
        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"));
        }
Пример #17
0
        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"));
        }
Пример #18
0
        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));
        }
Пример #19
0
        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));
        }
Пример #20
0
        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));
        }
Пример #21
0
        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);
        }
Пример #22
0
        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));
        }
Пример #23
0
        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);
        }
Пример #24
0
        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);
        }
Пример #25
0
        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));
        }
Пример #26
0
        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));
        }
Пример #27
0
        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));
        }
Пример #28
0
        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);
        }
Пример #29
0
        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);
        }
Пример #30
0
        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);
        }