Exemplo n.º 1
0
        public void containerTest1()
        {
            var uvar        = new UserVariable();
            Script target   = new Script(env, uvar);

            Assert.AreEqual("ne]", target.parse("#[var name = value\nli]ne]"));
            Assert.AreEqual(1, uvar.Variables.Count());
            Assert.AreEqual("value\nli", uvar.get("name"));
        }
Exemplo n.º 2
0
        public void containerTest2()
        {
            var uvar = new UserVariable();
            Script target = new Script(env, uvar);

            Assert.AreEqual(String.Empty, target.parse("#[var name = <#data>value\nli]ne</#data>]"));
            Assert.AreEqual(1, uvar.Variables.Count());
            Assert.AreEqual("value\nli]ne", uvar.get("name"));
        }
Exemplo n.º 3
0
        public void catchTest1()
        {
            var uvar    = new UserVariable();
            var target  = new Script(new StubEnv(), uvar);

            target.parse("#[try{ $(test = '123') }catch{ $(test2 = '456') }]");

            Assert.AreEqual(1, uvar.Variables.Count());
            Assert.AreEqual("123", uvar.get("test", null));
        }
Exemplo n.º 4
0
        public void catchTest2()
        {
            var uvar    = new UserVariable();
            var target  = new Script(new StubEnv(), uvar);

            Assert.AreEqual(0, uvar.Variables.Count());
            target.parse("#[try{ #[notrealcomponentToError]  $(test = '123') }catch{ $(test2 = '456') }]");

            Assert.AreEqual(1, uvar.Variables.Count());
            Assert.AreEqual("456", uvar.get("test2", null));
        }
Exemplo n.º 5
0
        public void containerTest3()
        {
            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"));
        }
Exemplo n.º 6
0
        public void iterateTest4()
        {
            var uvar    = new UserVariable();
            var target  = new Script(new StubEnv(), uvar);

            Assert.AreEqual("ab!ab!ab!", noSpaces(@"
                                                #[Box iterate(i = 1; $(i) < 4; i = $([MSBuild]::Add($(i), 1))):
                                                    ab!
                                                ]", target));

            Assert.AreEqual(1, uvar.Variables.Count());
            Assert.AreEqual("4", uvar.get("i", null));
        }
Exemplo n.º 7
0
        public void catchTest3()
        {
            var uvar    = new UserVariable();
            var target  = new Script(new StubEnv(), uvar);

            Assert.AreEqual(0, uvar.Variables.Count());
            target.parse(@"
                            #[( false ){

                                #[try
                                {
                                     #[notrealcomponentToError]
                                }
                                catch(err, msg)
                                {
                                    $(test1 = '123')
                                }]

                            }
                            else{

                                #[try
                                {
                                     #[notrealcomponentToError]
                                }
                                catch(err, msg)
                                {
                                    $(test2 = '456')
                                    $(exErr = $(err))
                                    $(exMsg = $(msg))
                                }]

                            }] ");

            Assert.AreEqual(3, uvar.Variables.Count());
            Assert.AreEqual(null, uvar.get("test1", null));
            Assert.AreEqual("456", uvar.get("test2", null));
            Assert.AreEqual(true, !string.IsNullOrWhiteSpace(uvar.get("exErr", null)));
            Assert.AreEqual(true, !string.IsNullOrWhiteSpace(uvar.get("exMsg", null)));
            Assert.AreEqual(null, uvar.get("err", null));
            Assert.AreEqual(null, uvar.get("msg", null));
        }
Exemplo n.º 8
0
        public void catchTest4()
        {
            var uvar    = new UserVariable();
            var target  = new Script(new StubEnv(), uvar);

            Assert.AreEqual(0, uvar.Variables.Count());
            target.parse(@"
                            #[( false ){

                                #[try
                                {
                                     #[notrealcomponentToError]
                                }
                                catch
                                {
                                    $(test1 = '123')
                                }]

                            }
                            else{

                                #[try
                                {
                                     #[notrealcomponentToError]
                                }
                                catch
                                {
                                    $(test2 = '456')
                                }]

                            }] ");

            Assert.AreEqual(1, uvar.Variables.Count());
            Assert.AreEqual(null, uvar.get("test1", null));
            Assert.AreEqual("456", uvar.get("test2", null));
            Assert.AreEqual(null, uvar.get("err", null));
            Assert.AreEqual(null, uvar.get("msg", null));
        }
Exemplo n.º 9
0
        public void containerTest9()
        {
            var uvar = new UserVariable();
            Script target = new Script(env, uvar);

            Assert.AreEqual("test - cc", target.parse("#[var sres = <#data>Data1\n\nEnd</#data>]test - cc#[var sres2 = <#data>Data2\n\nEnd</#data>]"));
            Assert.AreEqual(2, uvar.Variables.Count());
            Assert.AreEqual("Data1\n\nEnd", uvar.get("sres"));
            Assert.AreEqual("Data2\n\nEnd", uvar.get("sres2"));
        }
Exemplo n.º 10
0
        public void containerTest7()
        {
            var uvar = new UserVariable();
            Script target = new Script(env, uvar);

            Assert.AreEqual("#[var name = left [box1 right]", target.parse("#[var name = left [box1 right]"));
            Assert.AreEqual(0, uvar.Variables.Count());

            Assert.AreEqual(String.Empty, target.parse("#[var name = \"left [box1 right\"]"));
            Assert.AreEqual(1, uvar.Variables.Count());
            Assert.AreEqual("\"left [box1 right\"", uvar.get("name"));
        }
