private static IHistoryRepository CreateHistoryRepository(string schema = null)
        {
            var sqlGenerator = new JetSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies());
            var typeMapper   = new JetTypeMapper(new RelationalTypeMapperDependencies());

            var commandBuilderFactory = new RelationalCommandBuilderFactory(
                new FakeDiagnosticsLogger <DbLoggerCategory.Database.Command>(),
                typeMapper);

            return(new JetHistoryRepository(
                       new HistoryRepositoryDependencies(
                           Mock.Of <IRelationalDatabaseCreator>(),
                           Mock.Of <IRawSqlCommandBuilder>(),
                           Mock.Of <IJetRelationalConnection>(),
                           new DbContextOptions <DbContext>(
                               new Dictionary <Type, IDbContextOptionsExtension>
            {
                {
                    typeof(JetOptionsExtension),
                    new JetOptionsExtension().WithMigrationsHistoryTableSchema(schema)
                }
            }),
                           new MigrationsModelDiffer(
                               new JetTypeMapper(new RelationalTypeMapperDependencies()),
                               new JetMigrationsAnnotationProvider(new MigrationsAnnotationProviderDependencies())),
                           new JetMigrationsSqlGenerator(
                               new MigrationsSqlGeneratorDependencies(
                                   commandBuilderFactory,
                                   new JetSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies()),
                                   typeMapper),
                               new JetMigrationsAnnotationProvider(new MigrationsAnnotationProviderDependencies())),
                           sqlGenerator)));
        }
        public void GenerateLiteral_returns_ByteArray_literal()
        {
            var value   = new byte[] { 0xDA, 0x7A };
            var literal = new JetTypeMapper(new RelationalTypeMapperDependencies())
                          .GetMapping(typeof(byte[])).GenerateSqlLiteral(value);

            Assert.Equal("0xDA7A", literal);
        }
        public void GenerateLiteral_returns_DateTime_literal()
        {
            var value   = new DateTime(1969, 09, 15, 20, 21, 22, 371);
            var literal = new JetTypeMapper(new RelationalTypeMapperDependencies())
                          .GetMapping(typeof(DateTime)).GenerateSqlLiteral(value);

            Assert.Equal("#09/15/1969 20:21:22#", literal);
        }
Пример #4
0
        public static ConventionSet Build()
        {
            var jetTypeMapper = new JetTypeMapper(new RelationalTypeMapperDependencies());

            return(new JetConventionSetBuilder(
                       new RelationalConventionSetBuilderDependencies(jetTypeMapper, null, null),
                       new JetSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies()))
                   .AddConventions(
                       new CoreConventionSetBuilder(
                           new CoreConventionSetBuilderDependencies(jetTypeMapper))
                       .CreateConventionSet()));
        }
        public void Does_indexed_column_Jet_binary_mapping()
        {
            var entityType = CreateEntityType();
            var property   = entityType.AddProperty("MyProp", typeof(byte[]));

            entityType.AddIndex(property);

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

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

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

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

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

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

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

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

            entityType.AddIndex(property);

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

            Assert.Equal(DbType.String, typeMapping.DbType);
            Assert.Equal("varchar(255)", typeMapping.StoreType);
            Assert.Equal(255, typeMapping.Size);
            Assert.True(typeMapping.IsUnicode);
            Assert.Equal(255, typeMapping.CreateParameter(new TestCommand(), "Name", "Value").Size);
        }
        public void Does_key_Jet_string_mapping()
        {
            var property = CreateEntityType().AddProperty("MyProp", typeof(string));

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

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

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