public static DialogResult ShowDialog(IWin32Window parent, ref string server, ref string username, ref string password) { CredentialsDialog frmInit = new CredentialsDialog { txtDbServer = { Text = server != string.Empty ? server : "localhost" }, txtUsername = { Text = username }, txtPassword = { Text = password } }; DialogResult result = frmInit.ShowDialog(parent); if (result == DialogResult.OK) { username = frmInit.txtUsername.Text; password = frmInit.txtPassword.Text; server = frmInit.txtDbServer.Text; } return(result); }
public override void Start() { #region Create Database string server = "localhost"; string username = "******"; string password = string.Empty; if (CredentialsDialog.ShowDialog(null, ref server, ref username, ref password) != DialogResult.OK) { Console.WriteLine("The test was aborted by the user!"); throw new Exception("Test aborted by user"); } connectionString = GetConnectionString(server, username, password); List <string> createScripts = new List <string>(); List <string> integrityScripts = new List <string>(); foreach (string t in ArtefactNamespaces) { createScripts.Add(string.Concat(t, ".", CreateScriptName)); integrityScripts.Add(string.Concat(t, ".", IntegrityScriptName)); } DatabaseCreator.BuildEmptyDatabase(connectionString, true, DatabaseName, createScripts, integrityScripts, Assembly.GetAssembly(typeof(Company))); #endregion #region Initialize NHibernate Configuration configuration = new Configuration(); configuration.AddAssembly(typeof(Company).Assembly); configuration.Properties["connection.connection_string"] = "Database=" + DatabaseName + ";" + connectionString; sessionFactory = configuration.BuildSessionFactory(); #endregion CreateData(); }