public void getPropertyTest()
        {
            var mockDte2                    = new Mock<EnvDTE80.DTE2>();
            var mockSolution                = new Mock<EnvDTE.Solution>();
            var mockSolutionBuild           = new Mock<EnvDTE.SolutionBuild>();
            var mockSolutionConfiguration2  = new Mock<EnvDTE80.SolutionConfiguration2>();

            mockSolutionConfiguration2.SetupGet(p => p.Name).Returns("Release");
            mockSolutionConfiguration2.SetupGet(p => p.PlatformName).Returns("x86");

            mockSolutionBuild.SetupGet(p => p.ActiveConfiguration).Returns(mockSolutionConfiguration2.Object);
            mockSolution.SetupGet(p => p.SolutionBuild).Returns(mockSolutionBuild.Object);
            mockDte2.SetupGet(p => p.Solution).Returns(mockSolution.Object);

            Parser target = new Parser(new net.r_eg.vsCE.Environment(mockDte2.Object));
            Assert.IsNotNull(target.getProperty("Configuration"));
            Assert.IsNotNull(target.getProperty("Platform"));
        }
예제 #2
0
 public void parseUnloopingTest4()
 {
     var target = new Parser(new StubEnv());
     // p4 -> p2 -> p3 -> p1 -> p4
     target.parse("$(p4 = $$(p2))$(p3 = $$(p1))$(p2 = $$(p3))$(p1 = $$(p4))$(p4)");
 }
예제 #3
0
        public void quotesTest4()
        {
            var target = new Parser(new StubEnv());

            target.UVariable.set("name", "project", "test123");
            target.UVariable.evaluate("name", "project", new EvaluatorBlank(), true);

            //Assert.AreEqual("test123", target.parse("$([System.String]::Concat('$(name:project)'))")); //TODO: read note from hquotes
            Assert.AreEqual("test123", target.parse("$([System.String]::Concat(\"$(name:project)\"))")); // $([System.DateTime]::Parse(\"$([System.DateTime]::UtcNow.Ticks)\").ToBinary())
        }
        public void parseTest12()
        {
            Parser target = new Parser(new net.r_eg.vsCE.Environment((DTE2)null));

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

            Assert.AreEqual(expected, actual);
        }
        public void parseTest1()
        {
            Parser target = new Parser(new net.r_eg.vsCE.Environment((DTE2)null));

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

            Assert.AreEqual(expected, actual);
        }
예제 #6
0
 public void quotesTest11()
 {
     var target = new Parser(new StubEnv());
     Assert.AreEqual("simply \"text\" data", target.parse("simply \"text\" data"));
     Assert.AreEqual("simply \\\"text\\\" data", target.parse("simply \\\"text\\\" data"));
     Assert.AreEqual("simply \\\\\"text\\\\\" data", target.parse("simply \\\\\"text\\\\\" data"));
     Assert.AreEqual("simply 'text' data", target.parse("simply 'text' data"));
     Assert.AreEqual("simply \'text\' data", target.parse("simply \'text\' data"));
     Assert.AreEqual("simply \\'text\\' data", target.parse("simply \\'text\\' data"));
 }
예제 #7
0
        public void quotesTest1()
        {
            var target = new Parser(new StubEnv());

            Assert.AreEqual(String.Empty, target.parse("$(name = \" $([System.Math]::Pow(2, 16)) \")"));
            Assert.AreEqual(" 65536 ", target.UVariable.get("name", null));

            Assert.AreEqual(String.Empty, target.parse("$(name = ' $([System.Math]::Pow(2, 16)) ')"));
            Assert.AreEqual(" $([System.Math]::Pow(2, 16)) ", target.UVariable.get("name", null));
        }
예제 #8
0
 public void parseUnloopingTest7()
 {
     var target = new Parser(new StubEnv());
     Assert.AreEqual(String.Format("2 {0} 2", Parser.PROP_VALUE_DEFAULT),
                     target.parse("$(test = \"1 $(test) 2\")$(test = $(test.Replace('1', '2')))$(test)"));
 }
예제 #9
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)");
        }
예제 #10
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"));
        }
예제 #11
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"));
        }
예제 #12
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"));
        }
예제 #13
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"));
        }
예제 #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 quotesTest6()
        {
            var target = new Parser(new StubEnv());

            Assert.AreEqual(String.Empty, target.parse("$(version = \"1.2.3\")"));
            Assert.AreEqual(String.Empty, target.parse("$(tpl = \"My version - $(version), \\\"$(version)\\\", '$(version)' end.\")"));
            Assert.AreEqual("My version - 1.2.3, \"1.2.3\", '$(version)' end.", target.parse("$(tpl)"));
        }
예제 #16
0
 public void parseUnloopingTest5()
 {
     var target = new Parser(new StubEnv());
     Assert.AreEqual(Parser.PROP_VALUE_DEFAULT, target.parse("$(p2 = $$(p1))$(p6 = $$(p2))$(p7 = $$(p5))$(p5 = $(p6))$(p5)"));
 }
