示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }