public void HasAnnotation_evaluates_preconditions()
        {
            var innerConfig = new Properties.Primitive.PrimitivePropertyConfiguration();
            var config      = new ConventionPrimitivePropertyConfiguration(new MockPropertyInfo(), () => innerConfig);

            Assert.Equal(
                Strings.ArgumentIsNullOrWhitespace("name"),
                Assert.Throws <ArgumentException>(() => config.HasColumnAnnotation(null, null)).Message);

            Assert.Equal(
                Strings.ArgumentIsNullOrWhitespace("name"),
                Assert.Throws <ArgumentException>(() => config.HasColumnAnnotation(" ", null)).Message);

            Assert.Equal(
                Strings.BadAnnotationName("Cheese:Pickle"),
                Assert.Throws <ArgumentException>(() => config.HasColumnAnnotation("Cheese:Pickle", null)).Message);
        }
        public void HasAnnotation_configures_only_annotations_that_have_not_already_been_set()
        {
            var innerConfig = new Properties.Primitive.PrimitivePropertyConfiguration();

            innerConfig.SetAnnotation("A1", "V1");
            var config = new ConventionPrimitivePropertyConfiguration(new MockPropertyInfo(), () => innerConfig);

            var result = config.HasColumnAnnotation("A1", "V1B").HasColumnAnnotation("A2", "V2");

            Assert.Equal("V1", innerConfig.Annotations["A1"]);
            Assert.Equal("V2", innerConfig.Annotations["A2"]);
            Assert.Same(config, result);
        }
        public void Methods_dont_throw_if_configuration_is_null()
        {
            var config = new ConventionPrimitivePropertyConfiguration(new MockPropertyInfo(), () => null);

            config.HasColumnName("Column1");
            config.HasColumnOrder(0);
            config.HasColumnType("int");
            config.HasParameterName("Parameter1");
            config.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            config.HasMaxLength(1);
            config.HasPrecision(1);
            config.HasPrecision(1, 1);
            config.IsConcurrencyToken(false);
            config.IsOptional();
            config.IsRequired();
            config.IsUnicode();
            config.IsVariableLength();
            config.IsFixedLength();
            config.IsMaxLength();
            config.IsRowVersion();
            config.IsKey();
            config.HasColumnAnnotation("Fox", "Like an angel in disguise");
        }
        public void Methods_dont_throw_if_configuration_is_null()
        {
            var config = new ConventionPrimitivePropertyConfiguration(new MockPropertyInfo(), () => null);

            config.HasColumnName("Column1");
            config.HasColumnOrder(0);
            config.HasColumnType("int");
            config.HasParameterName("Parameter1");
            config.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            config.HasMaxLength(1);
            config.HasPrecision(1);
            config.HasPrecision(1, 1);
            config.IsConcurrencyToken(false);
            config.IsOptional();
            config.IsRequired();
            config.IsUnicode();
            config.IsVariableLength();
            config.IsFixedLength();
            config.IsMaxLength();
            config.IsRowVersion();
            config.IsKey();
            config.HasColumnAnnotation("Fox", "Like an angel in disguise");
        }
        public void HasAnnotation_configures_only_annotations_that_have_not_already_been_set()
        {
            var innerConfig = new Properties.Primitive.PrimitivePropertyConfiguration();
            innerConfig.SetAnnotation("A1", "V1");
            var config = new ConventionPrimitivePropertyConfiguration(new MockPropertyInfo(), () => innerConfig);

            var result = config.HasColumnAnnotation("A1", "V1B").HasColumnAnnotation("A2", "V2");

            Assert.Equal("V1", innerConfig.Annotations["A1"]);
            Assert.Equal("V2", innerConfig.Annotations["A2"]);
            Assert.Same(config, result);
        }
        public void HasAnnotation_evaluates_preconditions()
        {
            var innerConfig = new Properties.Primitive.PrimitivePropertyConfiguration();
            var config = new ConventionPrimitivePropertyConfiguration(new MockPropertyInfo(), () => innerConfig);

            Assert.Equal(
                Strings.ArgumentIsNullOrWhitespace("name"),
                Assert.Throws<ArgumentException>(() => config.HasColumnAnnotation(null, null)).Message);

            Assert.Equal(
                Strings.ArgumentIsNullOrWhitespace("name"),
                Assert.Throws<ArgumentException>(() => config.HasColumnAnnotation(" ", null)).Message);

            Assert.Equal(
                Strings.BadAnnotationName("Cheese:Pickle"),
                Assert.Throws<ArgumentException>(() => config.HasColumnAnnotation("Cheese:Pickle", null)).Message);
        }