public string Create(string server, string instance, string database, string snapshot, string username = "", string password="") { DbSnapshotMgr mgr = new DbSnapshotMgr(); DbConnectionInfo connectionInfo; if(!string.IsNullOrWhiteSpace(username) && !string.IsNullOrWhiteSpace(password)) { connectionInfo = new DbConnectionInfo(server, instance, username, password); } else { connectionInfo = new DbConnectionInfo(server,instance); } try { mgr.CreateSnapshot(connectionInfo,database,snapshot); } catch (Exception ex) { return ex.ToString(); } return "Ok"; }
public void CreateSnapshotMissingDb() { var target = new DbSnapshotMgr(); var connectionInfo = new DbConnectionInfo(@".\", "SQL2012"); string databaseName = "UnknowDatabase"; string snapshotDatabaseName = string.Empty; try { target.CreateSnapshot(connectionInfo, databaseName, snapshotDatabaseName); } catch (ArgumentOutOfRangeException ex) { Assert.IsTrue(ex.Message.Contains(databaseName)); } }
public void CreateSnapshotNoValidDbNameParameters() { var target = new DbSnapshotMgr(); var connectionInfo = new DbConnectionInfo(); string databaseName = string.Empty; string snapshotDatabaseName = string.Empty; try { target.CreateSnapshot(connectionInfo, databaseName, snapshotDatabaseName); Assert.Fail(); } catch (ArgumentNullException ex) { Assert.IsTrue(ex.Message.Contains("databaseName")); } }
public void CreateSnapshotValidthCustomSnapshotName() { var target = new DbSnapshotMgr(); var connectionInfo = new DbConnectionInfo(@".\", "SQL2012"); string databaseName = "Certit"; string snapshotDatabaseName = "Certit_pretest"; try { target.CreateSnapshot(connectionInfo, databaseName, snapshotDatabaseName); } catch (ArgumentNullException ex) { Assert.IsTrue(ex.Message.Contains("databaseName")); } }
public void CreateSnapshotValid() { var target = new DbSnapshotMgr(); var connectionInfo = new DbConnectionInfo(@".\", "SQL2012"); string databaseName = "Certit"; string snapshotDatabaseName = string.Empty; target.CreateSnapshot(connectionInfo, databaseName, snapshotDatabaseName); }