コード例 #1
0
        public void CaptureEncodingAndExtension()
        {
            string input          = InputTemplate_CaptureEncodingAndExtension;
            string output         = Preprocess(input);
            string expectedOutput = TemplatingEngineHelper.CleanCodeDom(Output_CaptureEncodingAndExtension.Replace("\\n", Environment.NewLine.Replace("\r", "\\r").Replace("\n", "\\n")), "\n");

            Assert.AreEqual(expectedOutput, output, output);
        }
コード例 #2
0
        public void Preprocess_ControlBlockAfterIncludedTemplateWithClassFeatureBlock_ReturnsValidCSharpOutput()
        {
            string    input = InputTemplate_ControlBlockAfterIncludedTemplateWithClassFeatureBlock;
            DummyHost host  = CreateDummyHostForControlBlockAfterIncludedTemplateWithClassFeatureBlockTest();

            string expectedOutput = TemplatingEngineHelper.CleanCodeDom(Output_ControlBlockAfterIncludedTemplateWithClassFeatureBlock.Replace("\\n", Environment.NewLine.Replace("\r", "\\r").Replace("\n", "\\n")), "\n");
            string output         = Preprocess(input, host);

            Assert.AreEqual(expectedOutput, output, output);
        }
コード例 #3
0
        public void Preprocess()
        {
            string input =
                "<#@ template language=\"C#\" #>\r\n" +
                "Test\r\n";

            string expectedOutput = TemplatingEngineHelper.CleanCodeDom(OutputSample1, "\n");
            string output         = Preprocess(input);

            Assert.AreEqual(expectedOutput, output);
        }
コード例 #4
0
ファイル: GenerationTests.cs プロジェクト: bittercoder/t5
        //NOTE: we set the newline property on the code generator so that the whole files has matching newlines,
        // in order to match the newlines in the verbatim code blocks
        void Generate(string input, string expectedOutput, string newline)
        {
            DummyHost host      = new DummyHost();
            string    className = "GeneratedTextTransformation4f504ca0";
            string    code      = GenerateCode(host, input, className, newline);

            Assert.AreEqual(0, host.Errors.Count);

            var generated = TemplatingEngineHelper.CleanCodeDom(code, newline);

            expectedOutput = TemplatingEngineHelper.CleanCodeDom(expectedOutput, newline);
            Assert.AreEqual(expectedOutput, generated);
        }
コード例 #5
0
        string Preprocess(string input, DummyHost host)
        {
            string className      = "PreprocessedTemplate";
            string classNamespace = "Templating";
            string language       = null;

            string[] references = null;

            TemplatingEngine engine = new TemplatingEngine();
            string           output = engine.PreprocessTemplate(input, host, className, classNamespace, out language, out references);

            ReportErrors(host.Errors);
            if (output != null)
            {
                return(TemplatingEngineHelper.CleanCodeDom(output, "\n"));
            }
            return(null);
        }