Ejemplo n.º 1
0
        public void TestTemplateBuilder_ReturnValidTemplate()
        {
            IStringTemplateBuilder builder  = new StringTemplateBuilder();
            IStringTemplate        template = builder
                                              .SetFormat(templateData)
                                              .AddParameter(templateVarName)
                                              .Build();

            IStringTemplateProcessor processor = new StringTemplateProcessor();
            var a = processor.Process(template, templateVarValue);

            var argB = template.CreateArgument(0, templateVarValue);
            var b    = processor.Process(template, argB);

            var argC = template.CreateArgument(templateVarName, templateVarValue);
            var c    = processor.Process(template, argC);

            var argD = template.CreateArgument(template.Parameters[0], templateVarValue);
            var d    = processor.Process(template, argD);

            Assert.AreEqual(expected_result, a);
            Assert.AreEqual(expected_result, b);
            Assert.AreEqual(expected_result, c);
            Assert.AreEqual(expected_result, d);
        }
Ejemplo n.º 2
0
        public void TestTemplateParser_MessyData_ReturnFixedTemplate()
        {
            IStringTemplateParser parser   = new StringTemplateParser();
            IStringTemplate       template = parser.Parse(messyTemplateData, StringTemplateParserOption.FixMalformedTemplate);

            Assert.AreEqual(templateData, template.Template);
            Assert.AreEqual(1, template.Parameters.Length);
            Assert.AreEqual(templateVarName, template.Parameters[0].Name);

            IStringTemplateProcessor processor = new StringTemplateProcessor();
            var a = processor.Process(template, templateVarValue);

            Assert.AreEqual(expected_result, a);
        }
Ejemplo n.º 3
0
        public void TestTemplateParser_ReturnValidTemplate()
        {
            IStringTemplateParser parser   = new StringTemplateParser();
            IStringTemplate       template = parser.Parse(templateData);

            Assert.AreEqual(templateData, template.Template);
            Assert.AreEqual(1, template.Parameters.Length);
            Assert.AreEqual(templateVarName, template.Parameters[0].Name);

            IStringTemplateProcessor processor = new StringTemplateProcessor();
            var a = processor.Process(template, templateVarValue);

            Assert.AreEqual(expected_result, a);
        }