/// <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();
        }
        /// <summary>
        /// Add a new connection to the DatabaseSettings.xml and connect to the Database
        /// </summary>
        /// <author>Bernhard Bruns</author>
        private void SaveAndConnectClick(object sender, RoutedEventArgs e)
        {
            DBConnectionHelpers.LoadConnectionParameters();

            ConnectionParameters connectionParameters = new ConnectionParameters(DBTypeComboBox.Text, DBConnectionnameTextBox.Text, DBHostnameTextBox.Text, DBDatabaseTextBox.Text, DBUsernameTextBox.Text, DBPasswordTextBox.Password, DBPortTextBox.Text);

            if (connectionParameters.IsComplete())
            {
                if (DBConnectionHelpers.CheckIfDatabaseNameExists(connectionParameters.Name))
                {
                    DBConnectionHelpers.AddDatabaseConnectionToConnectionList(connectionParameters);

                    if (ConnectToDb(connectionParameters))
                    {
                        DBConnectionHelpers.SaveConnectionParameters();
                        DBConnectionHelpers.SaveLastUsedDatabase(connectionParameters);
                        AddConnectionGrid.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        ModernDialog.ShowMessage("Can't connect to database!", "New Connection", MessageBoxButton.OK);
                    }
                }
                else
                {
                    ModernDialog.ShowMessage("Connection Name \"" + connectionParameters.Name + "\" already exists! \r\nPlease choose a new Name for your connection.", "New Connection", MessageBoxButton.OK);
                }
            }
            else
            {
                ModernDialog.ShowMessage("Please fill out all fields to add the new connection!", "New Connection", MessageBoxButton.OK);
            }
        }
        public void AddDatabaseConnectionToConnectionListTest()
        {
            DBConnectionHelpers.ConnectionParametersList = new List <ConnectionParameters>();

            DBConnectionHelpers.AddDatabaseConnectionToConnectionList(ConParams);
            Assert.IsTrue(DBConnectionHelpers.ConnectionParametersList.Contains(ConParams));
        }
        public void RemoveConnectionParameterTest()
        {
            DBConnectionHelpers.ConnectionParametersList = new List <ConnectionParameters>();
            DBConnectionHelpers.AddDatabaseConnectionToConnectionList(ConParams);

            DBConnectionHelpers.RemoveConnectionParameter(ConParams.Name);
            Assert.IsFalse(DBConnectionHelpers.ConnectionParametersList.Contains(ConParams));
        }
        public void SaveConnectionParametersTest()
        {
            DBConnectionHelpers.ConnectionParametersList = new List <ConnectionParameters>();
            DBConnectionHelpers.AddDatabaseConnectionToConnectionList(ConParams);

            DBConnectionHelpers.SaveConnectionParameters();
            Assert.IsTrue(File.Exists(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\" + "DatabaseSettings.mpm"));
        }
        public void SaveLastUsedDatabaseTest()
        {
            DBConnectionHelpers.ConnectionParametersList = new List <ConnectionParameters>();
            DBConnectionHelpers.AddDatabaseConnectionToConnectionList(ConParams);

            DBConnectionHelpers.SaveLastUsedDatabase(ConParams);
            Assert.IsTrue(DBConnectionHelpers.ConnectionParametersList[0].IsLastUsedDatabase);

            ConnectionParameters c = new ConnectionParameters();

            DBConnectionHelpers.SaveLastUsedDatabase(c);
            Assert.IsTrue(DBConnectionHelpers.ConnectionParametersList[0].IsLastUsedDatabase == false);
        }