Example #1
0
        public void CanChangeContentStatus_should_throw_exception_if_status_flow_not_valid()
        {
            var command = new ChangeContentStatus {
                Status = Status.Published
            };

            ValidationAssert.Throws(() => GuardContent.CanChangeContentStatus(schema, false, Status.Archived, command),
                                    new ValidationError("Cannot change status from Archived to Published.", "Status"));
        }
Example #2
0
        public void CanReorder_should_throw_exception_if_field_ids_null()
        {
            var command = new ReorderFields {
                FieldIds = null
            };

            ValidationAssert.Throws(() => GuardSchema.CanReorder(schema_0, command),
                                    new ValidationError("Field ids is required.", "FieldIds"));
        }
Example #3
0
        public void CanAdd_should_throw_exception_if_name_empty()
        {
            var command = new AddRole {
                Name = null
            };

            ValidationAssert.Throws(() => GuardAppRoles.CanAdd(roles_0, command),
                                    new ValidationError("Name is required.", "Name"));
        }
        public void CanAdd_should_throw_exception_if_properties_not_valid()
        {
            var command = new AddField {
                Name = "field5", Properties = invalidProperties
            };

            ValidationAssert.Throws(() => GuardSchemaField.CanAdd(command, schema_0),
                                    new ValidationError("Max length must be greater or equal to min length.", "Properties.MinLength", "Properties.MaxLength"));
        }
        public void CanAdd_should_throw_exception_if_partitioning_not_valid()
        {
            var command = new AddField {
                Name = "field5", Partitioning = "INVALID_PARTITIONING", Properties = validProperties
            };

            ValidationAssert.Throws(() => GuardSchemaField.CanAdd(command, schema_0),
                                    new ValidationError("Partitioning is not a valid value.", "Partitioning"));
        }
Example #6
0
        public void CanCreate_should_throw_exception_if_name_not_valid()
        {
            var command = new CreateApp {
                Name = "INVALID NAME"
            };

            ValidationAssert.Throws(() => GuardApp.CanCreate(command),
                                    new ValidationError("Name must be a valid slug.", "Name"));
        }
        public void CanAdd_should_throw_exception_if_nested_field_already_exists()
        {
            var command = new AddField {
                Name = "field301", Properties = validProperties, ParentFieldId = 3
            };

            ValidationAssert.Throws(() => GuardSchemaField.CanAdd(command, schema_0),
                                    new ValidationError("A field with the same name already exists."));
        }
Example #8
0
        public void CanRename_should_throw_exception_if_folder_name_is_empty()
        {
            var command = new RenameAssetFolder {
                AppId = appId
            };

            ValidationAssert.Throws(() => GuardAssetFolder.CanRename(command),
                                    new ValidationError("Folder name is required.", "FolderName"));
        }
Example #9
0
        public void CanUpdateLanguage_should_throw_exception_if_language_is_null()
        {
            var command = new UpdateLanguage();

            var languages_1 = languages_0.Set(new LanguageConfig(Language.EN));

            ValidationAssert.Throws(() => GuardAppLanguages.CanUpdate(languages_1, command),
                                    new ValidationError("Language is required.", "Language"));
        }
        public void CanRename_should_throw_exception_if_names_are_the_same()
        {
            var command = new RenameAssetFolder {
                FolderName = "My Folder"
            };

            ValidationAssert.Throws(() => GuardAssetFolder.CanRename(command, "My Folder"),
                                    new ValidationError("Asset folder has already this name.", "FolderName"));
        }
        public void CanPatch_should_throw_exception_if_data_is_null()
        {
            SetupSingleton(false);

            var command = new PatchContent();

            ValidationAssert.Throws(() => GuardContent.CanPatch(command),
                                    new ValidationError("Data is required.", "Data"));
        }
Example #12
0
        public void CanAnnotate_should_throw_exception_if_slugs_are_the_same()
        {
            var command = new AnnotateAsset {
                Slug = "asset-slug"
            };

            ValidationAssert.Throws(() => GuardAsset.CanAnnotate(command, "asset-name", "asset-slug"),
                                    new ValidationError("Asset has already this slug.", "Slug"));
        }
Example #13
0
        public void CanChangeContentStatus_should_throw_exception_if_publishing_without_pending_changes()
        {
            var command = new ChangeContentStatus {
                Status = Status.Published
            };

            ValidationAssert.Throws(() => GuardContent.CanChangeContentStatus(schema, false, Status.Published, command),
                                    new ValidationError("Content has no changes to publish.", "Status"));
        }
Example #14
0
        public void CanChangeContentStatus_should_throw_exception_if_due_date_in_past()
        {
            var command = new ChangeContentStatus {
                Status = Status.Published, DueTime = dueTimeInPast
            };

            ValidationAssert.Throws(() => GuardContent.CanChangeContentStatus(schema, false, Status.Draft, command),
                                    new ValidationError("Due time must be in the future.", "DueTime"));
        }
Example #15
0
        public void CanUpdate_should_throw_execption_if_client_id_is_null()
        {
            var command = new UpdateClient {
                Name = "iOS"
            };

            ValidationAssert.Throws(() => GuardAppClients.CanUpdate(clients_0, command, Roles.Empty),
                                    new ValidationError("Client id is required.", "Id"));
        }
