public void SetUp() { _tokenReplacerFactory = Substitute.For <ITokenReplacerFactory>(); _tokenReplacer = new TokenReplacer(); _tokenReplacer.AddStringToken("author", AuthorTokenValue); _tokenReplacer.AddStringToken("title", TitleTokenValue); _tokenReplacerFactory.BuildTokenReplacerWithoutOutputfiles(Arg.Any <Job>()).Returns(_tokenReplacer); _pageNumberCalculator = Substitute.For <IPageNumberCalculator>(); _userTokenExtractor = Substitute.For <IUserTokenExtractor>(); _jobDataUpdater = new JobDataUpdater(_tokenReplacerFactory, _pageNumberCalculator, _userTokenExtractor); var jobInfo = new JobInfo(); jobInfo.Metadata = new Metadata(); jobInfo.Metadata.Author = "<author>"; jobInfo.Metadata.Title = "<title>"; jobInfo.Metadata.Subject = "Test Subject"; jobInfo.Metadata.Keywords = "Test Keywords"; var sfi1 = new SourceFileInfo(); sfi1.Filename = PSFile1; jobInfo.SourceFiles.Add(sfi1); var sfi2 = new SourceFileInfo(); sfi2.Filename = PSFile2; jobInfo.SourceFiles.Add(sfi2); var profile = new ConversionProfile(); _job = new Job(jobInfo, profile, new Accounts()); _userTokenExtractor.ExtractUserTokenFromPsFile(PSFile1, _job.Profile.UserTokens.Seperator).Returns(_userToken1); _userTokenExtractor.ExtractUserTokenFromPsFile(PSFile2, _job.Profile.UserTokens.Seperator).Returns(_userToken2); }
public void EmailClientAction_BodyWithToken_MailContainsReplacedBody() { var action = BuildAction(); _profile.EmailClientSettings.Content = "some content \r\nwith line breaks <foo>"; _tokenReplacer.AddStringToken("foo", "bar"); action.ProcessJob(_job); Assert.AreEqual(_mockMailClient.Mails[0].Body, "some content \r\nwith line breaks bar"); }
public void EmailClientAction_SubjectWithToken_MailContainsReplacedSubject() { var action = new EMailClientAction(_emailClientFactory, SignatureText); _profile.EmailClient.Subject = "my subject <foo>"; _tokenReplacer.AddStringToken("foo", "bar"); action.ProcessJob(_job); Assert.AreEqual(_mockMailClient.Mails[0].Subject, "my subject bar"); }
private void AddAuthorAndTitleTokens(Metadata metadata) { var author = _tokenReplacer.ReplaceTokens(metadata.Author); var title = _tokenReplacer.ReplaceTokens(metadata.Title); _tokenReplacer.AddStringToken("Author", author); _tokenReplacer.AddStringToken("Title", title); }
public void SetUp() { var fixture = new Fixture(); _userName = fixture.Create <string>(); _smtpPassword = fixture.Create <string>(); _mailSignatureHelper = Substitute.For <IMailSignatureHelper>(); _mailSignatureHelper.ComposeMailSignature().Returns(""); var bootstrapper = new IntegrationTestBootstrapper(); var container = bootstrapper.ConfigureContainer(); _th = container.GetInstance <TestHelper>(); _th.InitTempFolder("SmtpEmailTest"); _tokenReplacer = new TokenReplacer(); _tokenReplacer.AddStringToken("ReplaceThis", "Replaced"); var serverIp = IPAddress.Loopback; _smtpPort = FindFreeTcpPort(); _mailServer = serverIp.ToString(); _smtpServer = new SmtpServerForUnitTest(serverIp, _smtpPort, new[] { new NetworkCredential(_userName, _smtpPassword) }); _smtpServer.Start(); }
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 TokenReplacerWithSingleStringToken_GetToken_ReturnsStringToken() { var tr = new TokenReplacer(); tr.AddStringToken("testName", "testValue"); Assert.IsTrue(tr.GetToken("testName") is StringToken); }
public DesignTimeEditEmailTextWindowViewModel() : base(new TranslationProxy()) { var interaction = new EditEmailTextInteraction("This is the mail subject <Counter>", "This is my content <Counter>", true); TokenReplacer = new TokenReplacer(); TokenReplacer.AddStringToken("Counter", "123"); SetInteraction(interaction); }
public DesignTimeEditEmailTextWindowViewModel() : base(new EditEmailTextWindowTranslation(), new MailSignatureHelperFreeVersion(new MailSignatureHelperTranslation()), new TokenHelper(new TokenPlaceHoldersTranslation())) { var interaction = new EditEmailTextInteraction("This is the mail subject <Counter>", "This is my content <Counter>", true, true); TokenReplacer = new TokenReplacer(); TokenReplacer.AddStringToken("Counter", "123"); SetInteraction(interaction); }
public void ComposeScriptPath_WithoutTokens_ConcatenatesParamsAndFiles() { var tokenReplacer = new TokenReplacer(); tokenReplacer.AddStringToken("foo", "bar"); var result = ScriptAction.ComposeScriptParameters("--myparam", new[] { @"C:\file1.pdf" }, tokenReplacer); Assert.AreEqual("--myparam \"C:\\file1.pdf\"", result); }
public void ComposeScriptPath_WithTokenReplacer_ReplacesTokens() { var tokenReplacer = new TokenReplacer(); tokenReplacer.AddStringToken("foo", "bar"); var result = ScriptAction.ComposeScriptPath(@"C:\Test\<foo>", tokenReplacer); Assert.AreEqual(@"C:\Test\bar", result); }
public void ComposeScriptPath_WithTokensInParams_ReplacesTokens() { var tokenReplacer = new TokenReplacer(); tokenReplacer.AddStringToken("foo", "bar"); var result = ScriptAction.ComposeScriptParameters("--myparam <foo>", new[] { @"C:\file1.pdf" }, tokenReplacer); Assert.AreEqual("--myparam bar \"C:\\file1.pdf\"", result); }
public void ApplyTokens_ReplacesTokensInSharedFolder() { var token = "<Token>"; var tokenKey = "Token"; var tokenValue = "TokenValue"; var tokenReplacer = new TokenReplacer(); tokenReplacer.AddStringToken(tokenKey, tokenValue); _profile.DropboxSettings.SharedFolder = token; var job = new Job(null, _profile, null, _accounts); job.TokenReplacer = tokenReplacer; _dropboxAction.ApplyPreSpecifiedTokens(job); Assert.AreEqual(tokenValue, _profile.DropboxSettings.SharedFolder); }
public void ApplyTokens_RepalcesTokensInFtpDirectoryAndMakesItValid() { var token = "<Token>"; var tokenKey = "Token"; var tokenValue = "TokenValue"; var tokenReplacer = new TokenReplacer(); tokenReplacer.AddStringToken(tokenKey, tokenValue); _profile.Ftp.Directory = token + "?*"; var job = new Job(null, _profile, _accounts); job.TokenReplacer = tokenReplacer; _ftpAction.ApplyPreSpecifiedTokens(job); Assert.AreEqual(tokenValue + "_", _profile.Ftp.Directory); }
public void Build_WithTokenReplacer_UsesTokenReplacerPreview() { var token = "token1"; var tokenValue = "token-value-1"; var tokenList = new[] { "<token1>", "<token2>" }; var tokenReplacer = new TokenReplacer(); tokenReplacer.AddStringToken(token, tokenValue); _currentValue.PropertyOne = "<" + token + ">"; var vm = _builder .WithSelector(p => p.PropertyOne) .WithTokenReplacerPreview(tokenReplacer) .WithTokenList(tokenList) .Build(); Assert.AreEqual(tokenValue, vm.Preview); }
public void ApplyTokens_ReplacesTokensForAllRecipientsAndSwitchesSemiColonTo() { var token = "<Token>"; var tokenKey = "Token"; var tokenValue = "TokenValue"; var tokenReplacer = new TokenReplacer(); tokenReplacer.AddStringToken(tokenKey, tokenValue); var givenRecipients = $"{token};{token}, {token}"; var expectedRecipients = $"{tokenValue},{tokenValue}, {tokenValue}"; _profile.EmailSmtpSettings.Recipients = givenRecipients; _profile.EmailSmtpSettings.RecipientsCc = givenRecipients; _profile.EmailSmtpSettings.RecipientsBcc = givenRecipients; var job = new Job(null, _profile, _accounts); job.TokenReplacer = tokenReplacer; _smtpAction.ApplyPreSpecifiedTokens(job); Assert.AreEqual(expectedRecipients, _profile.EmailSmtpSettings.Recipients, "Recipients"); Assert.AreEqual(expectedRecipients, _profile.EmailSmtpSettings.RecipientsCc, "RecipientsCc"); Assert.AreEqual(expectedRecipients, _profile.EmailSmtpSettings.RecipientsBcc, "RecipientsBcc"); }
public TokenReplacer BuildTokenReplacerWithOutputfiles(Job job) { BuildTokenReplacerWithoutOutputfiles(job); var outputFilenames = job.OutputFiles.Select(outputFile => _pathWrap.GetFileName(outputFile)).ToList(); _tokenReplacer.AddListToken("OutputFilenames", outputFilenames); _tokenReplacer.AddStringToken("OutputFilePath", _pathWrap.GetFullPath(job.OutputFiles.First())); return(_tokenReplacer); }
public void TokenReplacer_AddStringToken_ContainsStringToken() { var tr = new TokenReplacer(); tr.AddStringToken("testName", "testValue"); }