public void Apply_should_set_timestamp_when_facets_empty()
        {
            var propertyConfiguration = new BinaryPropertyConfiguration();

            new TimestampAttributeConvention()
            .Apply(new MockPropertyInfo(), propertyConfiguration, new TimestampAttribute());

            Assert_Timestamp(propertyConfiguration);
        }
        private void Assert_Timestamp(BinaryPropertyConfiguration binaryPropertyConfiguration)
        {
            binaryPropertyConfiguration.Configure(EdmProperty.Primitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)));

            Assert.Equal("rowversion", binaryPropertyConfiguration.ColumnType);
            Assert.Equal(false, binaryPropertyConfiguration.IsNullable);
            Assert.Equal(ConcurrencyMode.Fixed, binaryPropertyConfiguration.ConcurrencyMode);
            Assert.Equal(DatabaseGeneratedOption.Computed, binaryPropertyConfiguration.DatabaseGeneratedOption);
            Assert.Equal(8, binaryPropertyConfiguration.MaxLength.Value);
        }
        public void Apply_should_not_set_timestamp_when_maxLength()
        {
            var propertyConfiguration = new BinaryPropertyConfiguration
            {
                MaxLength = 100
            };

            new TimestampAttributeConvention()
            .Apply(new MockPropertyInfo(), propertyConfiguration, new TimestampAttribute());

            Assert.Null(propertyConfiguration.ColumnType);
        }
        public void Apply_should_not_set_timestamp_when_identity()
        {
            var propertyConfiguration = new BinaryPropertyConfiguration
            {
                DatabaseGeneratedOption = DatabaseGeneratedOption.Identity
            };

            new TimestampAttributeConvention()
            .Apply(new MockPropertyInfo(), propertyConfiguration, new TimestampAttribute());

            Assert.Null(propertyConfiguration.ColumnType);
        }
        public void Apply_should_set_timestamp_when_rowversion_set()
        {
            var propertyConfiguration = new BinaryPropertyConfiguration
            {
                ColumnType = "rowversion"
            };

            new TimestampAttributeConvention()
            .Apply(new MockPropertyInfo(), propertyConfiguration, new TimestampAttribute());

            Assert_Timestamp(propertyConfiguration);
        }
        public void Apply_should_set_timestamp_when_concurrency_token_set()
        {
            var propertyConfiguration = new BinaryPropertyConfiguration
            {
                ConcurrencyMode = ConcurrencyMode.Fixed
            };

            new TimestampAttributeConvention()
            .Apply(new MockPropertyInfo(), propertyConfiguration, new TimestampAttribute());

            Assert_Timestamp(propertyConfiguration);
        }
        public void Apply_should_set_timestamp_when_required_set()
        {
            var propertyConfiguration = new BinaryPropertyConfiguration
            {
                IsNullable = false
            };

            new TimestampAttributeConvention()
            .Apply(new MockPropertyInfo(), propertyConfiguration, new TimestampAttribute());

            Assert_Timestamp(propertyConfiguration);
        }
        public void Apply_should_set_timestamp_when_length_set()
        {
            var propertyConfiguration = new BinaryPropertyConfiguration
            {
                MaxLength = 8
            };

            new TimestampAttributeConvention()
            .Apply(new MockPropertyInfo(), propertyConfiguration, new TimestampAttribute());

            Assert_Timestamp(propertyConfiguration);
        }
        public static BinaryPropertyConfiguration PrivateProperty <T>(
            this EntityTypeConfiguration <T> mapper,
            Expression <Func <T, byte[]> > exp,
            NamingConventions?convention = null) where T : class
        {
            mapper.Ignore(exp);
            dynamic expression = exp;
            string  defaultColumnName;

            ExpressionModifier.ToPrivate(ref expression, convention, out defaultColumnName);
            BinaryPropertyConfiguration configuration = mapper.Property(expression);

            configuration.HasColumnName(defaultColumnName);
            return(configuration);
        }