public void ComposeScriptPath_WithUnkownToken_ReturnsValidFilename() { var tokenReplacer = new TokenReplacer(); var result = ScriptAction.ComposeScriptPath(@"C:\Test\<unknown>", tokenReplacer); Assert.AreEqual(@"C:\Test\_unknown_", 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 ComposeScript_PathGetFullPathThrowsExpection_DoNotThrowExcpetion_PathRemains() { _path.GetFullPath(Arg.Any <string>()).Throws(new Exception()); var path = "inputPATH"; Assert.DoesNotThrow(() => { path = _scriptAction.ComposeScriptPath(path, new TokenReplacer()); }); Assert.AreEqual("inputPATH", path, "Path did not remain"); }
private string ComposeSampleCommand(string scriptPath, string additionalParams) { if ((string.IsNullOrEmpty(scriptPath)) || (scriptPath.Trim().Length == 0)) { return(""); } //TokenReplacer tokenReplacer = TokenHelper.TokenReplacerWithPlaceHolders; string scriptCall = Path.GetFileName(ScriptAction.ComposeScriptPath(scriptPath, _tokenReplacer)); if (!string.IsNullOrEmpty(additionalParams)) { scriptCall += " " + ScriptAction.ComposeScriptParameters(additionalParams, new[] { @"C:\File1.pdf", @"C:\File2.pdf" }, _tokenReplacer); } else { scriptCall += @" C:\File1.pdf C:\File2.pdf"; } return(scriptCall); }