public void Apply_should_throw_when_invalid_length_given()
        {
            var propertyConfiguration = new StringPropertyConfiguration();

            Assert.Equal(Strings.StringLengthAttributeConvention_InvalidMaximumLength("P", typeof(object)), Assert.Throws<InvalidOperationException>(() => new StringLengthAttributeConvention.StringLengthAttributeConventionImpl()
                                                                                                                                                                     .Apply(new MockPropertyInfo(), propertyConfiguration, new StringLengthAttribute(0))).Message);
        }
        private StringPropertyConfiguration(StringPropertyConfiguration source)
            : base(source)
        {
            DebugCheck.NotNull(source);

            IsUnicode = source.IsUnicode;
        }
        private StringPropertyConfiguration(StringPropertyConfiguration source)
            : base(source)
        {
            DebugCheck.NotNull(source);

            IsUnicode = source.IsUnicode;
        }
        private StringPropertyConfiguration(StringPropertyConfiguration source)
            : base(source)
        {
            //Contract.Requires(source != null);

            IsUnicode = source.IsUnicode;
        }
Exemple #5
0
        internal override bool IsCompatible(
            PrimitivePropertyConfiguration other,
            bool inCSpace,
            out string errorMessage)
        {
            StringPropertyConfiguration other1 = other as StringPropertyConfiguration;
            bool flag1 = base.IsCompatible(other, inCSpace, out errorMessage);
            int  num;

            if (other1 != null)
            {
                num = this.IsCompatible <bool, StringPropertyConfiguration>((Expression <Func <StringPropertyConfiguration, bool?> >)(c => c.IsUnicode), other1, ref errorMessage) ? 1 : 0;
            }
            else
            {
                num = 1;
            }
            bool flag2 = num != 0;

            if (flag1)
            {
                return(flag2);
            }
            return(false);
        }
Exemple #6
0
        public void IsRowVersion_throws_when_not_binary()
        {
            var innerConfig = new Properties.Primitive.StringPropertyConfiguration();
            var config      = new ConventionPrimitivePropertyConfiguration(new MockPropertyInfo(), () => innerConfig);

            Assert.Equal(
                Strings.LightweightPrimitivePropertyConfiguration_IsRowVersionNonBinary("P"),
                Assert.Throws <InvalidOperationException>(() => config.IsRowVersion()).Message);
        }
Exemple #7
0
        public void HasPrecision_with_scale_throws_when_not_decimal()
        {
            var innerConfig = new Properties.Primitive.StringPropertyConfiguration();
            var config      = new ConventionPrimitivePropertyConfiguration(new MockPropertyInfo(), () => innerConfig);

            Assert.Equal(
                Strings.LightweightPrimitivePropertyConfiguration_HasPrecisionNonDecimal("P"),
                Assert.Throws <InvalidOperationException>(() => config.HasPrecision(8, 2)).Message);
        }
        public void Apply_should_ignore_attribute_if_already_set()
        {
            var propertyConfiguration = new StringPropertyConfiguration { IsNullable = true };

            new RequiredPrimitivePropertyAttributeConvention.RequiredPrimitivePropertyAttributeConventionImpl()
                .Apply(new MockPropertyInfo(), propertyConfiguration, new RequiredAttribute());

            Assert.Equal(true, propertyConfiguration.IsNullable);
        }
        public void Apply_should_not_set_max_length_for_strings_if_value_exists()
        {
            var propertyConfiguration = new StringPropertyConfiguration { MaxLength = 11 };

            new StringLengthAttributeConvention.StringLengthAttributeConventionImpl()
                .Apply(new MockPropertyInfo(), propertyConfiguration, new StringLengthAttribute(12));

            Assert.Equal(11, propertyConfiguration.MaxLength);
        }
Exemple #10
0
        public void Apply_should_set_max_length_for_strings()
        {
            var propertyConfiguration = new StringPropertyConfiguration();

            new StringLengthAttributeConvention()
            .Apply(new ConventionPrimitivePropertyConfiguration(new MockPropertyInfo(), () => propertyConfiguration), new StringLengthAttribute(12));

            Assert.Equal(12, propertyConfiguration.MaxLength);
        }
        public void Apply_should_set_max_length_for_strings()
        {
            var propertyConfiguration = new StringPropertyConfiguration();

            new StringLengthAttributeConvention.StringLengthAttributeConventionImpl()
                .Apply(new MockPropertyInfo(), propertyConfiguration, new StringLengthAttribute(12));

            Assert.Equal(12, propertyConfiguration.MaxLength);
        }
        public void Apply_should_unset_optional_flag()
        {
            var propertyConfiguration = new StringPropertyConfiguration();

            new RequiredPrimitivePropertyAttributeConvention.RequiredPrimitivePropertyAttributeConventionImpl()
                .Apply(new MockPropertyInfo(), propertyConfiguration, new RequiredAttribute());

            Assert.Equal(false, propertyConfiguration.IsNullable);
        }
