public void compositeTest7()
        {
            IUserVariable uv = new UserVariable();

            uv.set("test", null, "data1 && data|2");
            uv.set("test2", null, "data1 || data&2");

            ConditionComponent target = new ConditionComponent((new Mock <IEnvironment>()).Object, uv);

            Assert.AreEqual("yes", target.parse("[( #[var test] == \"data1 && data|2\" ){yes}else{no}]"));
            Assert.AreEqual("yes", target.parse("[( #[var test2] == \"data1 || data&2\" ){yes}else{no}]"));
        }
        public void disclosureTest1()
        {
            IUserVariable uv = new UserVariable();

            uv.set("test", null, "(data");
            uv.set("test2", null, "data)");
            uv.set("test3", null, "true");

            ConditionComponent target = new ConditionComponent((new Mock <IEnvironment>()).Object, uv);

            Assert.AreEqual("yes", target.parse("[( #[var test] ~= \"(data\"){yes}else{no}]"));
            Assert.AreEqual("no", target.parse("[( #[var test2] ~= \"(data\"){yes}else{no}]"));
            Assert.AreEqual("yes", target.parse("[( (#[var test3]) ){yes}else{no}]"));
            Assert.AreEqual("yes", target.parse("[( 1 < 2 && 2 == 2 || (((2 >= 2) && true)) ){yes}else{no}]"));
        }
        public void unsetTest3()
        {
            UserVariable target = new UserVariable();

            target.set("name", null, "unevaluated");
            target.set("name2", null, "unevaluated2");

            target.unset("name");
            Assert.AreEqual(1, target.Definitions.Count());

            foreach (string v in target.Definitions)
            {
                Assert.AreEqual(v, "name2");
            }
        }
        public void isUnevaluatedTest4()
        {
            UserVariable target = new UserVariable();

            target.set("name", "project", "val");
            Assert.AreEqual(true, target.isUnevaluated("name", "project"));
        }
        public void isExistTest3()
        {
            UserVariable target = new UserVariable();

            target.set("name", "project", "val");
            Assert.AreEqual(true, target.isExist("name", "project"));
        }
        public void getTest3()
        {
            UserVariable target = new UserVariable();

            target.set("name", null, "val");
            Assert.AreEqual(String.Empty, target.get("name"));
        }
        public void unsetAllTest()
        {
            UserVariable target = new UserVariable();

            target.set("name", null, "unevaluated");
            target.unsetAll();
            Assert.AreEqual(target.Variables.Count(), 0);
        }
        public void disclosureTest4()
        {
            IUserVariable uv = new UserVariable();

            uv.set("test", null, "data(str)");
            uv.set("test2", null, "true");
            uv.set("test3", null, "4");

            ConditionComponent target = new ConditionComponent((new Mock <IEnvironment>()).Object, uv);

            target.PostProcessingMSBuild = true;

            Assert.AreEqual("yes", target.parse("[(  $(test) == \"data(str)\" ){yes}else{no}]"));
            Assert.AreEqual("yes", target.parse("[(  $(test) == \"data(str)\" && 1 < 2){yes}else{no}]"));
            Assert.AreEqual("yes", target.parse("[(  #[var test] == \"data(str)\" && #[var test2] || #[var test3] == 4){yes}else{no}]"));
            Assert.AreEqual("yes", target.parse("[(  #[var test] == \"data(str)\" && !#[var test2] || #[var test3] == 4){yes}else{no}]"));
            Assert.AreEqual("no", target.parse("[(  #[var test] == \"data(str)\" && !#[var test2] && #[var test3] == 4){yes}else{no}]"));
        }
        public void evaluateTest3()
        {
            UserVariable target  = new UserVariable();
            string       name    = "name";
            string       project = "project";

            target.set(name, project, "val");
            target.evaluate(name, project, null, true);
        }
        public void evaluateTest4()
        {
            UserVariable target  = new UserVariable();
            string       name    = "name";
            string       project = "project";

            target.set(name, project, "val");
            target.evaluate(name, project, new Evaluator1(), true);
            Assert.AreEqual("[E1:val]", target.get(name, project));
        }
        public void compositeTest1()
        {
            IUserVariable uv = new UserVariable();

            uv.set("test", null, "(data");

            ConditionComponent target = new ConditionComponent((new Mock <IEnvironment>()).Object, uv);

            Assert.AreEqual("no", target.parse("[( #[var test] ~= \"(data && 1 < 2\" ){yes}else{no}]"));
            Assert.AreEqual("yes", target.parse("[( #[var test] ~= \"(data\" && 1 < 2 ){yes}else{no}]"));
        }
Пример #12
0
        public void containerTest5()
        {
            var    uvar   = new UserVariable();
            Script target = new Script(env, uvar);

            uvar.set("mx", null, "<#data>value\nli]ne</#data>");
            uvar.evaluate("mx", null, new EvaluatorBlank(), true);

            Assert.AreEqual(String.Empty, target.parse("#[var name = #[var mx]]"));
            Assert.AreEqual(2, uvar.Variables.Count());
            Assert.AreEqual("value\nli]ne", uvar.get("name"));
        }
        public void setTest6()
        {
            UserVariable target = new UserVariable();

            target.set("name", "project", null);

            Assert.AreEqual(1, target.Variables.Count());
            foreach (TUserVariable v in target.Variables)
            {
                Assert.AreEqual(v.unevaluated, String.Empty);
            }
        }
