コード例 #1
0
        public UpgradeAsyncTests()
        {
            logger         = A.Fake <ILogger <MigrationRunner> >();
            container      = A.Fake <IRapidContainerAdapter>();
            environment    = A.Fake <IMigrationEnvironment>();
            appLocker      = A.Fake <IDistributedAppLockProvider>();
            contextFactory = A.Fake <IMigrationContextFactory>();
            finder         = A.Fake <IMigrationFinder>();
            storage        = A.Fake <IMigrationStorage>();
            context        = A.Fake <IMigrationContext>();
            appLock        = A.Fake <IDistributedAppLock>();
            migration1     = A.Fake <IMigration>();
            migration2     = A.Fake <IMigration>();

            A.CallTo(() => appLocker.AcquireAsync("RapidCoreMigrations", A <TimeSpan> ._, A <TimeSpan> ._))
            .Returns(Task.FromResult(appLock));
            A.CallTo(() => contextFactory.GetContext()).Returns(context);

            runner = new MigrationRunner(
                logger,
                container,
                environment,
                appLocker,
                contextFactory,
                finder,
                storage
                );
        }
コード例 #2
0
 /// <summary>
 /// Bypasses dependency injection almost entirely to give an easy
 /// to get started with migration runner.
 ///
 /// You must register <see cref="IConnectionMultiplexer"/> in <paramref name="services"/>.
 /// </summary>
 /// <param name="services">The dependency injection container provided by dotnet Core</param>
 /// <param name="environmentName">The name of the environment you are running in</param>
 /// <param name="appLocker">The locker to use</param>
 /// <param name="assemblyWithMigrations">The assembly containing your migration classes</param>
 public YoloMigrationRunner(
     IServiceProvider services,
     string environmentName,
     IDistributedAppLockProvider appLocker,
     Assembly assemblyWithMigrations
     )
     : base(
         new LoggerFactory().CreateLogger <MigrationRunner>(),
         new ServiceProviderRapidContainerAdapter(services),
         new MigrationEnvironment(environmentName),
         appLocker,
         new RedisMigrationContextFactory(),
         new ReflectionMigrationFinder(assemblyWithMigrations),
         new RedisMigrationStorage()
         )
 {
 }
コード例 #3
0
 public MigrationRunner(
     ILogger <MigrationRunner> logger,
     IRapidContainerAdapter container,
     IMigrationEnvironment environment,
     IDistributedAppLockProvider appLocker,
     IMigrationContextFactory contextFactory,
     IMigrationFinder finder,
     IMigrationStorage storage
     )
 {
     this.logger         = logger;
     this.container      = container;
     this.environment    = environment;
     this.appLocker      = appLocker;
     this.contextFactory = contextFactory;
     this.finder         = finder;
     this.storage        = storage;
 }