public void RestoreDatabase_AllOptionsToggled_DoesNotThrow() { var newDatabaseName = "RestoredFromTest.Cake"; try { //Arrange var path = GetBackupFilePath(); var settings = new RestoreSqlBackupSettings() { NewDatabaseName = newDatabaseName, NewStorageFolder = new DirectoryPath(Path.GetTempPath()), WithReplace = true, SwitchToSingleUserMode = false, }; // Act SqlBackupsImpl.RestoreSqlBackup(context, ConnectionString, new FilePath(path), settings); // Assert SqlHelpers.DbExists(ConnectionString, newDatabaseName); } finally { // Cleanup SqlHelpers.DropDatabase(ConnectionString, newDatabaseName); } }
public void RestoreDatabase_NoSingleUserModeInformation_DoesNotThrow() { var originalDbName = "CakeRestoreTest"; try { //Arrange var path = GetBackupFilePath(); var settings = new RestoreSqlBackupSettings() { SwitchToSingleUserMode = false }; // Act SqlBackupsImpl.RestoreSqlBackup(context, ConnectionString, new FilePath(path), settings); // Assert SqlHelpers.DbExists(ConnectionString, originalDbName); } finally { // Cleanup SqlHelpers.DropDatabase(ConnectionString, originalDbName); } }
public void RestoreDatabase_MoveLocation_DoesNotThrow() { var newDatabaseName = "RestoredFromTest.Cake"; try { //Arrange var path = GetBackupFilePath(); var settings = new RestoreSqlBackupSettings() { NewDatabaseName = newDatabaseName, NewStorageFolder = new DirectoryPath(System.IO.Path.GetTempPath()) }; // Act SqlBackupsImpl.RestoreSqlBackup(context, ConnectionString, new FilePath(path), settings); // Assert SqlHelpers.DbExists(ConnectionString, newDatabaseName); } finally { // Cleanup SqlHelpers.DropDatabase(ConnectionString, newDatabaseName); } }
public void Can_Read_DefaultDataPath() { using (var connection = SqlServerAliasesImpl.OpenSqlConnection(context, ConnectionString)) { // Act var path = SqlBackupsImpl.GetDefaultDataPath(connection); // Assert path.Should().NotBeNullOrEmpty(); Directory.Exists(path).Should().BeTrue(); } }
public void GetDatabaseName_Should_ReturnName() { using (var connection = SqlServerAliasesImpl.OpenSqlConnection(context, ConnectionString)) { //Arrange var path = GetBackupFilePath(); // Act var names = SqlBackupsImpl.GetDatabaseName(path, connection); // Assert names.Should().Be("CakeRestoreTest"); } }
public void Can_Read_LogicalNames() { using (var connection = SqlServerAliasesImpl.OpenSqlConnection(context, ConnectionString)) { //Arrange var path = GetBackupFilePath(); // Act var names = SqlBackupsImpl.GetLogicalNames(path, connection); // Assert names.Should().HaveCount(3); } }
public void RestoreDatabase_DatabaseRename_DoesNotThrow() { var databaseName = "NewRandomDatabase"; try { //Arrange var path = GetBackupFilePath(); SqlBackupsImpl.RestoreSqlBackup(context, ConnectionString, new FilePath(path), new RestoreSqlBackupSettings() { NewDatabaseName = databaseName }); // Assert SqlHelpers.DbExists(ConnectionString, databaseName); } finally { // Cleanup SqlHelpers.DropDatabase(ConnectionString, databaseName); } }
public void RestoreDatabase_WithReplace_DoesNotThrow() { var originalDbName = "CakeRestoreTest"; try { //Arrange var path = GetBackupFilePath(); // Act SqlBackupsImpl.RestoreSqlBackup(context, ConnectionString, new FilePath(path), new RestoreSqlBackupSettings() { WithReplace = true }); // Assert SqlHelpers.DbExists(ConnectionString, originalDbName); } finally { // Cleanup SqlHelpers.DropDatabase(ConnectionString, originalDbName); } }