예제 #17
0
 public void parseUnloopingTest6()
 {
     var target = new Parser(new StubEnv());
     target.parse("$(p2 = \"$$(p1) to $$(p8),  and new ($$( p7.Replace('1', '2'))) s$$(p9)\")$(p6 = $$(p2))$(p7 = $$(p5))$(p5 = $(p6))$(p5)");
     target.parse("$(p2 = \"$$(p1) to $$(p8),  and new ($$(p7.Replace('1', '2'))) s$$(p9)\")$(p6 = $$(p2))$(p7 = $$(p5))$(p5 = $(p6))$(p5)");
     Assert.IsTrue(true); // no problems for stack & heap
 }
예제 #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()); }
        }
예제 #19
0
 public void parseUnloopingTest8()
 {
     var target = new Parser(new StubEnv());
     Assert.AreEqual("7", target.parse("$(test = 7)$(test = $(test))$(test)"));
 }
예제 #20
0
        public void parseTest1()
        {
            Parser target = new Parser(new StubEnv());

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

            Assert.AreEqual(expected, actual);
        }
예제 #21
0
        public void quotesTest10()
        {
            var target = new Parser(new StubEnv());

            target.UVariable.set("name", null, "test123");
            target.UVariable.evaluate("name", null, new EvaluatorBlank(), true);

            Assert.AreEqual("test123)", target.parse("$([System.String]::Concat(\"$(name))\"))"));
            Assert.AreEqual("(test123", target.parse("$([System.String]::Concat(\"($(name)\"))"));

            Assert.AreEqual("(test123", target.parse("$([System.String]::Concat('($(name)'))"));
            Assert.AreEqual("test123)", target.parse("$([System.String]::Concat('$(name))'))"));

            Assert.AreEqual(" left ) test123 ", target.parse("$([System.String]::Concat(\" left ) $(name) \"))"));
            Assert.AreEqual(" left ) test123 ", target.parse("$([System.String]::Concat(' left ) $(name) '))"));

            Assert.AreEqual(" left () test123 ", target.parse("$([System.String]::Concat(\" left () $(name) \"))"));
            Assert.AreEqual(" left () test123 ", target.parse("$([System.String]::Concat(' left () $(name) '))"));
        }
예제 #22
0
        public void parseTest12()
        {
            Parser target = new Parser(new StubEnv());

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

            Assert.AreEqual(expected, actual);
        }
예제 #23
0
        public void quotesTest2()
        {
            var target = new Parser(new StubEnv());
            Assert.AreEqual(" left '123' right ", target.parse("$([System.String]::Format(\" left '{0}' right \", \"123\"))"));
            Assert.AreEqual(" left '123' ) right ", target.parse("$([System.String]::Format(\" left '{0}' ) right \", \"123\"))"));

            Assert.AreEqual(" left \"123\" right ", target.parse("$([System.String]::Format(' left \"{0}\" right ', '123'))"));
            Assert.AreEqual(" left \"123\" ) right ", target.parse("$([System.String]::Format(' left \"{0}\" ) right ', '123'))"));
        }
예제 #24
0
        public void parseUnloopingTest1()
        {
            var target = new Parser(new StubEnv());

            string data = "$(myVar = $$(myVar))$(myVar)";
            Assert.AreEqual("$(myVar)", target.parse(data));
        }
예제 #25
0
        public void parseUnloopingTest2()
        {
            var target = new Parser(new StubEnv());

            string data = "$(myVar = $(myVar))$(myVar)";
            Assert.AreEqual(Parser.PROP_VALUE_DEFAULT, target.parse(data));
        }
예제 #26
0
 public void parseUnloopingTest3()
 {
     var target = new Parser(new StubEnv());
     // p1 -> p2 -> p1 ] p3 -> p2
     target.parse("$(p1 = $$(p2))$(p2 = $$(p1))$(p3 = $(p2))");
 }
        public void parseVariablesSBETest4()
        {
            Parser target = new Parser(new net.r_eg.vsCE.Environment((DTE2)null));

            string expected = String.Empty;
            string actual   = target.parseVariablesSBE("$(name)", "name", null);
            Assert.AreEqual(expected, actual);
        }
예제 #28
0
        public void quotesTest3()
        {
            var target = new Parser(new StubEnv());

            Assert.AreEqual(String.Empty, target.parse("$(tpl = \"My version - '%Ver%'\")"));
            Assert.AreEqual("My version - '%Ver%'", target.UVariable.get("tpl", null));

            Assert.AreEqual(String.Empty, target.parse("$(ver = '1.2.3')"));
            Assert.AreEqual("1.2.3", target.UVariable.get("ver", null));

            Assert.AreEqual(String.Empty, target.parse("$(rev = '2417')"));
            Assert.AreEqual("2417", target.UVariable.get("rev", null));

            Assert.AreEqual("My version - '1, 2, 3, 2417'", target.parse("$(tpl.Replace(\"%Ver%\", \"$(ver.Replace('.', ', ')), $(rev)\"))"));
            Assert.AreEqual("1.2.3 version - '1.2.3.2417'", target.parse("$(tpl.Replace(\"%Ver%\", \"$(ver).$(rev)\").Replace(\"My\", \"$(ver)\"))"));
        }