/// <summary> /// Confirms contents of email and email password boxes and encrypts/writes contents to JSON object using <see cref="NewEmail(string, string)"/> if valid. /// </summary> private void btnSubmitEmail_click(object sender, RoutedEventArgs e) { //Initialize helper class rcHelper rc = new rcHelper(); try { //Initialize all variables from email and ePass fields. #region variable_Initialization //Initialize email and password variables string email = null; string ePass = null; //Check for valid input in txtEmail textbox if (txtEmail.Text != null && rc.IsEmailValid(txtEmail.Text) == true) { email = txtEmail.Text; } //If invalid, display error & return else { MessageBox.Show("Please enter a valid email address"); return; } //Ensure password exists if (pwdEmail.Password.Count() > 0) { ePass = pwdEmail.Password; } //If null or empty, display error & return else { MessageBox.Show("Please input your email password."); return; } #endregion //Tests email credentials & writes them to JSON object if valid. if (email != null && ePass != null) { bool eLog = rc.NewEmail(email, ePass); if (eLog == false) { MessageBox.Show("Your email address or password was incorrect."); return; } MessageBox.Show("Email credentials accepted & saved"); if (rc.ApplicationReady() == true) { MessageBox.Show("You may now run RedditCrawler!"); } } } //Generic exception handling catch (Exception ex) { rc.DebugLog(ex); } }
public void TestInvalidEmailFormat() { rcHelper rc = new rcHelper(); string email = "cd2"; bool b = rc.IsEmailValid(email); Assert.AreEqual(b, false); }
public void TestValidEmailFormat() { rcHelper rc = new rcHelper(); string email = "*****@*****.**"; bool b = rc.IsEmailValid(email); Assert.AreEqual(b, true); }