public void TestDirectoryVariableArgUnknownSubstitution() { var variable = new DirectoryVariable(); var template = variable.ToString("UNKNOWN"); var engine = new TemplateEngine(template); engine.AddVariable(variable); var dynCtx = new Dictionary <string, object>(); engine.ToString(dynCtx); }
public static TemplateEngine CreateTemplateEngine(string template) { var engine = new TemplateEngine(template); engine.AddVariable(new DateTimeVariable()); engine.AddVariable(new DirectoryVariable()); engine.AddVariable(new EnvironmentVariable()); engine.AddVariable(new GuidVariable()); engine.AddVariable(new LineFeedVariable()); engine.AddVariable(new SeparatorVariable()); engine.AddVariable(new SpaceVariable()); engine.AddVariable(new PlaceHolderVariable()); return(engine); }
public void TestDirectoryVariableArgCurrentAbsoluteSubstitution() { var variable = new DirectoryVariable(); var template = variable.ToString(DirectoryVariable.ArgCurrentAbsolute); var engine = new TemplateEngine(template); engine.AddVariable(variable); var currentDir = new DirectoryInfo(PathUtil.Combine("path", "to", "base", "down", "to", "current")); var dynCtx = new Dictionary <string, object>(); dynCtx[DirectoryVariable.ContextCurrentDir] = currentDir; var str = engine.ToString(dynCtx); Console.WriteLine(string.Format("SUBSTITUTED STRING: '{0}'", str)); Assert.AreEqual(currentDir.FullName, str); }
public void TestPlaceHolderVariableArgNameSubstitution() { var variable = new PlaceHolderVariable(); var template = variable.ToString(PlaceHolderVariable.ArgName); var engine = new TemplateEngine(template); engine.AddVariable(variable); var placeHolderFile = new FileInfo(PathUtil.Combine("path", "to", "placeholder", ".emptydir")); var dynCtx = new Dictionary <string, object>(); dynCtx[PlaceHolderVariable.ContextPlaceHolderFile] = placeHolderFile; var str = engine.ToString(dynCtx); Console.WriteLine(string.Format("SUBSTITUTED STRING: '{0}'", str)); Assert.AreEqual(placeHolderFile.Name, str); }