private static IHistoryRepository CreateHistoryRepository()
        {
            var annotationsProvider = new SqlServerAnnotationProvider();
            var sqlGenerator        = new SqlServerSqlGenerator();
            var typeMapper          = new SqlServerTypeMapper();

            var commandBuilderFactory = new RelationalCommandBuilderFactory(
                typeMapper);

            return(new SqlServerHistoryRepository(
                       Mock.Of <IRelationalDatabaseCreator>(),
                       Mock.Of <ISqlStatementExecutor>(),
                       Mock.Of <ISqlServerConnection>(),
                       new DbContextOptions <DbContext>(
                           new Dictionary <Type, IDbContextOptionsExtension>
            {
                { typeof(SqlServerOptionsExtension), new SqlServerOptionsExtension() }
            }),
                       new MigrationsModelDiffer(
                           annotationsProvider,
                           new SqlServerMigrationsAnnotationProvider()),
                       new SqlServerMigrationsSqlGenerator(
                           commandBuilderFactory,
                           new SqlServerSqlGenerator(),
                           typeMapper,
                           annotationsProvider),
                       annotationsProvider,
                       sqlGenerator));
        }
        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)));
        }
示例#3
0
        private static IHistoryRepository CreateHistoryRepository()
        {
            var annotationsProvider = new SqlCeAnnotationProvider();
            var sqlGenerator        = new SqlCeSqlGenerationHelper();
            var typeMapper          = new SqlCeTypeMapper();

            var commandBuilderFactory = new RelationalCommandBuilderFactory(
                new FakeSensitiveDataLogger <RelationalCommandBuilderFactory>(),
                new DiagnosticListener("Fake"),
                typeMapper);

            return(new SqlCeHistoryRepository(
                       Mock.Of <IRelationalDatabaseCreator>(),
                       Mock.Of <IRawSqlCommandBuilder>(),
                       Mock.Of <ISqlCeDatabaseConnection>(),
                       new DbContextOptions <DbContext>(
                           new Dictionary <Type, IDbContextOptionsExtension>
            {
                { typeof(SqlCeOptionsExtension), new SqlCeOptionsExtension() }
            }),
                       new MigrationsModelDiffer(
                           new SqlCeTypeMapper(),
                           annotationsProvider,
                           new SqlCeMigrationsAnnotationProvider()),
                       new SqlCeMigrationsSqlGenerator(
                           commandBuilderFactory,
                           new SqlCeSqlGenerationHelper(),
                           typeMapper,
                           annotationsProvider),
                       annotationsProvider,
                       sqlGenerator));
        }
        private static IHistoryRepository CreateHistoryRepository(string schema = null)
        {
            var annotationsProvider = new SqlServerAnnotationProvider();
            var sqlGenerator        = new SqlServerSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies());
            var typeMapper          = new SqlServerTypeMapper(new RelationalTypeMapperDependencies());

            var commandBuilderFactory = new RelationalCommandBuilderFactory(
                new FakeSensitiveDataLogger <RelationalCommandBuilderFactory>(),
                new DiagnosticListener("Fake"),
                typeMapper);

            return(new SqlServerHistoryRepository(
                       new HistoryRepositoryDependencies(
                           Mock.Of <IRelationalDatabaseCreator>(),
                           Mock.Of <IRawSqlCommandBuilder>(),
                           Mock.Of <ISqlServerConnection>(),
                           new DbContextOptions <DbContext>(
                               new Dictionary <Type, IDbContextOptionsExtension>
            {
                {
                    typeof(SqlServerOptionsExtension),
                    new SqlServerOptionsExtension {
                        MigrationsHistoryTableSchema = schema
                    }
                }
            }),
                           new MigrationsModelDiffer(
                               new SqlServerTypeMapper(new RelationalTypeMapperDependencies()),
                               annotationsProvider,
                               new SqlServerMigrationsAnnotationProvider(new MigrationsAnnotationProviderDependencies())),
                           new SqlServerMigrationsSqlGenerator(
                               new MigrationsSqlGeneratorDependencies(
                                   commandBuilderFactory,
                                   new SqlServerSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies()),
                                   typeMapper,
                                   annotationsProvider),
                               new SqlServerMigrationsAnnotationProvider(new MigrationsAnnotationProviderDependencies())),
                           annotationsProvider,
                           sqlGenerator)));
        }
        private static IHistoryRepository CreateHistoryRepository()
        {
            var optionsBuilder = new DbContextOptionsBuilder();

            optionsBuilder.UseMySQL(MySQLTestStore.rootConnectionString + "database=test;");
            var connection = new MySQLServerConnection(optionsBuilder.Options, new Logger <MySQLServerConnection>(new LoggerFactory()));

            var typeMapper = new MySQLTypeMapper();

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddEntityFrameworkMySQL()
            .AddDbContext <MyTestContext>();

            var serviceProvider = serviceCollection.BuildServiceProvider();

            var context = serviceProvider.GetRequiredService <MyTestContext>();

            var creator    = context.GetService <IRelationalDatabaseCreator>();
            var cmdBuilder = context.GetService <IRawSqlCommandBuilder>();

            var options = new DbContextOptions <DbContext>(
                new Dictionary <Type, IDbContextOptionsExtension>
            {
                {
                    typeof(MySQLOptionsExtension),
                    new MySQLOptionsExtension()
                }
            });

            var modelDiffer = new MigrationsModelDiffer(
                new MySQLTypeMapper(),
                new MySQLMigrationsAnnotationProvider(
                    new MigrationsAnnotationProviderDependencies()));

            var logger = new DiagnosticsLogger <DbLoggerCategory.Database.Command>(
                new LoggerFactory(),
                new LoggingOptions(),
                new DiagnosticListener("Fake"));

            var commandBuilderFactory = new RelationalCommandBuilderFactory(
                logger,
                typeMapper);

            var sqlGeneratorHelper = new MySQLSqlGenerationHelper(new RelationalSqlGenerationHelperDependencies());

            var migrationsSqlGeneratorDependencies = new MigrationsSqlGeneratorDependencies(
                commandBuilderFactory,
                sqlGeneratorHelper,
                typeMapper);

            var migrationsSqlGeneratior = new MySQLMigrationsSqlGenerator(migrationsSqlGeneratorDependencies);

            HistoryRepositoryDependencies dependencies = new HistoryRepositoryDependencies(
                creator,
                cmdBuilder,
                connection,
                options,
                modelDiffer,
                migrationsSqlGeneratior,
                sqlGeneratorHelper);

            return(new MySQLHistoryRepository(dependencies));
        }
        private static IHistoryRepository CreateHistoryRepository()
        {
            var annotationsProvider = new SqlServerAnnotationProvider();
            var sqlGenerator = new SqlServerSqlGenerator();
            var typeMapper = new SqlServerTypeMapper();

            var commandBuilderFactory = new RelationalCommandBuilderFactory(
                new FakeSensitiveDataLogger<RelationalCommandBuilderFactory>(),
                new DiagnosticListener("Fake"),
                typeMapper);

            return new SqlServerHistoryRepository(
                Mock.Of<IRelationalDatabaseCreator>(),
                Mock.Of<ISqlCommandBuilder>(),
                Mock.Of<ISqlServerConnection>(),
                new DbContextOptions<DbContext>(
                    new Dictionary<Type, IDbContextOptionsExtension>
                    {
                        { typeof(SqlServerOptionsExtension), new SqlServerOptionsExtension() }
                    }),
                new MigrationsModelDiffer(
                    annotationsProvider,
                    new SqlServerMigrationsAnnotationProvider()),
                new SqlServerMigrationsSqlGenerator(
                    commandBuilderFactory,
                    new SqlServerSqlGenerator(),
                    typeMapper,
                    annotationsProvider),
                annotationsProvider,
                sqlGenerator);
        }