public void ServerDatabaseIsPresentAndCorrect(bool alreadyExists) { var server = new ExternalDatabaseServer(CatalogueRepository, "Fiction", null); server.Server = DiscoveredServerICanCreateRandomDatabasesAndTablesOn.Name; //server.Database = "FictionalDatabase"; Ignored by the extractor! try { var destination = new ExecuteFullExtractionToDatabaseMSSql(); destination.PreInitialize(_projectStub, new ThrowImmediatelyDataLoadEventListener()); destination.PreInitialize(_commandStub, new ThrowImmediatelyDataLoadEventListener()); destination.TargetDatabaseServer = server; destination.TableNamingPattern = "$d"; if (alreadyExists) { destination.DatabaseNamingPattern = Database.GetRuntimeName(); //database that exists } else { destination.DatabaseNamingPattern = "Fictional$nDatabase"; //database does not exist (but server does) } var tomemory = new ToMemoryCheckNotifier(new ThrowImmediatelyCheckNotifier()); destination.Check(tomemory); Assert.AreEqual(alreadyExists? CheckResult.Warning: CheckResult.Success, tomemory.GetWorst()); } finally { server.DeleteInDatabase(); } }
public void ServerDatabaseIsPresentAndCorrectButHasTablesInIt() { var server = new ExternalDatabaseServer(CatalogueRepository, "Fiction", null); server.Server = DiscoveredServerICanCreateRandomDatabasesAndTablesOn.Name; //server.Database = "FictionalDatabase"; Ignored by the extractor! using (var con = Database.Server.GetConnection()) { con.Open(); Database.Server.GetCommand("CREATE TABLE Bob(name varchar(10))", con).ExecuteNonQuery(); } try { var destination = new ExecuteFullExtractionToDatabaseMSSql(); destination.PreInitialize(_projectStub, new ThrowImmediatelyDataLoadEventListener()); destination.PreInitialize(_commandStub, new ThrowImmediatelyDataLoadEventListener()); destination.TargetDatabaseServer = server; destination.TableNamingPattern = "$d"; destination.DatabaseNamingPattern = "FictionalDatabase"; var tomemory = new ToMemoryCheckNotifier(new ThrowImmediatelyCheckNotifier()); destination.Check(tomemory); Assert.AreEqual(CheckResult.Warning, tomemory.GetWorst()); Database.ExpectTable("Bob").Drop(); } finally { server.DeleteInDatabase(); } }