title: Calling function inside a button for unit test
body: <pre><code>private void btnSave_Click(object sender, EventArgs e)
      {
          if(txtFirstName.Text.Trim() != "" &amp;&amp; txtLastName.Text.Trim() != "" &amp;&amp; txtContact.Text.Trim() != "")
          {
              Regex reg = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"); //only accepting proper email
              Match match = reg.Match(txtEmail.Text.Trim());
              if (match.Success)
              { using (SqlConnection sqlCon = new SqlConnection(connectionString)) // connecting info to database
                  {
                      sqlCon.Open();
                      SqlCommand sqlCmd = new SqlCommand("ContactAddorEdit", sqlCon);
                      sqlCmd.CommandType = CommandType.StoredProcedure;
                      sqlCmd.Parameters.AddWithValue("@PhoneBookID", PhoneBookID); //connecting each value to database
                      sqlCmd.Parameters.AddWithValue("@FirstName", txtFirstName.Text.Trim());
                      sqlCmd.Parameters.AddWithValue("@LastName", txtLastName.Text.Trim());
                      sqlCmd.Parameters.AddWithValue("@Contact", txtContact.Text.Trim());
                      sqlCmd.Parameters.AddWithValue("@Email", txtEmail.Text.Trim());
                      sqlCmd.Parameters.AddWithValue("@Address", txtAddress.Text.Trim());
                      sqlCmd.ExecuteNonQuery(); // executeing the query in database
                      MessageBox.Show("Submitted successfully"); // showing message when success
                      Clear(); // clearing the form
                      GridFill();// refreshing the table
                  }
              }
              else
              {
                  MessageBox.Show(" Please enter a valid Email"); // Showing MEssage when email is not valid
              }
          }
          else
          {
              MessageBox.Show("Please fill Mandatory fields"); // if no input this message will show
          }
  </code></pre>
  
  <p>These codes are under a "save" button in a form and i wanted to call them in the unit test class in order to test them out. Any idea what should i do? Thank you</p>