public async Task HostSpecificStringParameterWithSpecificHostType() { string template = @"<#@ template language=""C#"" hostspecific=""true"" #> <#@ parameter name=""TestParam"" type=""string"" #> Hello <#=TestParam#>!"; var gen = new CustomHostWithSpecificHostType(); gen.AddParameter(null, null, "TestParam", "World"); var outFilename = "test.txt"; var result = await gen.ProcessTemplateAsync("test.tt", template, outFilename); Assert.True(result.success); Assert.Equal("Hello World!", result.content); }
public void HostSpecificStringParameterWithSpecificHostType() { string template = @"<#@ template language=""C#"" hostspecific=""true"" #> <#@ parameter name=""TestParam"" type=""string"" #> Hello <#=TestParam#>!"; var gen = new CustomHostWithSpecificHostType(); gen.AddParameter(null, null, "TestParam", "World"); var outFilename = "test.txt"; var success = gen.ProcessTemplate("test.tt", template, ref outFilename, out var outContent); Assert.True(success); Assert.AreEqual("Hello World!", outContent); }
public async Task TestCustomHostWithSpecificHostType() { var gen = new CustomHostWithSpecificHostType { TestProperty = 3 }; gen.Refs.Add(typeof(CustomHostWithSpecificHostType).Assembly.Location); gen.Imports.Add("Mono.TextTemplating.Tests"); var outFilename = "test.txt"; var result = await gen.ProcessTemplateAsync( "test.tt", "<#@ template hostspecific=\"true\" #><#= Host.TestProperty * 5 #>", outFilename ); Assert.True(result.success); Assert.Equal("15", result.content); }
public void TestCustomHostWithSpecificHostType() { var gen = new CustomHostWithSpecificHostType { TestProperty = 3 }; gen.Refs.Add(typeof(CustomHostWithSpecificHostType).Assembly.Location); gen.Imports.Add("Mono.TextTemplating.Tests"); var outFilename = "test.txt"; var success = gen.ProcessTemplate( "test.tt", "<#@ template hostspecific=\"true\" #><#= Host.TestProperty * 5 #>", ref outFilename, out var outContent ); Assert.True(success); Assert.AreEqual("15", outContent); }