Пример #14
0
        public void quotesTest7()
        {
            var uvar   = new UserVariable();
            var target = new Parser(new StubEnv(), uvar);

            uvar.set("lp", null, "s1\\dir");
            uvar.evaluate("lp", null, new EvaluatorBlank(), true);
            Assert.AreEqual("s1\\dir", uvar.get("lp", null));

            Assert.AreEqual("\"s1\\dir\\p1.exe\"", target.parse("\"$(lp)\\p1.exe\""));
            Assert.AreEqual("'$(lp)\\p2.exe'", target.parse("'$(lp)\\p2.exe'"));
            Assert.AreEqual("s1\\dir\\p3.exe", target.parse("$(lp)\\p3.exe"));
        }
Пример #15
0
        public void quotesTest9()
        {
            var uvar   = new UserVariable();
            var target = new Parser(new StubEnv(), uvar);

            uvar.set("lp", null, "\"s3\\dir\"");
            uvar.evaluate("lp", null, new EvaluatorBlank(), true);
            Assert.AreEqual("\"s3\\dir\"", uvar.get("lp", null));

            //Assert.AreEqual("\"\"s3\\dir\"\\p1.exe\"", target.parse("\"$(lp)\\p1.exe\"")); // ? TODO: unspecified for current time
            Assert.AreEqual("'$(lp)\\p2.exe'", target.parse("'$(lp)\\p2.exe'"));
            Assert.AreEqual("\"s3\\dir\"\\p3.exe", target.parse("$(lp)\\p3.exe"));
        }
Пример #16
0
        public void parseMSBuildUnloopingTest6()
        {
            var env     = new StubEnv();
            var uvar    = new UserVariable();
            var msbuild = new vsSBE.MSBuild.Parser(env, uvar);
            var sbe     = new Script(env, uvar);

            string data = "#[var test = #[($(test) == \"" + vsSBE.MSBuild.Parser.PROP_VALUE_DEFAULT + "\"){0}else{$(test)}]]#[var test]";

            Assert.AreEqual("0", msbuild.parse(sbe.parse(data, true)));
            Assert.AreEqual("0", msbuild.parse(sbe.parse(data, true)));

            uvar.set("test", null, "7");
            uvar.evaluate("test", null, new EvaluatorBlank(), true);
            Assert.AreEqual("7", msbuild.parse(sbe.parse(data, true)));
        }
        public void setTest3()
        {
            UserVariable target = new UserVariable();

            target.set("name", null, "unevaluated");
            Assert.AreEqual(1, target.Variables.Count());

            foreach (TUserVariable v in target.Variables)
            {
                Assert.AreEqual(v.evaluated, null);
                Assert.AreEqual(v.ident, "name");
                Assert.AreEqual(v.persistence, false);
                Assert.AreEqual(v.prev, new TUserVariable());
                Assert.AreEqual(v.status, TUserVariable.StatusType.Unevaluated);
                Assert.AreEqual(v.unevaluated, "unevaluated");
            }
        }
        public void stDataTest1()
        {
            var uvar   = new UserVariable();
            var target = new Script(new StubEnv(), uvar);

            uvar.set("p1", null, "v1");
            uvar.evaluate("p1", null, new EvaluatorBlank(), true);

            Assert.AreEqual(String.Empty, target.parse("#[Box data.pack(\"test1\", false): $(p1)#[Box operators.sleep(10)] ]"));
            Assert.AreEqual(String.Empty, target.parse("#[Box data.pack(\"test2\", true): $(p1) #[Box operators.sleep(10)] ]"));

            Assert.AreEqual("$(p1)#[Box operators.sleep(10)]", target.parse("#[Box data.get(\"test1\", false)]").Trim());
            Assert.AreEqual("v1", noSpaces("#[Box data.get(\"test1\", true)]", target));

            Assert.AreEqual("v1", noSpaces("#[Box data.get(\"test2\", false)]", target));
            Assert.AreEqual("v1", noSpaces("#[Box data.get(\"test2\", true)]", target));
        }
        public void stDataTest5()
        {
            var uvar   = new UserVariable();
            var target = new Script(new StubEnv(), uvar);

            uvar.set("p1", null, "ab!");
            uvar.evaluate("p1", null, new EvaluatorBlank(), true);

            Assert.AreEqual(String.Empty, target.parse("#[Box data.pack(\"test1\", false): $(p1) ]"));
            Assert.AreEqual(String.Empty, target.parse("#[Box data.pack(\"test2\", true): $(p1) ]"));

            Assert.AreEqual("$(p1)$(p1)$(p1)$(p1)", noSpaces("#[Box data.clone(\"test1\", 4)]", target));
            Assert.AreEqual("$(p1)$(p1)$(p1)$(p1)", noSpaces("#[Box data.clone(\"test1\", 4, false)]", target));
            Assert.AreEqual("ab!ab!ab!ab!", noSpaces("#[Box data.clone(\"test1\", 4, true)]", target));

            Assert.AreEqual("ab!ab!", noSpaces("#[Box data.clone(\"test2\", 2)]", target));
            Assert.AreEqual("ab!ab!", noSpaces("#[Box data.clone(\"test2\", 2, false)]", target));
            Assert.AreEqual("ab!ab!", noSpaces("#[Box data.clone(\"test2\", 2, true)]", target));

            Assert.AreEqual(String.Empty, noSpaces("#[Box data.clone(\"test2\", 0)]", target));
        }
        public void setTest5()
        {
            UserVariable target = new UserVariable();

            target.set("na%me", "project", "unevaluated");
        }