Esempio n. 1
0
        public Migrator(
            [NotNull] DbContextConfiguration contextConfiguration,
            [NotNull] HistoryRepository historyRepository,
            [NotNull] MigrationAssembly migrationAssembly,
            [NotNull] ModelDiffer modelDiffer,
            [NotNull] IMigrationOperationSqlGeneratorFactory ddlSqlGeneratorFactory,
            [NotNull] SqlGenerator dmlSqlGenerator,
            [NotNull] SqlStatementExecutor sqlExecutor)
        {
            Check.NotNull(contextConfiguration, "contextConfiguration");
            Check.NotNull(historyRepository, "historyRepository");
            Check.NotNull(migrationAssembly, "migrationAssembly");
            Check.NotNull(modelDiffer, "modelDiffer");
            Check.NotNull(ddlSqlGeneratorFactory, "ddlSqlGeneratorFactory");
            Check.NotNull(dmlSqlGenerator, "dmlSqlGenerator");
            Check.NotNull(sqlExecutor, "sqlExecutor");

            _contextConfiguration = contextConfiguration;
            _historyRepository = historyRepository;
            _migrationAssembly = migrationAssembly;
            _modelDiffer = modelDiffer;
            _ddlSqlGeneratorFactory = ddlSqlGeneratorFactory;
            _dmlSqlGenerator = dmlSqlGenerator;
            _sqlExecutor = sqlExecutor;
        }
 public ThrowingMonsterStateManager(
     DbContextConfiguration configuration,
     StateEntryFactory factory,
     EntityKeyFactorySource entityKeyFactorySource,
     StateEntrySubscriber subscriber)
     : base(configuration, factory, entityKeyFactorySource, subscriber)
 {
 }
Esempio n. 3
0
        public ChangeDetector([NotNull] DbContextConfiguration configuration, [NotNull] StateEntryNotifier notifier)
        {
            Check.NotNull(configuration, "configuration");
            Check.NotNull(notifier, "notifier");

            _configuration = configuration;
            _notifier = notifier;
        }
        public StateEntryFactory(
            [NotNull] DbContextConfiguration configuration,
            [NotNull] EntityMaterializerSource materializerSource)
        {
            Check.NotNull(configuration, "configuration");
            Check.NotNull(materializerSource, "materializerSource");

            _configuration = configuration;
            _materializerSource = materializerSource;
        }
        public ModificationCommandBatchFactory(
            [NotNull] SqlGenerator sqlGenerator,
            [NotNull] DbContextConfiguration contextConfiguration)
        {
            Check.NotNull(sqlGenerator, "sqlGenerator");
            Check.NotNull(contextConfiguration, "contextConfiguration");

            _sqlGenerator = sqlGenerator;
            _contextConfiguration = contextConfiguration;
        }
Esempio n. 6
0
        protected StateEntry(
            [NotNull] DbContextConfiguration configuration,
            [NotNull] IEntityType entityType)
        {
            Check.NotNull(configuration, "configuration");
            Check.NotNull(entityType, "entityType");

            _configuration = configuration;
            _entityType = entityType;
            _stateData = new StateData(entityType.Properties.Count);
        }
        public StateManager(
            [NotNull] DbContextConfiguration configuration,
            [NotNull] StateEntryFactory factory,
            [NotNull] EntityKeyFactorySource entityKeyFactorySource,
            [NotNull] StateEntrySubscriber subscriber)
        {
            Check.NotNull(configuration, "configuration");
            Check.NotNull(factory, "factory");
            Check.NotNull(entityKeyFactorySource, "entityKeyFactorySource");
            Check.NotNull(subscriber, "subscriber");

            _configuration = configuration;
            _keyFactorySource = entityKeyFactorySource;
            _factory = factory;
            _subscriber = subscriber;
        }
Esempio n. 8
0
        public NavigationFixer(
            [NotNull] DbContextConfiguration configuration,
            [NotNull] ClrPropertyGetterSource getterSource,
            [NotNull] ClrPropertySetterSource setterSource,
            [NotNull] ClrCollectionAccessorSource collectionAccessorSource)
        {
            Check.NotNull(configuration, "configuration");
            Check.NotNull(getterSource, "getterSource");
            Check.NotNull(setterSource, "setterSource");
            Check.NotNull(collectionAccessorSource, "collectionAccessorSource");

            _configuration = configuration;
            _getterSource = getterSource;
            _setterSource = setterSource;
            _collectionAccessorSource = collectionAccessorSource;
        }
        public MigrationScaffolder(
            [NotNull] DbContextConfiguration contextConfiguration,
            [NotNull] MigrationAssembly migrationAssembly,
            [NotNull] ModelDiffer modelDiffer,
            [NotNull] MigrationCodeGenerator migrationCodeGenerator)
        {
            Check.NotNull(contextConfiguration, "contextConfiguration");
            Check.NotNull(migrationAssembly, "migrationAssembly");
            Check.NotNull(modelDiffer, "modelDiffer");
            Check.NotNull(migrationCodeGenerator, "migrationCodeGenerator");

            _contextConfiguration = contextConfiguration;
            _migrationAssembly = migrationAssembly;
            _modelDiffer = modelDiffer;
            _migrationCodeGenerator = migrationCodeGenerator;
        }
        public void Available_when_configured()
        {
            var config = new DbContextConfiguration();
            config.Initialize(
                Mock.Of<IServiceProvider>(),
                Mock.Of<IServiceProvider>(),
                new DbContextOptions(),
                Mock.Of<DbContext>(),
                DbContextConfiguration.ServiceProviderSource.Implicit);

            var source = new RedisDataStoreSource(config);

            Assert.False(source.IsAvailable);

            config.ContextOptions.AddExtension(new RedisOptionsExtension());

            Assert.True(source.IsAvailable);
        }
        private Tuple<RelationalConnection, SqlStatement> PrepareCommand(DbContextConfiguration contextConfiguration)
        {
            // TODO: Parameterize query and/or delimit identifier without using SqlServerMigrationOperationSqlGenerator
            var sql = new SqlStatement(string.Format(
                CultureInfo.InvariantCulture,
                "SELECT NEXT VALUE FOR {0}", _sequenceName));

            // TODO: Should be able to get relational connection without cast
            var connection = (RelationalConnection)contextConfiguration.Connection;

            return Tuple.Create(connection, sql);
        }