Exemplo n.º 11
0
        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));
        }
Exemplo n.º 12
0
 public void getTest3()
 {
     UserVariable target = new UserVariable();
     target.set("name", null, "val");
     Assert.AreEqual(String.Empty, target.get("name"));
 }
Exemplo n.º 13
0
 public void getTest()
 {
     UserVariable target = new UserVariable();
     Assert.AreEqual(null, target.get("name"));
     Assert.AreEqual(null, target.get("name", "project"));
 }
Exemplo n.º 14
0
        public void vtSignTest1()
        {
            var uvar    = new UserVariable();
            var target  = new Parser(new StubEnv(), uvar);

            Assert.AreEqual(String.Empty, target.parse("$(+name = 'myvar')"));
            Assert.AreEqual("myvar", uvar.get("name"));

            Assert.AreEqual(String.Empty, target.parse("$(+name += '12')"));
            Assert.AreEqual("myvar12", uvar.get("name"));

            Assert.AreEqual(String.Empty, target.parse("$(name += '34')"));
            Assert.AreEqual("myvar1234", uvar.get("name"));
        }
Exemplo n.º 15
0
        public void repeatTest4()
        {
            var uvar    = new UserVariable();
            var target  = new Script(new StubEnv(), uvar);

            Assert.AreEqual("ab!ab!ab!ab!", noSpaces(@"
                                                #[$(i = 0)]#[Box repeat($(i) < 4; false): $(i = $([MSBuild]::Add($(i), 1)))
                                                    ab!
                                                ]", target));

            Assert.AreEqual(1, uvar.Variables.Count());
            Assert.AreEqual("4", uvar.get("i", null));
        }
Exemplo n.º 16
0
        public void repeatTest3()
        {
            var uvar    = new UserVariable();
            var target  = new Script(new StubEnv(), uvar);

            Assert.AreEqual(String.Empty, noSpaces(@"
                                                #[$(i = 2)]#[Box repeat($(i) < 8; true): $(i = $([MSBuild]::Add($(i), 1)))
                                                    ab!
                                                ]", target));

            Assert.AreEqual(1, uvar.Variables.Count());
            Assert.AreEqual("8", uvar.get("i", null));
        }
Exemplo n.º 17
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"));
        }
Exemplo n.º 18
0
        public void vtSignTest5()
        {
            var uvar = new UserVariable();
            var target = new Parser(new StubEnv(), uvar);

            Assert.AreEqual(String.Empty, target.parse("$(i = 1)"));
            Assert.AreEqual(String.Empty, target.parse("$(i += $(i))"));
            Assert.AreEqual("2", uvar.get("i"));

            //TODO: currently std. exception:
            try {
                Assert.AreEqual(String.Empty, target.parse("$(i += 'test')"));
                Assert.Fail("1");
            }
            catch(Exception ex) { Assert.IsTrue(true /*ex.GetType() == typeof(NotFoundException)*/, ex.GetType().ToString()); }
        }
Exemplo n.º 19
0
        public void vtSignTest4()
        {
            var uvar    = new UserVariable();
            var target  = new Parser(new StubEnv(), uvar);

            Assert.AreEqual(String.Empty, target.parse("$(i = \"test\")"));
            Assert.AreEqual(String.Empty, target.parse("$(i += 1)"));
            Assert.AreEqual("test1", uvar.get("i"));

            target.parse("$(i -= 1)");
        }
Exemplo n.º 20
0
        public void vtSignTest3()
        {
            var uvar = new UserVariable();
            var target = new Parser(new StubEnv(), uvar);

            Assert.AreEqual(String.Empty, target.parse("$(i += 1)"));
            Assert.AreEqual("1", uvar.get("i"));

            Assert.AreEqual(String.Empty, target.parse("$(j -= 1)"));
            Assert.AreEqual("-1", uvar.get("j"));
        }
Exemplo n.º 21
0
        public void vtSignTest2()
        {
            var uvar = new UserVariable();
            var target = new Parser(new StubEnv(), uvar);

            Assert.AreEqual(String.Empty, target.parse("$(i = 0)"));
            Assert.AreEqual(String.Empty, target.parse("$(i += 1)"));
            Assert.AreEqual(String.Empty, target.parse("$(i += 2)$(i += 1)"));
            Assert.AreEqual(String.Empty, target.parse("$(i -= 2)"));
            Assert.AreEqual("2", uvar.get("i"));
        }
Exemplo n.º 22
0
        public void repeatTest2()
        {
            var uvar    = new UserVariable();
            var target  = new Script(new StubEnv(), uvar);

            Assert.AreEqual("ab!ab!ab!", noSpaces(@"
                                                #[$(i = 2)]#[Box repeat($(i) < 8): $(i = $([MSBuild]::Add($(i), 2)))
                                                    ab!
                                                    #[Box operators.sleep(50)]
                                                ]", target));

            Assert.AreEqual(1, uvar.Variables.Count());
            Assert.AreEqual("8", uvar.get("i", null));
        }
Exemplo n.º 23
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"));
        }