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}]"));
        }
 public void parseTest8()
 {
     var mockEnv = new Mock<IEnvironment>();
     var mockUVar = new Mock<IUserVariable>();
     ConditionComponent target = new ConditionComponent(mockEnv.Object, mockUVar.Object);
     Assert.AreEqual(" body1 ", target.parse("[(!false){ body1 }else{ body2 }]"));
     Assert.AreEqual(String.Empty, target.parse("[(!true){ body1 }]"));
 }
 public void parseTest7()
 {
     var mockEnv = new Mock<IEnvironment>();
     var mockUVar = new Mock<IUserVariable>();
     ConditionComponent target = new ConditionComponent(mockEnv.Object, mockUVar.Object);
     Assert.AreEqual(" body2 ", target.parse("[ (false) { body1 } else { body2 } ]"));
     Assert.AreEqual(" body1 ", target.parse("[ (false == 0) { body1 } else { body2 } ]"));
     Assert.AreEqual(" body1 ", target.parse("[ (false == false) { body1 } else { body2 } ]"));
     Assert.AreEqual(" body1 ", target.parse("[ (\"false\" == 0) { body1 } else { body2 } ]"));
     Assert.AreEqual(" body2 ", target.parse("[ (\"false\") { body1 } else { body2 } ]"));
     Assert.AreEqual(" body2 ", target.parse("[(false){ body1 }else{ body2 }]"));
     Assert.AreEqual("\n body2 \n", target.parse("[ (false) {\n body1 \n}\nelse {\n body2 \n} ]"));
 }
 public void parseTest6()
 {
     var mockEnv = new Mock<IEnvironment>();
     var mockUVar = new Mock<IUserVariable>();
     ConditionComponent target = new ConditionComponent(mockEnv.Object, mockUVar.Object);
     Assert.AreEqual(" body1 ", target.parse("[ (true) { body1 } ]"));
     Assert.AreEqual(" body1 ", target.parse("[ (true == 1) { body1 } ]"));
     Assert.AreEqual(" body1 ", target.parse("[ (true == true) { body1 } ]"));
     Assert.AreEqual(" body1 ", target.parse("[(true){ body1 }]"));
     Assert.AreEqual("\n body1 \n", target.parse("[(true){\n body1 \n}]"));
     Assert.AreEqual(" body1 ", target.parse("[ (\"true\" == 1) { body1 } ]"));
     Assert.AreEqual(" body1 ", target.parse("[ (\"true\") { body1 } ]"));
     Assert.AreEqual(String.Empty, target.parse("[ (false) { body1 } ]"));
     Assert.AreEqual(String.Empty, target.parse("[ (true == 0) { body1 } ]"));
     Assert.AreEqual(String.Empty, target.parse("[ (true == false) { body1 } ]"));
 }
 public void parseTest5()
 {
     var mockEnv = new Mock<IEnvironment>();
     var mockUVar = new Mock<IUserVariable>();
     ConditionComponent target = new ConditionComponent(mockEnv.Object, mockUVar.Object);
     target.parse("[ (!) { body1 } ]");
 }
        public void parseTest18()
        {
            var mockEnv = new Mock<IEnvironment>();
            var mockUVar = new Mock<IUserVariable>();
            ConditionComponent target = new ConditionComponent(mockEnv.Object, mockUVar.Object);

            Assert.AreEqual(" body1 ", target.parse("[(ConsoleApplication_1 ^= Console){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(ConsoleApplication_1 ^= Application){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(ConsoleApplication_1 ^= \" Console\"){ body1 }else{ body2 }]"));

            Assert.AreEqual(" body1 ", target.parse("[(ConsoleApplication_1 =^ _1){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(ConsoleApplication_1 =^ Console){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(ConsoleApplication_1 =^ \"_1 \"){ body1 }else{ body2 }]"));
        }
        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 compositeTest3()
 {
     ConditionComponent target = new ConditionComponent((new Mock<IEnvironment>()).Object, (new Mock<IUserVariable>()).Object);
     target.parse("[( 2 == 2 | 1 < 2 ){yes}else{no}]");
 }
        public void parseTest11()
        {
            var mockEnv = new Mock<IEnvironment>();
            var mockUVar = new Mock<IUserVariable>();
            ConditionComponent target = new ConditionComponent(mockEnv.Object, mockUVar.Object);

            Assert.AreEqual(" body1 ", target.parse("[(Test123Data ~= 12){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(Test123Data ~= \" 12\"){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body1 ", target.parse("[(Test 123 Data ~= \" 12\"){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body1 ", target.parse("[(Test 123 Data ~= Data){ body1 }else{ body2 }]"));
        }
 public void invertTest1()
 {
     ConditionComponent target = new ConditionComponent((new Mock<IEnvironment>()).Object, (new Mock<IUserVariable>()).Object);
     Assert.AreEqual("no", target.parse("[( (!2 == 2) && 1 < 2 ){yes}else{no}]"));
     Assert.AreEqual("no", target.parse("[( (!2 == 2) && (!1 < 2) ){yes}else{no}]"));
     Assert.AreEqual("no", target.parse("[( (!2 == 2) && (!1 > 2) ){yes}else{no}]"));
     Assert.AreEqual("yes", target.parse("[(! (!2 == 2) && (!1 > 2) ){yes}else{no}]"));
     Assert.AreEqual("no", target.parse("[( (!2 == 2) && (!1 < 2) || (!true) ){yes}else{no}]"));
     Assert.AreEqual("yes", target.parse("[( (!2 == 2) && (!1 < 2) || (true) ){yes}else{no}]"));
 }
        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 disclosureTest3()
 {
     ConditionComponent target = new ConditionComponent((new Mock<IEnvironment>()).Object, (new Mock<IUserVariable>()).Object);
     target.parse("[( 1 < 2 && () || (((2 >= 2) && true)) ){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 compositeTest8()
 {
     ConditionComponent target = new ConditionComponent((new Mock<IEnvironment>()).Object, (new Mock<IUserVariable>()).Object);
     Assert.AreEqual("yes", target.parse("[( (1 < 2 && 2 == 2 && ( true || ((false || 2 >= 2) && (1 > 7 && true)))) ){yes}else{no}]"));
     Assert.AreEqual("no", target.parse("[( (1 < 2 && 2 == 2 && ( true && ((false || 2 >= 2) && (1 > 7 && true)))) ){yes}else{no}]"));
     Assert.AreEqual("yes", target.parse("[( (1 < 2 && 2 == 2 || ( true && ((false || 2 >= 2) && (1 > 7 && true)))) ){yes}else{no}]"));
     Assert.AreEqual("yes", target.parse("[( (1 < 2 && 2 == 2 && ( true && ((false || 2 >= 2) || (1 > 7 && true)))) ){yes}else{no}]"));
     Assert.AreEqual("no", target.parse("[( (1 < 2 && 2 == 2 && ( true && ((false || 2 > 2) || (1 > 7 && true)))) ){yes}else{no}]"));
 }
        public void parseTest9()
        {
            var mockEnv = new Mock<IEnvironment>();
            var mockUVar = new Mock<IUserVariable>();
            ConditionComponent target = new ConditionComponent(mockEnv.Object, mockUVar.Object);

            Assert.AreEqual(" body1 ", target.parse("[(str1 === str1){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(\"str1 \"===\" str1\"){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body1 ", target.parse("[(str1 == str1){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(\"str1 \"==\" str1\"){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(\"str1\"==\" str1 \"){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(str1==\"str1 \"){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body1 ", target.parse("[(02 == 2){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(02 === 2){ body1 }else{ body2 }]"));
        }
        public void parseTest12()
        {
            var mockEnv = new Mock<IEnvironment>();
            var mockUVar = new Mock<IUserVariable>();
            ConditionComponent target = new ConditionComponent(mockEnv.Object, mockUVar.Object);

            Assert.AreEqual(" body2 ", target.parse("[(1 > 1){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body1 ", target.parse("[(1 >= 1){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(1 > 01){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body1 ", target.parse("[(01 >= 1){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(1 < 1){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body1 ", target.parse("[(1 <= 1){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(1 < 01){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body1 ", target.parse("[(01 <= 1){ body1 }else{ body2 }]"));
        }
        public void parseTest13()
        {
            var mockEnv = new Mock<IEnvironment>();
            var mockUVar = new Mock<IUserVariable>();
            ConditionComponent target = new ConditionComponent(mockEnv.Object, mockUVar.Object);

            Assert.AreEqual(" body2 ", target.parse("[(!str1 === str1){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body1 ", target.parse("[(!\"str1 \"===\" str1\"){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(! str1 == str1){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body1 ", target.parse("[(! \"str1 \"==\" str1\"){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(!02 == 2){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body1 ", target.parse("[(!02 === 2){ body1 }else{ body2 }]"));

            Assert.AreEqual(" body1 ", target.parse("[(!str1 !== str1){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(!\"str1 \"!==\" str1\"){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body1 ", target.parse("[(! str1 != str1){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(!\"str1 \"!=\" str1\"){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body1 ", target.parse("[(!02 != 2){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(! 02 !== 2){ body1 }else{ body2 }]"));

            Assert.AreEqual(" body2 ", target.parse("[(!Test123Data ~= 12){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body1 ", target.parse("[(! Test123Data ~= \" 12\"){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(! Test 123 Data ~= \" 12\"){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(!Test 123 Data ~= Data){ body1 }else{ body2 }]"));

            Assert.AreEqual(" body1 ", target.parse("[(!1 > 1){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(!1 >= 1){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body1 ", target.parse("[(! 1 > 01){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(!01 >= 1){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body1 ", target.parse("[(! 1 < 1){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(! 1 <= 1){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body1 ", target.parse("[(!1 < 01){ body1 }else{ body2 }]"));
            Assert.AreEqual(" body2 ", target.parse("[(! 01 <= 1){ body1 }else{ body2 }]"));
        }
 public void compositeTest4()
 {
     ConditionComponent target = new ConditionComponent((new Mock<IEnvironment>()).Object, (new Mock<IUserVariable>()).Object);
     Assert.AreEqual("yes", target.parse("[( 2 == 2 && 1 < 2 ){yes}else{no}]"));
     Assert.AreEqual("no", target.parse("[( 2 == 2 && 1 > 2 ){yes}else{no}]"));
     Assert.AreEqual("no", target.parse("[( 2 != 2 && 1 < 2 ){yes}else{no}]"));
     Assert.AreEqual("yes", target.parse("[( 2 == 2 || 1 < 2 ){yes}else{no}]"));
     Assert.AreEqual("yes", target.parse("[( 2 == 2 || 1 > 2 ){yes}else{no}]"));
     Assert.AreEqual("yes", target.parse("[( 2 != 2 || 1 < 2 ){yes}else{no}]"));
     Assert.AreEqual("no", target.parse("[( 2 != 2 || 1 > 2 ){yes}else{no}]"));
 }
 public void compositeTest5()
 {
     ConditionComponent target = new ConditionComponent((new Mock<IEnvironment>()).Object, (new Mock<IUserVariable>()).Object);
     Assert.AreEqual("no", target.parse("[( 2 == 2 && 1 < 2 && (7 == 4) ){yes}else{no}]"));
     Assert.AreEqual("yes", target.parse("[( 2 != 2 && 1 > 2 || (7 != 4) ){yes}else{no}]"));
     Assert.AreEqual("yes", target.parse("[( true && ((1 < 2) || (((2 >= 2) && true))) ){yes}else{no}]"));
     Assert.AreEqual("yes", target.parse("[( ((1 < 2) || (((2 >= 2) && true))) ){yes}else{no}]"));
     Assert.AreEqual("yes", target.parse("[( ((1 < 2) && (((2 >= 2) && true))) ){yes}else{no}]"));
     Assert.AreEqual("no", target.parse("[( ((1 < 2) && (((2 > 2) && true))) ){yes}else{no}]"));
     Assert.AreEqual("yes", target.parse("[( true && ((1 < 2) || (((2 > 2) && true))) ){yes}else{no}]"));
     Assert.AreEqual("no", target.parse("[( true && ((1 < 2) && (((2 > 2) && true))) ){yes}else{no}]"));
 }