예제 #1
0
            public void CreatesContextBeforeRepo(DbAuthType authType, string connString)
            {
                var underTest = new RollbackMigrationAction(_migratorFactory.Object);

                TestConstants.ConfigureRequest(_request, authType);

                var contextCreated           = false;
                var contextCreatedBeforeRepo = false;

                _migratorFactory.Setup(m => m.CreateDbContext(It.IsAny <string>()))
                .Callback(() => contextCreated = true);

                _migratorFactory.Setup(m => m.CreateMigrationRepository(It.IsAny <IMigrationVersionContext>()))
                .Callback(() => contextCreatedBeforeRepo = contextCreated)
                .Returns(_repo.Object);

                underTest.Migrate(_request, _result);

                _migratorFactory.Verify(m => m.CreateDbContext(connString), Times.Once);
                Assert.True(contextCreatedBeforeRepo);
            }