/// <summary> /// Send email to multiple receipts /// </summary> /// <param name="sender"></param> /// <param name="subject"></param> /// <param name="htmlMessage"></param> /// <param name="recipients"></param> /// <returns></returns> public Task SendBulkEmailAsync(string[] emails, string subject, string htmlMessage) { var client = new SmtpClient(host, port) { Credentials = new NetworkCredential(userName, password), EnableSsl = enableSSL }; MailMessage mailMessage = new MailMessage(); mailMessage.Body = htmlMessage; mailMessage.IsBodyHtml = true; mailMessage.Subject = subject; foreach (string emailAdress in emails) { if (DataValidationManager.CheckIsValiedEmailAddress(emailAdress)) { mailMessage.To.Add(emailAdress); } } return(client.SendMailAsync(mailMessage));; }
public void CheckAdress_WhenUserDataIsInvalid_ShouldReturnErrorWithMessage(string adress) { //Arrange (bool, string)expected = (false, UserMessages.InvalidAddressFormat); //Act var result = DataValidationManager.CheckAddress(adress); //Assert Assert.Equal(expected, result); }
public void CheckUserName_WhenUserDataIsInvalid_ShouldReturnErrorWithMessage(string sentence) { //Arrange (bool, string)expected = (false, UserMessages.InvalidFirstName); //Act var result = DataValidationManager.CheckFirstName(sentence); //Assert Assert.Equal(expected, result); }
public void CheckEmail_WhenUserEmailIsInvalid_ShouldReturnErrorWithMessage() { //Arrange (bool, string)expected = (false, UserMessages.InvalidEmailFormat); string email = "test%test.com"; //Act var result = DataValidationManager.CheckEmail(email); //Assert Assert.Equal(expected, result); }
public void CheckAdress_WhenUserDataIsCorrect_ShouldReturnCorrectResult() { //Arrange (bool, string)expected = (true, string.Empty); string adress = "Koktajlowo 16"; //Act var result = DataValidationManager.CheckAddress(adress); //Assert Assert.Equal(expected, result); }
public void CheckUserName_WhenUserDataCorrect_ShouldReturnCorrectResult() { //Arrange (bool, string)expected = (true, string.Empty); string userName = "******"; //Act var result = DataValidationManager.CheckFirstName(userName); //Assert Assert.Equal(expected, result); }
public void CheckEmail_WhenUserEmailIsCorrect_ShouldReturnCorrectResult() { //Arrange (bool, string)expected = (true, string.Empty); string email = "*****@*****.**"; //Act var result = DataValidationManager.CheckEmail(email); //Assert Assert.Equal(expected, result); }
private void Confirm_Click(object sender, EventArgs e) { List <(bool, string)> validators = new List <(bool, string)>() { DataValidationManager.CheckEmail(EmailTextBox.Text), DataValidationManager.CheckFirstName(FirstNameTextBox.Text), DataValidationManager.CheckLastName(LastNameTextBox.Text), DataValidationManager.CheckAddress(AddressTextBox.Text), }; foreach (var validator in validators) { if (!string.IsNullOrEmpty(validator.Item2)) { MessageBox.Show(validator.Item2, WindowsTypes.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); break; } } if (validators.TrueForAll(x => x.Item1)) { var emailBody = string.Format(emailBodyFormat, AddressTextBox.Text, FirstNameTextBox.Text, LastNameTextBox.Text, NotesTextBox.Text); EmailSendStatus emailSendStatus = new EmailManager().SendEmail(EmailTextBox.Text, "Pizza Application Order", emailBody); if (emailSendStatus.SendSuccessfully) { MessageBox.Show(UserMessages.EmailSended, WindowsTypes.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); AddHistoryRecordToDatabase(); UserActionHelpers.ClearAllTextBoxData(); Hide(); WindowsManagement.GetMainWindowInstance().Show(); } else { MessageBox.Show(UserMessages.EmailFailedToSend, WindowsTypes.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }