public virtual void SetupConnections() { _dbCreationPath = ConfigurationManager.AppSettings["DbCreationPath"]; Assert.That(_dbCreationPath, Is.Not.Null, "Please specify a DbCreationPath appsetting in your config file"); Assert.That(_dbCreationPath, Is.Not.Empty, "Please specify a DbCreationPath appsetting in your config file that is not empty"); _disposableDbServerConnection = GetDisposableServerConn(); SetUpDisposableServer(); _disposableDbManager = new DisposableDbManager(_dbCreationPath, DisposableDbServer, DbName); }
public void Setup() { var databaseManager = new DisposableDbManager(DbCreationPath, ConnectionString, CatalogName); _disposableDbName = databaseManager.CreateCompleteDisposableDb(); var sqlConnectionStringBuilder = new SqlConnectionStringBuilder(ConnectionString) { InitialCatalog = _disposableDbName }; _connectionStringWithDbName = sqlConnectionStringBuilder.ToString(); }
private string CreateDisposableDb(string databaseName) { var restOfConnString = ConfigurationManager.AppSettings["DisposableDbConnString"] + ";Application Name=" + ApplicationNameForConnectionString + ";"; var dbhostname = ConfigurationManager.AppSettings["DisposableDbHostname"]; var dbCreationPath = ConfigurationManager.AppSettings["DbCreationPath"]; var server = ConnectionHelper.Connect(dbhostname, restOfConnString); var disposableDbManager = new DisposableDbManager(dbCreationPath, server, databaseName); var disposableDbName = disposableDbManager.CreateCompleteDisposableDb(); return string.Format("Initial Catalog={0};Data Source={1};{2}", disposableDbName, dbhostname, restOfConnString); }
public void CreateDisposableDb() { string dbCreationPath = ConfigurationManager.AppSettings["DbCreationPath"]; Server server = DatabaseCreationTests.GetDisposableDbServer(); var creator = new DisposableDbManager(dbCreationPath, server, DbName); DisposableDb = server.Databases[creator.CreateCompleteDisposableDb()]; }
public void SetUpDisposableServer() { const string dbCreationPath = @"C:\SQLData"; _disposableDbServer = ConnectionHelper.Connect(DB_HOST_NAME, REST_OF_CONNECTION_STRING); _disposableDbManager = new DisposableDbManager(dbCreationPath, _disposableDbServer, DB_NAME); }
private DatabaseChangeSet TryMergingAndCompare(FileInfo migration, string baseDbWithNoMigrations, ICollection<string> migrationsToRun, string dbTempDirPath) { string dbPlusMigration = null, dbWithMigrationMerged = null; DatabaseChangeSet changes = null; try { if (Directory.Exists(dbTempDirPath)) { Directory.Delete(dbTempDirPath, true); } var dbTempDir = Directory.CreateDirectory(dbTempDirPath); Folders.CopyDirectory(_dbPath.FullName, dbTempDir.FullName); Console.WriteLine(dbTempDir.FullName); var lonelyCreator = new DisposableDbManager(_dbCreationPath, _disposableDbServer, DbName, dbTempDir.FullName); lonelyCreator.AllowCreatingSameDb = true; dbPlusMigration = lonelyCreator.CreateCompleteDisposableDbWithMigrations(migrationsToRun); DatabaseChangeSet changesFromMigration = DbComparer.CompareDatabases(_disposableDbServer.Databases[baseDbWithNoMigrations], _disposableDbServer.Databases[dbPlusMigration]); DbScriptFolderManager.UpdateScripts(dbTempDir.FullName, changesFromMigration, migration); dbWithMigrationMerged = lonelyCreator.CreateCompleteDisposableDbWithMigrations(new string[0]); changes = DbComparer.CompareDatabases(_disposableDbServer.Databases[dbPlusMigration], _disposableDbServer.Databases[dbWithMigrationMerged], DatabaseComparisonTests.DefaultSanitizeForComparison); } finally { Cleanup(dbPlusMigration, dbWithMigrationMerged); } return changes; }
public void CheckThatDisposableDbCreationStillWorksAfterApplyingEachMigration() { _dbCreationPath = ConfigurationManager.AppSettings["DbCreationPath"]; _disposableDbServer = DatabaseCreationTests.GetDisposableDbServer(); var creator = new DisposableDbManager(_dbCreationPath, _disposableDbServer, DbName); creator.AllowCreatingSameDb = true; var baseDbWithNoMigrations = creator.CreateCompleteDisposableDbWithMigrations(new string[0]); _dbPath = DisposableDbManager.FindDatabaseScriptsPath(DbName); IEnumerable<FileInfo> migrations = new MigrationManager().GetSqlSriptsIn(_dbPath.FullName); var migrationsAlreadyTested = new List<string>(); foreach (var migration in migrations) { TestMigration(migration, migrationsAlreadyTested, baseDbWithNoMigrations); migrationsAlreadyTested.Add(Path.GetFileNameWithoutExtension(migration.FullName)); } }