Ejemplo n.º 1
0
        public static void ExpandVariables_5()
        {
            EngineState s = EngineTests.CreateEngineState();

            EngineTests.PushDepthInfo(s, 2);

            s.Variables.SetValue(VarsType.Local, "B", "C#");
            s.CurSectionInParams[2] = "WPF";

            string[] srcs =
            {
                "A_%A%",
                "B_%B%",
                "C_#1",
                "D_#2"
            };
            List <string> dests = StringEscaper.ExpandVariables(s, srcs);

            string[] comps =
            {
                "A_#$pA#$p",
                "B_C#",
                "C_",
                "D_WPF"
            };

            for (int i = 0; i < dests.Count; i++)
            {
                Assert.IsTrue(dests[i].Equals(comps[i], StringComparison.Ordinal));
            }
        }
Ejemplo n.º 2
0
        public void ExpandVariables_3()
        {
            EngineState s = EngineTests.CreateEngineState();

            s.Variables.SetValue(VarsType.Local, "A", "Hello");

            const string src  = "%A% #1";
            string       dest = StringEscaper.ExpandVariables(s, src);
            const string comp = "Hello ##1";

            Assert.IsTrue(dest.Equals(comp, StringComparison.Ordinal));
        }
Ejemplo n.º 3
0
        public static void ExpandVariables_2()
        {
            EngineState s = EngineTests.CreateEngineState();

            s.CurSectionInParams[1] = "World";

            const string src  = "%A% #1";
            string       dest = StringEscaper.ExpandVariables(s, src);
            const string comp = "#$pA#$p World";

            Assert.IsTrue(dest.Equals(comp, StringComparison.Ordinal));
        }
Ejemplo n.º 4
0
        public void ExpandSectionParams_6()
        {
            EngineState s = EngineTests.CreateEngineState();

            s.CurDepth = 2;
            s.Variables.SetValue(VarsType.Local, "A", "Hello");
            Variables.SetVariable(s, "#1", "#2");
            Variables.SetVariable(s, "#2", "#3");
            Variables.SetVariable(s, "#3", "#1");

            const string src  = "%A% #1";
            string       dest = StringEscaper.ExpandVariables(s, src);
            const string comp = "Hello ";

            Assert.IsTrue(dest.Equals(comp, StringComparison.Ordinal));
        }
Ejemplo n.º 5
0
        public static void ExpandVariables_6()
        {
            EngineState s = EngineTests.CreateEngineState();

            EngineTests.PushDepthInfo(s, 2);

            // In real world, a value must be set with SetValue, so circular reference of variables does not happen
            s.Variables.SetValue(VarsType.Local, "A", "%B%");
            s.Variables.SetValue(VarsType.Local, "B", "%C%");
            s.Variables.SetValue(VarsType.Local, "C", "%A%"); // Set to [#$pC#4p], preventing circular reference
            s.CurSectionInParams[1] = "#2";

            const string src = "%A% #1";

            try { StringEscaper.ExpandVariables(s, src); }
            catch (VariableCircularReferenceException) { return; }

            Assert.Fail();
        }