Exemple #13
0
        public void Apply_should_throw_when_invalid_length_given()
        {
            var propertyConfiguration = new StringPropertyConfiguration();

            Assert.Equal(
                Strings.StringLengthAttributeConvention_InvalidMaximumLength("P", typeof(object)),
                Assert.Throws <InvalidOperationException>(
                    () => new StringLengthAttributeConvention()
                    .Apply(new ConventionPrimitivePropertyConfiguration(new MockPropertyInfo(), () => propertyConfiguration), new StringLengthAttribute(-1))).Message);
        }
        public void IsUnicode_configures_when_unset()
        {
            var innerConfig = new Properties.Primitive.StringPropertyConfiguration();
            var config      = new ConventionPrimitivePropertyConfiguration(new MockPropertyInfo(), () => innerConfig);

            var result = config.IsUnicode();

            Assert.Equal(true, innerConfig.IsUnicode);
            Assert.Same(config, result);
        }
        public void Apply_should_set_max_length_to_given_value()
        {
            var propertyConfiguration = new StringPropertyConfiguration();

            new MaxLengthAttributeConvention()
                .Apply(new MockPropertyInfo(), propertyConfiguration, new MaxLengthAttribute(100));

            Assert.Equal(100, propertyConfiguration.MaxLength);
            Assert.Null(propertyConfiguration.IsMaxLength);
        }
        public void Apply_should_set_is_max_length_when_no_length_given()
        {
            var propertyConfiguration = new StringPropertyConfiguration();

            new MaxLengthAttributeConvention.MaxLengthAttributeConventionImpl()
                .Apply(new MockPropertyInfo(), propertyConfiguration, new MaxLengthAttribute());

            Assert.Null(propertyConfiguration.MaxLength);
            Assert.Equal(true, propertyConfiguration.IsMaxLength);
        }
        public void Apply_should_not_set_max_length_if_value_exists()
        {
            var propertyConfiguration = new StringPropertyConfiguration { MaxLength = 200 };

            new MaxLengthAttributeConvention.MaxLengthAttributeConventionImpl()
                .Apply(new MockPropertyInfo(), propertyConfiguration, new MaxLengthAttribute(100));

            Assert.Equal(200, propertyConfiguration.MaxLength);
            Assert.Null(propertyConfiguration.IsMaxLength);
        }
Exemple #18
0
        public void IsUnicode_with_parameter_configures_when_unset()
        {
            var innerConfig = new StringPropertyConfiguration();
            var config      = new LightweightPropertyConfiguration(new MockPropertyInfo(), () => innerConfig);

            var result = config.IsUnicode(false);

            Assert.Equal(false, innerConfig.IsUnicode);
            Assert.Same(config, result);
        }
Exemple #19
0
        internal override void FillFrom(PrimitivePropertyConfiguration other, bool inCSpace)
        {
            base.FillFrom(other, inCSpace);
            StringPropertyConfiguration propertyConfiguration = other as StringPropertyConfiguration;

            if (propertyConfiguration == null || this.IsUnicode.HasValue)
            {
                return;
            }
            this.IsUnicode = propertyConfiguration.IsUnicode;
        }
Exemple #20
0
        internal override void CopyFrom(PrimitivePropertyConfiguration other)
        {
            base.CopyFrom(other);
            StringPropertyConfiguration propertyConfiguration = other as StringPropertyConfiguration;

            if (propertyConfiguration == null)
            {
                return;
            }
            this.IsUnicode = propertyConfiguration.IsUnicode;
        }
        public void Cloning_a_string_property_configuration_clones_its_property_information()
        {
            var configuration = new StringPropertyConfiguration();

            configuration.IsUnicode = true;

            var clone = (StringPropertyConfiguration)
                        Cloning_a_length_property_configuration_clones_its_property_information(configuration);

            Assert.True(clone.IsUnicode.Value);
        }
Exemple #22
0
        internal override void MakeCompatibleWith(PrimitivePropertyConfiguration other, bool inCSpace)
        {
            base.MakeCompatibleWith(other, inCSpace);
            StringPropertyConfiguration propertyConfiguration = other as StringPropertyConfiguration;

            if (propertyConfiguration == null || !propertyConfiguration.IsUnicode.HasValue)
            {
                return;
            }
            this.IsUnicode = new bool?();
        }
        public void HasMaxLength_does_not_configure_IsUnicode_when_unset()
        {
            var innerConfig = new Properties.Primitive.StringPropertyConfiguration();
            var config      = new ConventionPrimitivePropertyConfiguration(new MockPropertyInfo(), () => innerConfig);

            var result = config.HasMaxLength(256);

            Assert.Equal(256, innerConfig.MaxLength);
            Assert.Equal(false, innerConfig.IsFixedLength);
            Assert.Equal(null, innerConfig.IsUnicode);
            Assert.Same(config, result);
        }
