public void ReturnCodeMigrationsFromAssemblyByInterface()
        {
            // arrange
            var dbProvider = Mock.Of <IDbProvider>();

            var logger   = Mock.Of <ILogger>();
            var provider = new CodeMigrationsProvider(GetServiceCollection());

            provider.FromAssembly <ISpecificCodeMigrations>(Assembly.GetExecutingAssembly());

            // act
            var migrations = provider
                             .GetMigrations(dbProvider, new Dictionary <string, string>(), logger)
                             .ToList();

            // assert
            Assert.Equal(2, migrations.Count);

            Assert.True(migrations[0] is CodeMigration);
            Assert.Equal(new DbVersion(1, 1), migrations[0].Version);
            Assert.Equal("comment", migrations[0].Comment);

            Assert.True(migrations[1] is CodeMigration);
            Assert.Equal(new DbVersion(1, 2), migrations[1].Version);
            Assert.Equal("comment", migrations[1].Comment);
        }
        public void ReturnCodeMigrationsFromAssemblyByBaseClass()
        {
            // arrange
            var dbProvider = Mock.Of <IDbProvider>();
            var logger     = Mock.Of <ILogger>();

            var provider = new CodeMigrationsProvider(GetServiceCollection());

            provider.FromAssembly <CustomBaseCodeMigration>(Assembly.GetExecutingAssembly());

            // act
            var migrations = provider
                             .GetMigrations(dbProvider, new Dictionary <string, string>(), logger)
                             .ToList();

            // assert
            Assert.Single(migrations);

            Assert.True(migrations[0] is CodeMigration);
            Assert.Equal(new DbVersion(1, 3), migrations[0].Version);
            Assert.Equal("comment", migrations[0].Comment);
        }
        public void ReturnCodeMigrationWithDependenciesFromIoC()
        {
            // arrange
            var dbProvider = Mock.Of <IDbProvider>();
            var logger     = Mock.Of <ILogger>();

            var provider = new CodeMigrationsProvider(GetServiceCollection());

            provider.FromAssembly(Assembly.GetExecutingAssembly());

            // act
            var migrations = provider
                             .GetMigrations(dbProvider, new Dictionary <string, string>(), logger)
                             .ToList();

            // assert

            migrations.Count.Should().Be(4, "because we have only 4 code migrations");
            var typedMigration = migrations[3] as FourthMigrationWithDependency;

            typedMigration.Should().NotBeNull();
            typedMigration.DependencyService.Should().NotBeNull("because IoC should create dependency");
        }