Exemple #1
0
        public void ParseUnloopingTest7()
        {
            var target = new EvMSBuilderAcs();

            Assert.Equal(string.Format("2 {0} 2", EvMSBuilder.UNDEF_VAL),
                         target.Eval("$(test = \"1 $(test) 2\")$(test = $(test.Replace('1', '2')))$(test)"));
        }
Exemple #2
0
        public void QuotesTest6()
        {
            var target = new EvMSBuilderAcs();

            Assert.Equal(string.Empty, target.Eval("$(version = \"1.2.3\")"));
            Assert.Equal(string.Empty, target.Eval("$(tpl = \"My version - $(version), \\\"$(version)\\\", '$(version)' end.\")"));
            Assert.Equal("My version - 1.2.3, \"1.2.3\", '$(version)' end.", target.Eval("$(tpl)"));
        }
Exemple #3
0
        public void ParseUnloopingTest6()
        {
            var target = new EvMSBuilderAcs();

            target.Eval("$(p2 = \"$$(p1) to $$(p8),  and new ($$( p7.Replace('1', '2'))) s$$(p9)\")$(p6 = $$(p2))$(p7 = $$(p5))$(p5 = $(p6))$(p5)");
            target.Eval("$(p2 = \"$$(p1) to $$(p8),  and new ($$(p7.Replace('1', '2'))) s$$(p9)\")$(p6 = $$(p2))$(p7 = $$(p5))$(p5 = $(p6))$(p5)");
            Assert.True(true); // no problems for stack & heap
        }
Exemple #4
0
        public void ParseUnloopingTest2()
        {
            var target = new EvMSBuilderAcs();

            string data = "$(myVar = $(myVar))$(myVar)";

            Assert.Equal(EvMSBuilder.UNDEF_VAL, target.Eval(data));
        }
Exemple #5
0
        public void ParseUnloopingTest1()
        {
            var target = new EvMSBuilderAcs();

            string data = "$(myVar = $$(myVar))$(myVar)";

            Assert.Equal("$(myVar)", target.Eval(data));
        }
Exemple #6
0
        public void BasicParseTest1()
        {
            var target = new EvMSBuilderAcs();

            string actual   = target.Eval("FooBar");
            string expected = "FooBar";

            Assert.Equal(expected, actual);
        }
Exemple #7
0
        public void BasicParseTest6()
        {
            var target = new EvMSBuilderAcs();

            string actual   = target.Eval("$$(Path.Replace('\', '/'):project)");
            string expected = "$(Path.Replace('\', '/'):project)";

            Assert.Equal(expected, actual);
        }
Exemple #8
0
        public void ParseUnloopingTest4()
        {
            var target = new EvMSBuilderAcs();

            Assert.Throws <LimitException>(() => {
                // p4 -> p2 -> p3 -> p1 -> p4
                target.Eval("$(p4 = $$(p2))$(p3 = $$(p1))$(p2 = $$(p3))$(p1 = $$(p4))$(p4)");
            });
        }
Exemple #9
0
        public void QuotesTest5()
        {
            var target = new EvMSBuilderAcs();

            target.UVars.SetVariable("name", null, "test123");
            target.UVars.Evaluate("name", null, new EvaluatorBlank(), true);

            Assert.Equal("test123", target.Eval("$([System.String]::Concat(\"$(name)\"))"));
            Assert.Equal("test123", target.Eval("$([System.String]::Concat('$(name)'))"));
        }
Exemple #10
0
        public void QuotesTest4()
        {
            var target = new EvMSBuilderAcs();

            target.UVars.SetVariable("name", "project", "test123");
            target.UVars.Evaluate("name", "project", new EvaluatorBlank(), true);

            //Assert.Equal("test123", target.parse("$([System.String]::Concat('$(name:project)'))")); //TODO: read note from hquotes
            Assert.Equal("test123", target.Eval("$([System.String]::Concat(\"$(name:project)\"))")); // $([System.DateTime]::Parse(\"$([System.DateTime]::UtcNow.Ticks)\").ToBinary())
        }
Exemple #11
0
        public void QuotesTest2()
        {
            var target = new EvMSBuilderAcs();

            Assert.Equal(" left '123' right ", target.Eval("$([System.String]::Format(\" left '{0}' right \", \"123\"))"));
            Assert.Equal(" left '123' ) right ", target.Eval("$([System.String]::Format(\" left '{0}' ) right \", \"123\"))"));

            Assert.Equal(" left \"123\" right ", target.Eval("$([System.String]::Format(' left \"{0}\" right ', '123'))"));
            Assert.Equal(" left \"123\" ) right ", target.Eval("$([System.String]::Format(' left \"{0}\" ) right ', '123'))"));
        }
Exemple #12
0
        public void QuotesTest1()
        {
            var target = new EvMSBuilderAcs();

            Assert.Equal(string.Empty, target.Eval("$(name = \" $([System.Math]::Pow(2, 16)) \")"));
            Assert.Equal(" 65536 ", target.UVars.GetValue("name", null));

            Assert.Equal(string.Empty, target.Eval("$(name = ' $([System.Math]::Pow(2, 16)) ')"));
            Assert.Equal(" $([System.Math]::Pow(2, 16)) ", target.UVars.GetValue("name", null));
        }
Exemple #13
0
        public void QuotesTest11()
        {
            var target = new EvMSBuilderAcs();

            Assert.Equal("simply \"text\" data", target.Eval("simply \"text\" data"));
            Assert.Equal("simply \\\"text\\\" data", target.Eval("simply \\\"text\\\" data"));
            Assert.Equal("simply \\\\\"text\\\\\" data", target.Eval("simply \\\\\"text\\\\\" data"));
            Assert.Equal("simply 'text' data", target.Eval("simply 'text' data"));
            Assert.Equal("simply \'text\' data", target.Eval("simply \'text\' data"));
            Assert.Equal("simply \\'text\\' data", target.Eval("simply \\'text\\' data"));
        }
Exemple #14
0
        public void QuotesTest3()
        {
            var target = new EvMSBuilderAcs();

            Assert.Equal(string.Empty, target.Eval("$(tpl = \"My version - '%Ver%'\")"));
            Assert.Equal("My version - '%Ver%'", target.UVars.GetValue("tpl", null));

            Assert.Equal(string.Empty, target.Eval("$(ver = '1.2.3')"));
            Assert.Equal("1.2.3", target.UVars.GetValue("ver", null));

            Assert.Equal(string.Empty, target.Eval("$(rev = '2417')"));
            Assert.Equal("2417", target.UVars.GetValue("rev", null));

            Assert.Equal("My version - '1, 2, 3, 2417'", target.Eval("$(tpl.Replace(\"%Ver%\", \"$(ver.Replace('.', ', ')), $(rev)\"))"));
            Assert.Equal("1.2.3 version - '1.2.3.2417'", target.Eval("$(tpl.Replace(\"%Ver%\", \"$(ver).$(rev)\").Replace(\"My\", \"$(ver)\"))"));
        }
Exemple #15
0
        public void ParseUnloopingTest8()
        {
            var target = new EvMSBuilderAcs();

            Assert.Equal("7", target.Eval("$(test = 7)$(test = $(test))$(test)"));
        }
Exemple #16
0
        public void ParseUnloopingTest5()
        {
            var target = new EvMSBuilderAcs();

            Assert.Equal(EvMSBuilder.UNDEF_VAL, target.Eval("$(p2 = $$(p1))$(p6 = $$(p2))$(p7 = $$(p5))$(p5 = $(p6))$(p5)"));
        }