Exemple #24
0
        public void HasMaxLength_configures_IsUnicode_when_unset()
        {
            var innerConfig = new StringPropertyConfiguration();
            var config      = new LightweightPropertyConfiguration(new MockPropertyInfo(), () => innerConfig);

            var result = config.HasMaxLength(256);

            Assert.Equal(256, innerConfig.MaxLength);
            Assert.Equal(false, innerConfig.IsFixedLength);
            Assert.Equal(true, innerConfig.IsUnicode);
            Assert.Same(config, result);
        }
        public void Apply_should_not_set_is_max_length_if_value_exists()
        {
            var propertyConfiguration = new StringPropertyConfiguration
                                            {
                                                IsMaxLength = false
                                            };

            new MaxLengthAttributeConvention()
                .Apply(new MockPropertyInfo(), propertyConfiguration, new MaxLengthAttribute());

            Assert.Null(propertyConfiguration.MaxLength);
            Assert.Equal(false, propertyConfiguration.IsMaxLength);
        }
        public void IsUnicode_with_parameter_is_noop_when_set()
        {
            var innerConfig = new Properties.Primitive.StringPropertyConfiguration
            {
                IsUnicode = true
            };
            var config = new ConventionPrimitivePropertyConfiguration(new MockPropertyInfo(), () => innerConfig);

            var result = config.IsUnicode(false);

            Assert.Equal(true, innerConfig.IsUnicode);
            Assert.Same(config, result);
        }
Exemple #27
0
        public void IsUnicode_is_noop_when_set()
        {
            var innerConfig = new StringPropertyConfiguration
            {
                IsUnicode = false
            };
            var config = new LightweightPropertyConfiguration(new MockPropertyInfo(), () => innerConfig);

            var result = config.IsUnicode();

            Assert.Equal(false, innerConfig.IsUnicode);
            Assert.Same(config, result);
        }
        public void IsUnicode_with_parameter_configures_when_unset()
        {
            var innerConfig = new StringPropertyConfiguration();
            var config = new LightweightPropertyConfiguration(new MockPropertyInfo(), () => innerConfig);

            var result = config.IsUnicode(false);

            Assert.Equal(false, innerConfig.IsUnicode);
            Assert.Same(config, result);
        }
        public void IsUnicode_is_noop_when_set()
        {
            var innerConfig = new StringPropertyConfiguration
                                  {
                                      IsUnicode = false
                                  };
            var config = new LightweightPropertyConfiguration(new MockPropertyInfo(), () => innerConfig);

            var result = config.IsUnicode();

            Assert.Equal(false, innerConfig.IsUnicode);
            Assert.Same(config, result);
        }
Exemple #30
0
 private StringPropertyConfiguration(StringPropertyConfiguration source)
     : base((LengthPropertyConfiguration)source)
 {
     this.IsUnicode = source.IsUnicode;
 }
        public void IsUnicode_configures_when_unset()
        {
            var innerConfig = new Properties.Primitive.StringPropertyConfiguration();
            var config = new ConventionPrimitivePropertyConfiguration(new MockPropertyInfo(), () => innerConfig);

            var result = config.IsUnicode();

            Assert.Equal(true, innerConfig.IsUnicode);
            Assert.Same(config, result);
        }
        public void IsUnicode_with_parameter_is_noop_when_set()
        {
            var innerConfig = new Properties.Primitive.StringPropertyConfiguration
                {
                    IsUnicode = true
                };
            var config = new ConventionPrimitivePropertyConfiguration(new MockPropertyInfo(), () => innerConfig);

            var result = config.IsUnicode(false);

            Assert.Equal(true, innerConfig.IsUnicode);
            Assert.Same(config, result);
        }
        public void HasMaxLength_does_not_configure_IsUnicode_when_set()
        {
            var innerConfig = new Properties.Primitive.StringPropertyConfiguration
                {
                    IsUnicode = false
                };
            var config = new ConventionPrimitivePropertyConfiguration(new MockPropertyInfo(), () => innerConfig);

            var result = config.HasMaxLength(256);

            Assert.Equal(256, innerConfig.MaxLength);
            Assert.Equal(false, innerConfig.IsFixedLength);
            Assert.Equal(false, innerConfig.IsUnicode);
            Assert.Same(config, result);
        }
 internal StringColumnConfiguration(Properties.Primitive.StringPropertyConfiguration configuration)
     : base(configuration)
 {
 }
        public void HasMaxLength_configures_IsUnicode_when_unset()
        {
            var innerConfig = new StringPropertyConfiguration();
            var config = new LightweightPropertyConfiguration(new MockPropertyInfo(), () => innerConfig);

            var result = config.HasMaxLength(256);

            Assert.Equal(256, innerConfig.MaxLength);
            Assert.Equal(false, innerConfig.IsFixedLength);
            Assert.Equal(true, innerConfig.IsUnicode);
            Assert.Same(config, result);
        }