tests/UnitTests/Curiosity.Migrations.UnitTests/Services_Should.cs
/// <summary>
/// Checks registering single migrator to IoC
/// </summary>
Checks registering single migrator to IoC
Checks registering single migrator to IoC
[Fact]
        public void AddMigrationToService()
        {
            var provider = new Mock<IDbProvider>();
            var providerFactory = new Mock<IDbProviderFactory>();
            providerFactory
                .Setup(x => x.CreateDbProvider())
                .Returns(provider.Object);
            var services = new ServiceCollection();
            services.AddTransient<DependencyService>();
            services.AddMigrations(options =>
            {
                options
                    .UseScriptMigrations()
                    .FromAssembly(Assembly.GetExecutingAssembly());
                options
                    .UserDbProviderFactory(providerFactory.Object);
            });
            var serviceProvider = services.BuildServiceProvider();
            var migrator = serviceProvider.GetRequiredService<IDbMigrator>();
            migrator.Should().NotBeNull("because we've registered it");
        }
[ Fact ] public void AddMigrationToService ( ) { var provider = new Mock < IDbProvider > ( ) ; var providerFactory = new Mock < IDbProviderFactory > ( ) ; providerFactory . Setup ( x => x . CreateDbProvider ( ) ) . Returns ( provider . Object ) ; var services = new ServiceCollection ( ) ; services . AddTransient < DependencyService > ( ) ; services . AddMigrations ( options => { options . UseScriptMigrations ( ) . FromAssembly ( Assembly . GetExecutingAssembly ( ) ) ; options . UserDbProviderFactory ( providerFactory . Object ) ; } ) ; var serviceProvider = services . BuildServiceProvider ( ) ; var migrator = serviceProvider . GetRequiredService < IDbMigrator > ( ) ; migrator . Should ( ) . NotBeNull ( " " ) ; }
Checks registering single migrator to IoC
Checks registering single migrator to IoC
// arrange // act // assert