Exemplo n.º 1
0
        public void TestEnvironmentVariableSubstitution()
        {
            #region SetUp
            // Create environment variable.
            var envVarName  = "TMP_ENV_VAR_NAME";
            var envVarValue = "dummy-value";
            Environment.SetEnvironmentVariable(envVarName, envVarValue);
            #endregion

            var variable = new EnvironmentVariable();
            var template = variable.ToString(envVarName);

            var engine = new TemplateEngine(template);
            engine.AddVariable(variable);

            var str = engine.ToString();
            Console.WriteLine(string.Format("SUBSTITUTED STRING: '{0}'", str));

            #region CleanUp
            // Delete environment variable.
            Environment.SetEnvironmentVariable(envVarName, null);
            #endregion

            Assert.AreEqual(envVarValue, str);
        }
Exemplo n.º 2
0
        public void TestSeparatorVariableArgUnknownSubstitution()
        {
            var variable = new SeparatorVariable();
            var template = variable.ToString("UNKNOWN");

            var engine = new TemplateEngine(template);

            engine.AddVariable(variable);

            engine.ToString();
        }
Exemplo n.º 3
0
        public void TestLineFeedVariableSubstitution()
        {
            var variable = new LineFeedVariable();
            var template = variable.ToString(null);

            var engine = new TemplateEngine(template);

            engine.AddVariable(variable);

            var str = engine.ToString();

            Console.WriteLine(string.Format("SUBSTITUTED STRING: '{0}'", str));

            Assert.AreEqual("\n", str);
        }
Exemplo n.º 4
0
        public void TestDateTimeVariableSubstitution()
        {
            var variable = new DateTimeVariable();
            var template = variable.ToString(null);

            var engine = new TemplateEngine(template);

            engine.AddVariable(variable);

            var str = engine.ToString();

            Console.WriteLine(string.Format("SUBSTITUTED STRING: '{0}'", str));

            DateTime.Parse(str);
        }
Exemplo n.º 5
0
        public void TestSeparatorVariableArgVolumeSubstitution()
        {
            var variable = new SeparatorVariable();
            var template = variable.ToString(SeparatorVariable.ArgVolume);

            var engine = new TemplateEngine(template);

            engine.AddVariable(variable);

            var str = engine.ToString();

            Console.WriteLine(string.Format("SUBSTITUTED STRING: '{0}'", str));

            Assert.AreEqual(Path.VolumeSeparatorChar.ToString(), str);
        }
Exemplo n.º 6
0
        public void TestSpaceVariableWithArgSubstitution()
        {
            var variable = new SpaceVariable();
            int count    = 3;
            var template = variable.ToString(count.ToString());

            var engine = new TemplateEngine(template);

            engine.AddVariable(variable);

            var str = engine.ToString();

            Console.WriteLine(string.Format("SUBSTITUTED STRING: '{0}'", str));

            Assert.AreEqual(new string(' ', count), str);
        }