public void Does_key_SQL_Server_binary_mapping()
        {
            var property = CreateEntityType().AddProperty("MyProp", typeof(byte[]));

            property.IsNullable = false;
            property.DeclaringEntityType.SetPrimaryKey(property);

            var typeMapping = new SqlCeTypeMapper().GetMapping(property);

            Assert.Equal(DbType.Binary, typeMapping.StoreType);
            Assert.Equal("varbinary(512)", typeMapping.DefaultTypeName);
            Assert.Equal(0, typeMapping.CreateParameter(new TestCommand(), "Name", new byte[3]).Size);
        }
        public void Does_indexed_column_SQL_Server_binary_mapping()
        {
            var entityType = CreateEntityType();
            var property   = entityType.AddProperty("MyProp", typeof(byte[]));

            entityType.AddIndex(property);

            var typeMapping = new SqlCeTypeMapper().GetMapping(property);

            Assert.Equal(DbType.Binary, typeMapping.StoreType);
            Assert.Equal("varbinary(512)", typeMapping.DefaultTypeName);
            Assert.Equal(0, typeMapping.CreateParameter(new TestCommand(), "Name", "Value").Size);
        }
        public void Does_key_SQL_Server_string_mapping()
        {
            var property = CreateEntityType().AddProperty("MyProp", typeof(string));

            property.IsNullable = false;
            property.DeclaringEntityType.SetPrimaryKey(property);

            var typeMapping = new SqlCeTypeMapper().GetMapping(property);

            Assert.Equal(DbType.String, typeMapping.StoreType);
            Assert.Equal("nvarchar(256)", typeMapping.DefaultTypeName);
            Assert.Equal(0, typeMapping.CreateParameter(new TestCommand(), "Name", "Value").Size);
        }
        public void Does_indexed_column_SQL_Server_string_mapping()
        {
            var entityType = CreateEntityType();
            var property   = entityType.AddProperty("MyProp", typeof(string));

            entityType.AddIndex(property);

            var typeMapping = new SqlCeTypeMapper().GetMapping(property);

            Assert.Equal(DbType.String, typeMapping.StoreType);
            Assert.Equal("nvarchar(256)", typeMapping.DefaultTypeName);
            Assert.Equal(0, typeMapping.CreateParameter(new TestCommand(), "Name", "Value").Size);
        }
        public void Does_indexed_column_SQL_Server_binary_mapping()
        {
            var entityType = CreateEntityType();
            var property   = entityType.AddProperty("MyProp", typeof(byte[]));

            entityType.AddIndex(property);

            var typeMapping = new SqlCeTypeMapper(new RelationalTypeMapperDependencies()).GetMapping(property);

            Assert.Equal(DbType.Binary, typeMapping.DbType);
            Assert.Equal("varbinary(512)", typeMapping.StoreType);
            Assert.Equal(512, typeMapping.CreateParameter(new TestCommand(), "Name", new byte[3]).Size);
        }
        public void Does_non_key_SQL_Server_rowversion_mapping()
        {
            var property = CreateEntityType().AddProperty("MyProp", typeof(byte[]));

            property.IsConcurrencyToken = true;
            property.ValueGenerated     = ValueGenerated.OnAddOrUpdate;

            var typeMapping = new SqlCeTypeMapper(new RelationalTypeMapperDependencies()).GetMapping(property);

            Assert.Equal(DbType.Binary, typeMapping.DbType);
            Assert.Equal("rowversion", typeMapping.StoreType);
            Assert.Equal(8, typeMapping.Size);
            Assert.Equal(8, typeMapping.CreateParameter(new TestCommand(), "Name", new byte[8]).Size);
        }
        public void Does_indexed_column_SQL_Server_string_mapping()
        {
            var entityType = CreateEntityType();
            var property   = entityType.AddProperty("MyProp", typeof(string));

            entityType.AddIndex(property);

            var typeMapping = new SqlCeTypeMapper(new RelationalTypeMapperDependencies()).GetMapping(property);

            Assert.Equal(DbType.String, typeMapping.DbType);
            Assert.Equal("nvarchar(256)", typeMapping.StoreType);
            Assert.Equal(256, typeMapping.Size);
            Assert.True(typeMapping.IsUnicode);
            Assert.Equal(256, typeMapping.CreateParameter(new TestCommand(), "Name", "Value").Size);
        }
        public void Does_foreign_key_SQL_Server_binary_mapping()
        {
            var property = CreateEntityType().AddProperty("MyProp", typeof(byte[]));

            property.IsNullable = false;
            var fkProperty = property.DeclaringEntityType.AddProperty("FK", typeof(byte[]));
            var pk         = property.DeclaringEntityType.SetPrimaryKey(property);

            property.DeclaringEntityType.AddForeignKey(fkProperty, pk, property.DeclaringEntityType);

            var typeMapping = new SqlCeTypeMapper(new RelationalTypeMapperDependencies()).GetMapping(fkProperty);

            Assert.Equal(DbType.Binary, typeMapping.DbType);
            Assert.Equal("varbinary(512)", typeMapping.StoreType);
            Assert.Equal(512, typeMapping.CreateParameter(new TestCommand(), "Name", new byte[3]).Size);
        }
        public void Does_foreign_key_SQL_Server_string_mapping()
        {
            var property = CreateEntityType().AddProperty("MyProp", typeof(string));

            property.IsNullable = false;
            var fkProperty = property.DeclaringEntityType.AddProperty("FK", typeof(string));
            var pk         = property.DeclaringEntityType.SetPrimaryKey(property);

            property.DeclaringEntityType.AddForeignKey(fkProperty, pk, property.DeclaringEntityType);

            var typeMapping = new SqlCeTypeMapper(new RelationalTypeMapperDependencies()).GetMapping(fkProperty);

            Assert.Equal(DbType.String, typeMapping.DbType);
            Assert.Equal("nvarchar(256)", typeMapping.StoreType);
            Assert.Equal(256, typeMapping.Size);
            Assert.True(typeMapping.IsUnicode);
            Assert.Equal(256, typeMapping.CreateParameter(new TestCommand(), "Name", "Value").Size);
        }