Beispiel #1
0
        public async Task CanChangeStatus_should_not_throw_exception_if_singleton_is_published()
        {
            var schema = CreateSchema(true);

            var content = CreateDraftContent(Status.Draft);
            var command = new ChangeContentStatus {
                Status = Status.Published
            };

            await GuardContent.CanChangeStatus(command, content, contentWorkflow, contentRepository, schema);
        }
Beispiel #2
0
        public async Task CanChangeStatus_should_throw_exception_if_singleton()
        {
            var schema = CreateSchema(true);

            var content = CreateContent(Status.Published);
            var command = new ChangeContentStatus {
                Status = Status.Draft
            };

            await Assert.ThrowsAsync <DomainException>(() => GuardContent.CanChangeStatus(command, content, contentWorkflow, contentRepository, schema));
        }
        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 async Task CanChangeStatus_should_throw_exception_if_referenced()
        {
            var content = CreateContent(Status.Published);

            var command = CreateCommand(new ChangeContentStatus {
                Status = Status.Draft
            });

            A.CallTo(() => contentRepository.HasReferrersAsync(appId.Id, content.Id, SearchScope.Published))
            .Returns(true);

            await Assert.ThrowsAsync <ValidationException>(() => GuardContent.CanChangeStatus(command, content, workflow, contentRepository, schema));
        }
        public async Task CanChangeStatus_should_throw_exception_if_status_valid()
        {
            var content = CreateContent(Status.Draft);

            var command = CreateCommand(new ChangeContentStatus {
                Status = new Status("Invalid"), DoNotValidateWorkflow = true
            });

            A.CallTo(() => workflow.GetInfoAsync(content, command.Status))
            .Returns(Task.FromResult <StatusInfo?>(null));

            await ValidationAssert.ThrowsAsync(() => GuardContent.CanChangeStatus(command, content, workflow, contentRepository, schema),
                                               new ValidationError("Status is not defined in the workflow.", "Status"));
        }
        public async Task CanChangeStatus_should_throw_exception_if_status_flow_not_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(false);

            await ValidationAssert.ThrowsAsync(() => GuardContent.CanChangeStatus(command, content, workflow, contentRepository, schema),
                                               new ValidationError("Cannot change status from Draft to Published.", "Status"));
        }
Beispiel #7
0
        public async Task CanChangeStatus_should_throw_exception_if_due_date_in_past()
        {
            var content = CreateContent(Status.Draft);

            var command = CreateCommand(new ChangeContentStatus {
                Status = Status.Published, DueTime = dueTimeInPast
            });

            A.CallTo(() => workflow.CanMoveToAsync(content, content.Status, command.Status, user))
            .Returns(true);

            await ValidationAssert.ThrowsAsync(() => GuardContent.CanChangeStatus(command, content, workflow, contentRepository, schema),
                                               new ValidationError("Due time must be in the future.", "DueTime"));
        }