public void SmtpSettings_AutoSave_MultipleErrors() { _profile.EmailSmtpSettings.Enabled = true; _profile.EmailSmtpSettings.Ssl = false; _profile.EmailSmtpSettings.Subject = ""; _profile.EmailSmtpSettings.Content = ""; _profile.EmailSmtpSettings.AddSignature = false; _profile.EmailSmtpSettings.Address = ""; _profile.EmailSmtpSettings.UserName = ""; _profile.EmailSmtpSettings.Server = ""; _profile.EmailSmtpSettings.Port = -1; _profile.EmailSmtpSettings.Recipients = ""; SetValidAutoSaveSettings(); _profile.EmailSmtpSettings.Password = ""; var result = _smtpAction.Check(_profile, new Accounts()); Assert.Contains(ErrorCode.Smtp_NoEmailAddress, result, "ProfileCheck did not detect missing SMTP adress."); result.Remove(ErrorCode.Smtp_NoEmailAddress); Assert.Contains(ErrorCode.Smtp_NoUserSpecified, result, "ProfileCheck did not detect missing SMTP username."); result.Remove(ErrorCode.Smtp_NoUserSpecified); Assert.Contains(ErrorCode.Smtp_NoServerSpecified, result, "ProfileCheck did not detect missing SMTP host."); result.Remove(ErrorCode.Smtp_NoServerSpecified); Assert.Contains(ErrorCode.Smtp_InvalidPort, result, "ProfileCheck did not detect invalid SMTP port."); result.Remove(ErrorCode.Smtp_InvalidPort); Assert.Contains(ErrorCode.Smtp_NoRecipients, result, "ProfileCheck did not detect missing SMTP recipients."); result.Remove(ErrorCode.Smtp_NoRecipients); Assert.Contains(ErrorCode.Smtp_NoPasswordSpecified, result, "ProfileCheck did not detect missing SMTP password for autosaving."); result.Remove(ErrorCode.Smtp_NoPasswordSpecified); Assert.IsTrue(result, "Unexpected errorcodes:" + Environment.NewLine + result); }
public static ActionResult ProfileCheck(ConversionProfile profile) { var actionResult = new ActionResult(); actionResult.AddRange(CheckAutosaveSettings(profile)); actionResult.AddRange(CheckSaveSettings(profile)); actionResult.AddRange(CheckCoverPageSettings(profile)); actionResult.AddRange(CheckAttachmentPageSettings(profile)); actionResult.AddRange(CheckStampingSettings(profile)); actionResult.AddRange(CheckEncryptionSettings(profile)); actionResult.AddRange(CheckBackgroundpageSettings(profile)); actionResult.AddRange(CheckSignatureSettings(profile)); var ftpAction = new FtpAction(); actionResult.AddRange(ftpAction.Check(profile)); var scriptAction = new ScriptAction(); actionResult.AddRange(scriptAction.Check(profile)); var smtpMailAction = new SmtpMailAction(""); actionResult.AddRange(smtpMailAction.Check(profile)); return(actionResult); }
public void Check_ValidSettings_ReturnsTrue() { _profile.AutoSave.Enabled = false; var result = _smtpAction.Check(_profile, _accounts, CheckLevel.Profile); Assert.IsTrue(result, "Unexpected errorcodes: " + result); }
public void Check_NoAccount_ResultContainsAssociatedCode() { _profile.EmailSmtpSettings.AccountId = "Some unavailable Account ID"; var results = _smtpAction.Check(_profile, _accounts); Assert.AreEqual(ErrorCode.Smtp_NoAccount, results[0]); }
private void SendTestMailButton_OnClick(object sender, RoutedEventArgs e) { var smtpMailAction = new SmtpMailAction(MailSignatureHelper.ComposeMailSignature(CurrentProfile.EmailSmtp)); var currentProfile = ((ActionsTabViewModel)DataContext).CurrentProfile.Copy(); #region check profile var result = smtpMailAction.Check(currentProfile); if (!result.Success) { var caption = TranslationHelper.Instance.TranslatorInstance.GetTranslation("SmtpEmailActionSettings", "SendTestMail", "Send test mail"); var message = ErrorCodeInterpreter.GetFirstErrorText(result, true); MessageWindow.ShowTopMost(message, caption, MessageWindowButtons.OK, MessageWindowIcon.Error); return; } #endregion #region create job string tempFolder = Path.GetTempPath(); string tmpTestFolder = Path.Combine(tempFolder, "PdfCreatorTest\\SendSmtpTestmail"); Directory.CreateDirectory(tmpTestFolder); string tmpInfFile = Path.Combine(tmpTestFolder, "SmtpTest.inf"); var sb = new StringBuilder(); sb.AppendLine("[1]"); sb.AppendLine("SessionId=1"); sb.AppendLine("WinStation=Console"); sb.AppendLine("UserName=SampleUser1234"); sb.AppendLine("ClientComputer=\\PC1"); sb.AppendLine("PrinterName=PDFCreator"); sb.AppendLine("JobId=1"); sb.AppendLine("DocumentTitle=SmtpTest"); sb.AppendLine(""); File.WriteAllText(tmpInfFile, sb.ToString(), Encoding.GetEncoding("Unicode")); JobTranslations jobTranslations = new JobTranslations(); jobTranslations.EmailSignature = MailSignatureHelper.ComposeMailSignature(true); var tempFolderProvider = new StaticTempFolderProvider(Path.Combine(Path.GetTempPath(), "PDFCreator")); var job = new GhostscriptJob(new JobInfo(tmpInfFile), new ConversionProfile(), tempFolderProvider, jobTranslations); job.Profile = currentProfile; #endregion #region add password if (string.IsNullOrEmpty(Password)) { var pwWindow = new SmtpPasswordWindow(SmtpPasswordMiddleButton.None, currentProfile.EmailSmtp.Address, currentProfile.EmailSmtp.Recipients); if (pwWindow.ShowDialogTopMost() != SmtpPasswordResponse.OK) { Directory.Delete(tmpTestFolder, true); return; } job.Passwords.SmtpPassword = pwWindow.SmtpPassword; } else { job.Passwords.SmtpPassword = Password; } #endregion #region add testfile string testFile = (Path.Combine(tmpTestFolder, "testfile.txt")); File.WriteAllText(testFile, @"PDFCreator", Encoding.GetEncoding("Unicode")); job.OutputFiles.Add(testFile); #endregion LogManager.GetCurrentClassLogger().Info("Send test mail over smtp."); result = smtpMailAction.ProcessJob(job); Directory.Delete(tmpTestFolder, true); if (!result.Success) { var caption = TranslationHelper.Instance.TranslatorInstance.GetTranslation("SmtpEmailActionSettings", "SendTestMail", "Send test mail"); var message = ErrorCodeInterpreter.GetFirstErrorText(result, true); MessageWindow.ShowTopMost(message, caption, MessageWindowButtons.OK, MessageWindowIcon.Error); } else { var caption = TranslationHelper.Instance.TranslatorInstance.GetTranslation("SmtpEmailActionSettings", "SendTestMail", "Send test mail"); var message = TranslationHelper.Instance.TranslatorInstance.GetFormattedTranslation("SmtpEmailActionSettings", "TestMailSent", "Test mail sent to {0}.", job.Profile.EmailSmtp.Recipients); MessageWindow.ShowTopMost(message, caption, MessageWindowButtons.OK, MessageWindowIcon.Info); } }