public void DuringPasswordInteraction_ShowsRecipientsWithReplacedTokens() { var recipientToWithToken = "<username>@to.local"; var recipientCcWithToken = "<username>@cc.local"; var recipientBccWithToken = "<username>@bcc.local"; var expectedUserName = Environment.UserName; _profile.EmailSmtpSettings.Recipients = recipientToWithToken; _profile.EmailSmtpSettings.RecipientsCc = recipientCcWithToken; _profile.EmailSmtpSettings.RecipientsBcc = recipientBccWithToken; _tokenReplacer.AddStringToken("username", expectedUserName); //_interactionRequest.RegisterInteractionHandler<PasswordOverlayInteraction>(interaction => interaction.Result = PasswordResult.Cancel); PasswordOverlayInteraction interaction = null; _interactionInvoker.Invoke(Arg.Do <PasswordOverlayInteraction>(i => { interaction = i; i.Result = PasswordResult.Cancel; })); var assistant = BuildAssistant(); assistant.SendTestMail(_profile, _accounts); StringAssert.Contains(recipientToWithToken.Replace("<username>", expectedUserName), interaction.IntroText); StringAssert.Contains(recipientCcWithToken.Replace("<username>", expectedUserName), interaction.IntroText); StringAssert.Contains(recipientBccWithToken.Replace("<username>", expectedUserName), interaction.IntroText); }
public void Setup() { _smtpTestAccount = new SmtpAccount(); _smtpTestAccount.AccountId = "SmtpTestAccountId"; _profile = new ConversionProfile(); //Attention _profile.EmailSmtpSettings.AccountId = _smtpTestAccount.AccountId; //The AccountAssosiation is mocked below. The _smtpTestAccount is always used. _accounts = new Accounts(); _accounts.SmtpAccounts.Add(_smtpTestAccount); _interactionRequest = new UnitTestInteractionRequest(); _interactionInvoker = Substitute.For <IInteractionInvoker>(); _interactionInvoker.Invoke(Arg.Do <PasswordOverlayInteraction>(i => i.Result = PasswordResult.StorePassword)); _interactionRequest.RegisterInteractionHandler <PasswordOverlayInteraction>(interaction => interaction.Result = PasswordResult.StorePassword); _file = Substitute.For <IFile>(); _path = Substitute.For <IPath>(); _smtpAction = Substitute.For <ISmtpMailAction>(); _smtpAction.Check(Arg.Any <ConversionProfile>(), _accounts, Arg.Any <CheckLevel>()).Returns(x => new ActionResult()); _smtpAction.ProcessJob(Arg.Any <Job>()).Returns(x => new ActionResult()); //_smtpAction.GetSmtpAccount(_profile, _accounts).Returns(_smtpTestAccount); _mailSignatureHelper = Substitute.For <IMailSignatureHelper>(); _mailSignatureHelper.ComposeMailSignature().Returns(_mailSignature); _tokenReplacer = new TokenReplacer(); _tokenReplacerFactory = Substitute.For <ITokenReplacerFactory>(); _tokenReplacerFactory.BuildTokenReplacerWithOutputfiles(Arg.Any <Job>()).Returns(_tokenReplacer); _translation = new SmtpTranslation(); }
public void WhenPasswordInteractionIsCancelled_DoesNotSendMail() { //_interactionRequest.RegisterInteractionHandler<PasswordOverlayInteraction>(interaction => interaction.Result = PasswordResult.Cancel); _interactionInvoker.Invoke(Arg.Do <PasswordOverlayInteraction>(i => i.Result = PasswordResult.Cancel)); var assistant = BuildAssistant(); assistant.SendTestMail(_profile, _accounts); _smtpAction.DidNotReceive().ProcessJob(Arg.Any <Job>()); }