Esempio n. 12
0
        private static Mock<MigrationAssembly> MockMigrationAssembly(
            DbContextConfiguration contextConfiguration, IReadOnlyList<IMigrationMetadata> migrations)
        {
            var mock = new Mock<MigrationAssembly>(contextConfiguration);

            mock.SetupGet(ma => ma.Migrations).Returns(migrations);

            return mock;
        }
Esempio n. 13
0
        private static Mock<HistoryRepository> MockHistoryRepository(
            DbContextConfiguration contextConfiguration, IReadOnlyList<IMigrationMetadata> migrations)
        {
            var mock = new Mock<HistoryRepository>(contextConfiguration);

            mock.SetupGet(hr => hr.Migrations).Returns(migrations.ToArray());

            mock.Setup(hr => hr.GenerateInsertMigrationSql(It.IsAny<IMigrationMetadata>(), It.IsAny<SqlGenerator>()))
                .Returns<IMigrationMetadata, SqlGenerator>((m, sg) => new[] { new SqlStatement(m.GetMigrationName() + "InsertSql") });

            mock.Setup(hr => hr.GenerateDeleteMigrationSql(It.IsAny<IMigrationMetadata>(), It.IsAny<SqlGenerator>()))
                .Returns<IMigrationMetadata, SqlGenerator>((m, sg) => new[] { new SqlStatement(m.GetMigrationName() + "DeleteSql") });

            return mock;
        }
Esempio n. 14
0
        public Database([NotNull] DbContextConfiguration configuration)
        {
            Check.NotNull(configuration, "configuration");

            _configuration = configuration;
        }
Esempio n. 15
0
        public Database([NotNull] DbContextConfiguration configuration)
        {
            Check.NotNull(configuration, "configuration");

            _configuration = configuration;
        }
Esempio n. 16
0
 protected virtual Migrator GetMigrator(DbContextConfiguration contextConfiguration)
 {
     return contextConfiguration.Services.ServiceProvider.GetService<Migrator>();
 }
        private static MigrationAssembly MockMigrationAssembly(DbContextConfiguration contextConfiguration)
        {
            var mock = new Mock<MigrationAssembly>(contextConfiguration);

            mock.SetupGet(ma => ma.Migrations).Returns(new IMigrationMetadata[0]);
            mock.SetupGet(ma => ma.Model).Returns((IModel)null);

            return mock.Object;
        }
 public MyMigrationScaffolder(
     DbContextConfiguration contextConfiguration,
     MigrationAssembly migrationAssembly,
     ModelDiffer modelDiffer,
     MigrationCodeGenerator migrationCodeGenerator,
     Action<string, string, string> migrationValidation,
     Action<string, string> modelValidation)
     : base(
         contextConfiguration,
         migrationAssembly,
         modelDiffer,
         migrationCodeGenerator)
 {
     _migrationValidation = migrationValidation;
     _modelValidation = modelValidation;
 }
        public ModificationCommandBatch([NotNull] DbContextConfiguration contextConfiguration)
        {
            Check.NotNull(contextConfiguration, "contextConfiguration");

            _contextConfiguration = contextConfiguration;
        }
Esempio n. 20
0
        public HistoryRepository([NotNull] DbContextConfiguration contextConfiguration)
        {
            Check.NotNull(contextConfiguration, "contextConfiguration");

            _contextConfiguration = contextConfiguration;
        }
 public FakeRelationalDataStore(
     DbContextConfiguration configuration,
     RelationalConnection connection,
     CommandBatchPreparer batchPreparer,
     BatchExecutor batchExecutor)
     : base(configuration, connection, batchPreparer, batchExecutor)
 {
 }
Esempio n. 22
0
 protected virtual MigrationScaffolder CreateScaffolder(
     DbContextConfiguration contextConfiguration, string migrationDirectory)
 {
     return
         new MigrationScaffolder(
             contextConfiguration,
             contextConfiguration.Services.ServiceProvider.GetService<MigrationAssembly>(),
             contextConfiguration.Services.ServiceProvider.GetService<ModelDiffer>(),
             new CSharpMigrationCodeGenerator(new CSharpModelCodeGenerator()));
 }
Esempio n. 23
0
        public MigrationAssembly([NotNull] DbContextConfiguration contextConfiguration)
        {
            Check.NotNull(contextConfiguration, "contextConfiguration");

            _contextConfiguration = contextConfiguration;
        }