Ejemplo n.º 1
0
        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"));
        }
Ejemplo n.º 2
0
        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."));
        }
Ejemplo n.º 3
0
        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"));
        }
Ejemplo n.º 4
0
        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"));
        }
Ejemplo n.º 5
0
        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"));
        }
Ejemplo n.º 6
0
        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"));
        }
Ejemplo n.º 7
0
        public void CanUpdate_should_throw_exception_if_locked()
        {
            var command = new UpdateField {
                FieldId = 1, Properties = validProperties
            };

            var schema_1 = schema_0.UpdateField(1, f => f.Lock());

            Assert.Throws <DomainException>(() => GuardSchemaField.CanUpdate(command, schema_1));
        }
Ejemplo n.º 8
0
        public void CanShow_should_not_throw_exception_if_already_shown()
        {
            var command = new EnableField {
                FieldId = 1
            };

            var schema_1 = schema_0.UpdateField(1, f => f.Show());

            GuardSchemaField.CanEnable(command, schema_1);
        }
Ejemplo n.º 9
0
        public void CanDisable_should_throw_exception_if_already_disabled()
        {
            var command = new DisableField {
                FieldId = 1
            };

            var schema_1 = schema_0.DisableField(1);

            Assert.Throws <DomainException>(() => GuardSchemaField.CanDisable(schema_1, command));
        }
Ejemplo n.º 10
0
        public void CanHide_should_throw_exception_if_already_hidden()
        {
            var command = new HideField {
                FieldId = 1
            };

            var schema_1 = schema_0.HideField(1);

            Assert.Throws <DomainException>(() => GuardSchemaField.CanHide(schema_1, command));
        }
Ejemplo n.º 11
0
        public void CanUpdate_should_throw_exception_if_locked()
        {
            var command = new UpdateField {
                FieldId = 1, Properties = new StringFieldProperties()
            };

            var schema_1 = schema_0.LockField(1);

            Assert.Throws <DomainException>(() => GuardSchemaField.CanUpdate(schema_1, command));
        }
Ejemplo n.º 12
0
        public void CanDelete_should_throw_exception_if_locked()
        {
            var command = new DeleteField {
                FieldId = 1
            };

            var schema_1 = schema_0.LockField(1);

            Assert.Throws <DomainException>(() => GuardSchemaField.CanDelete(schema_1, command));
        }
Ejemplo n.º 13
0
        public void CanEnable_should_not_throw_exception_if_disabled()
        {
            var command = new EnableField {
                FieldId = 1
            };

            var schema_1 = schema_0.DisableField(1);

            GuardSchemaField.CanEnable(schema_1, command);
        }
Ejemplo n.º 14
0
        public void CanShow_should_not_throw_exception_if_hidden()
        {
            var command = new ShowField {
                FieldId = 1
            };

            var schema_1 = schema_0.HideField(1);

            GuardSchemaField.CanShow(schema_1, command);
        }
Ejemplo n.º 15
0
        public void CanShow_should_throw_exception_if_locked()
        {
            var command = new ShowField {
                FieldId = 1
            };

            var schema_1 = schema_0.UpdateField(1, f => f.Lock());

            Assert.Throws <DomainException>(() => GuardSchemaField.CanShow(command, schema_1));
        }
Ejemplo n.º 16
0
        public void CanDisable_should_not_throw_exception_if_already_disabled()
        {
            var command = new DisableField {
                FieldId = 1
            };

            var schema_1 = schema_0.UpdateField(1, f => f.Disable());

            GuardSchemaField.CanDisable(command, schema_1);
        }
Ejemplo n.º 17
0
        public void CanUpdate_should_throw_exception_if_properties_not_valid()
        {
            var command = new UpdateField {
                FieldId = 2, Properties = new StringFieldProperties {
                    MinLength = 10, MaxLength = 5
                }
            };

            Assert.Throws <ValidationException>(() => GuardSchemaField.CanUpdate(schema_0, command));
        }
Ejemplo n.º 18
0
        public void CanUpdate_should_throw_exception_if_marking_a_ui_field_as_list_field()
        {
            var command = new UpdateField {
                FieldId = 4, Properties = new UIFieldProperties {
                    IsListField = true
                }
            };

            ValidationAssert.Throws(() => GuardSchemaField.CanUpdate(schema_0, command),
                                    new ValidationError("UI field cannot be a list field.", "Properties.IsListField"));
        }
Ejemplo n.º 19
0
        public void CanAdd_should_throw_exception_if_creating_a_ui_field_as_list_field()
        {
            var command = new AddField {
                Name = "field5", Properties = new UIFieldProperties {
                    IsListField = true
                }
            };

            ValidationAssert.Throws(() => GuardSchemaField.CanAdd(schema_0, command),
                                    new ValidationError("UI field cannot be a list field.", "Properties.IsListField"));
        }
Ejemplo n.º 20
0
        public void CanUpdate_should_throw_exception_if_properties_not_valid()
        {
            var command = new UpdateField {
                FieldId = 2, Properties = new StringFieldProperties {
                    MinLength = 10, MaxLength = 5
                }
            };

            ValidationAssert.Throws(() => GuardSchemaField.CanUpdate(command, schema_0),
                                    new ValidationError("Max length must be greater or equal to min length.", "Properties.MinLength", "Properties.MaxLength"));
        }