diff options
Diffstat (limited to 'main/src/addins/TextTemplating/Mono.TextTemplating.Tests')
-rw-r--r-- | main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TemplateEnginePreprocessTemplateTests.cs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TemplateEnginePreprocessTemplateTests.cs b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TemplateEnginePreprocessTemplateTests.cs index 824a06ed1a..c904caacf7 100644 --- a/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TemplateEnginePreprocessTemplateTests.cs +++ b/main/src/addins/TextTemplating/Mono.TextTemplating.Tests/TemplateEnginePreprocessTemplateTests.cs @@ -60,6 +60,16 @@ namespace Mono.TextTemplating.Tests Assert.AreEqual (expectedOutput, output, output); } + + [Test] + public void CaptureEncodingAndExtension () + { + string input = InputTemplate_CaptureEncodingAndExtension; + string output = Preprocess (input); + string expectedOutput = TemplatingEngineHelper.CleanCodeDom (Output_CaptureEncodingAndExtension, "\n"); + + Assert.AreEqual (expectedOutput, output, output); + } #region Helpers @@ -145,6 +155,12 @@ Included Method Body Text Block #> "; + public static string InputTemplate_CaptureEncodingAndExtension = + @" +<#@ template debug=""false"" language=""C#"" inherits=""Foo"" hostspecific=""trueFromBase"" #> +<#@ output extension="".cs"" encoding=""utf-8"" #> +"; + #endregion #region Expected output strings @@ -589,6 +605,34 @@ namespace Templating { } } "; + + public static string Output_CaptureEncodingAndExtension = + + @"namespace Templating { + + + public partial class PreprocessedTemplate : Foo { + + public override string TransformText() { + this.GenerationEnvironment = null; + + #line 1 """" + this.Write(""\n""); + + #line default + #line hidden + return this.GenerationEnvironment.ToString(); + } + + protected override void Initialize() { + if ((this.Host != null)) { + this.Host.SetFileExtension("".cs""); + this.Host.SetOutputEncoding(System.Text.Encoding.GetEncoding(65001, true)); + } + base.Initialize(); + } + } +}"; #endregion } } |