Example #16
0
        public void CanAdd_should_throw_exception_if_pattern_empty()
        {
            var command = new AddPattern {
                PatternId = patternId, Name = "any", Pattern = string.Empty
            };

            ValidationAssert.Throws(() => GuardAppPatterns.CanAdd(patterns_0, command),
                                    new ValidationError("Pattern is required.", "Pattern"));
        }
Example #17
0
        public void CanUpdate_should_throw_exception_if_workflow_is_not_defined()
        {
            var command = new UpdateWorkflow {
                WorkflowId = workflowId
            };

            ValidationAssert.Throws(() => GuardAppWorkflows.CanUpdate(workflows, command),
                                    new ValidationError("Workflow is required.", "Workflow"));
        }
Example #18
0
        public void CanAdd_should_throw_exception_if_pattern_not_valid()
        {
            var command = new AddPattern {
                PatternId = patternId, Name = "any", Pattern = "[0-9{1}"
            };

            ValidationAssert.Throws(() => GuardAppPatterns.CanAdd(patterns_0, command),
                                    new ValidationError("Pattern is not a valid value.", "Pattern"));
        }
        public void CanUpdate_should_throw_exception_if_properties_null()
        {
            var command = new UpdateField {
                FieldId = 2, Properties = null !
            };

            ValidationAssert.Throws(() => GuardSchemaField.CanUpdate(command, schema_0),
                                    new ValidationError("Properties is required.", "Properties"));
        }
        public void CanUpdateLanguage_should_throw_exception_if_language_is_optional_and_master()
        {
            var command = new UpdateLanguage {
                Language = Language.EN, IsOptional = true
            };

            ValidationAssert.Throws(() => GuardAppLanguages.CanUpdate(languages, command),
                                    new ValidationError("Master language cannot be made optional.", "IsMaster"));
        }
        public void CanAdd_should_throw_exception_if_name_not_valid()
        {
            var command = new AddField {
                Name = "INVALID_NAME", Properties = validProperties
            };

            ValidationAssert.Throws(() => GuardSchemaField.CanAdd(command, schema_0),
                                    new ValidationError("Name is not a Javascript property name.", "Name"));
        }
        public void CanUpdateLanguage_should_throw_exception_if_fallback_language_defined_and_master()
        {
            var command = new UpdateLanguage {
                Language = Language.EN, Fallback = new[] { Language.DE }
            };

            ValidationAssert.Throws(() => GuardAppLanguages.CanUpdate(languages, command),
                                    new ValidationError("Master language cannot have fallback languages.", "Fallback"));
        }
        public void CanAdd_should_throw_exception_if_properties_null()
        {
            var command = new AddField {
                Name = "field5", Properties = null !
            };

            ValidationAssert.Throws(() => GuardSchemaField.CanAdd(command, schema_0),
                                    new ValidationError("Properties is required.", "Properties"));
        }
        public void CanUpdateLanguage_should_throw_exception_if_language_has_invalid_fallback()
        {
            var command = new UpdateLanguage {
                Language = Language.DE, Fallback = new[] { Language.IT }
            };

            ValidationAssert.Throws(() => GuardAppLanguages.CanUpdate(languages, command),
                                    new ValidationError("App does not have fallback language 'Italian'.", "Fallback"));
        }
Example #25
0
        public void CanCreate_should_throw_exception_if_name_not_valid()
        {
            var command = new CreateSchema {
                AppId = appId, Name = "INVALID NAME"
            };

            ValidationAssert.Throws(() => GuardSchema.CanCreate(command),
                                    new ValidationError("Name is not a valid slug.", "Name"));
        }
        public void CanAddLanguage_should_throw_exception_if_language_already_added()
        {
            var command = new AddLanguage {
                Language = Language.EN
            };

            ValidationAssert.Throws(() => GuardAppLanguages.CanAdd(languages, command),
                                    new ValidationError("Language has already been added."));
        }
Example #27
0
        public void CanConfigurePreviewUrls_should_throw_exception_if_preview_urls_null()
        {
            var command = new ConfigurePreviewUrls {
                PreviewUrls = null
            };

            ValidationAssert.Throws(() => GuardSchema.CanConfigurePreviewUrls(command),
                                    new ValidationError("Preview Urls is required.", "PreviewUrls"));
        }
        public void CanRemoveLanguage_should_throw_exception_if_language_is_master()
        {
            var command = new RemoveLanguage {
                Language = Language.EN
            };

            ValidationAssert.Throws(() => GuardAppLanguages.CanRemove(languages, command),
                                    new ValidationError("Master language cannot be removed."));
        }
Example #29
0
        public void CanDelete_should_throw_exception_if_name_empty()
        {
            var command = new DeleteRole {
                Name = null
            };

            ValidationAssert.Throws(() => GuardAppRoles.CanDelete(roles_0, command, contributors, clients),
                                    new ValidationError("Name is required.", "Name"));
        }
Example #30
0
        public void CanChangeContentStatus_should_throw_exception_if_status_not_valid()
        {
            var command = new ChangeContentStatus {
                Status = (Status)10
            };

            ValidationAssert.Throws(() => GuardContent.CanChangeContentStatus(schema, false, Status.Archived, command),
                                    new ValidationError("Status is not valid.", "Status"));
        }