/// <summary> /// Adds a new/changed connection to the connection list /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddConnectionClick(object sender, RoutedEventArgs e) { ConnectionParameters conParams = new ConnectionParameters(DBTypeComboBox.Text, DBConnectionnameTextBox.Text, DBHostnameTextBox.Text, DBDatabaseTextBox.Text, DBUsernameTextBox.Text, DBPasswordPasswordBox.Password, DBPortTextBox.Text); if (conParams.IsComplete()) { if (DBConnectionHelpers.CheckIfDatabaseNameExists(conParams.Name)) { DBConnectionHelpers.AddDatabaseConnectionToConnectionList(conParams); } else { if (ModernDialog.ShowMessage("Connection Name \"" + conParams.Name + "\" already exists! \r\nDo you want to override the existing connection?", "New Connection", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { DBConnectionHelpers.RemoveConnectionParameter(conParams.Name); DBConnectionHelpers.AddDatabaseConnectionToConnectionList(conParams); } } } else { ModernDialog.ShowMessage("Please fill out all fields to add the new connection!", "New Connection", MessageBoxButton.OK); } ReloadListbox(); }
public void RemoveConnectionParameterTest() { DBConnectionHelpers.ConnectionParametersList = new List <ConnectionParameters>(); DBConnectionHelpers.AddDatabaseConnectionToConnectionList(ConParams); DBConnectionHelpers.RemoveConnectionParameter(ConParams.Name); Assert.IsFalse(DBConnectionHelpers.ConnectionParametersList.Contains(ConParams)); }