Exemplo n.º 1
0
        public void TestAsInvokeRegexPattern02()
        {
            var testSubject = new CgMember()
            {
                Name     = "ToString",
                TypeName = "System.String",
                IsMethod = true
            };

            var testResult = testSubject.AsInvokeRegexPattern();

            var testCompare =
                "command.Parameters.Add(new SqlParameter(\"@createUser\", Convert.ToString(Session[SessionContants.LoggedInEntityId])));";

            Assert.IsFalse(System.Text.RegularExpressions.Regex.IsMatch(testCompare, testResult));
            Console.WriteLine(testResult);

            testCompare = "somethingElse.InvokeMe(4,true,\"sd\");var mysomething=ToString()";
            Assert.IsTrue(System.Text.RegularExpressions.Regex.IsMatch(testCompare, testResult));
        }
Exemplo n.º 2
0
        public void TestAsInvokeRegexPattern02()
        {
            var testSubject = new CgMember()
            {
                Name = "ToString",
                TypeName = "System.String",
                IsMethod = true
            };

            var testResult = testSubject.AsInvokeRegexPattern();

            var testCompare =
                "command.Parameters.Add(new SqlParameter(\"@createUser\", Convert.ToString(Session[SessionContants.LoggedInEntityId])));";
            Assert.IsFalse(System.Text.RegularExpressions.Regex.IsMatch(testCompare, testResult));
            System.Diagnostics.Debug.WriteLine(testResult);

            testCompare = "somethingElse.InvokeMe(4,true,\"sd\");var mysomething=ToString()";
            Assert.IsTrue(System.Text.RegularExpressions.Regex.IsMatch(testCompare, testResult));
        }
Exemplo n.º 3
0
        public void TestAsInvokeRegexPattern()
        {
            var testSubject = new CgMember()
            {
                Args =
                    new List <CgArg>
                {
                    new CgArg {
                        ArgName = "param1", ArgType = "int"
                    },
                    new CgArg {
                        ArgName = "param2", ArgType = "string"
                    },
                    new CgArg {
                        ArgName = "param3", ArgType = "bool"
                    }
                },
                Name     = "MyMethodName",
                TypeName = "System.String"
            };
            var testResult = testSubject.AsInvokeRegexPattern();

            Assert.IsNotNull(testResult);
            Assert.AreNotEqual(string.Empty, testResult);
            Assert.AreNotEqual(".", testResult);
            Console.WriteLine(testResult);
            Assert.IsTrue(System.Text.RegularExpressions.Regex.IsMatch("MyMethodName(11,\"a string literal\",true)", testResult));

            testSubject.IsStatic = true;
            testSubject.MyCgType = new CgType {
                Namespace = "NoFuture.TestNs", Name = "Something"
            };
            testSubject.IsGeneric = true;
            testResult            = testSubject.AsInvokeRegexPattern();
            Console.WriteLine(testResult);
            Assert.IsNotNull(testResult);

            testSubject.IsStatic = false;
            testResult           = testSubject.AsInvokeRegexPattern("myVar", "myVar.ItsTypes.Types.Type");
            Console.WriteLine(testResult);
            Assert.IsNotNull(testResult);

            testSubject.MyCgType.IsEnum = true;
            testSubject.IsGeneric       = false;
            testSubject.Name            = "MyEnum";
            testSubject.MyCgType.EnumValueDictionary.Add("MyType", new[] { "Instance", "NonPublic", "Public", "DeclaredOnly" });
            testResult = testSubject.AsInvokeRegexPattern();
            Console.WriteLine(testResult);
            Assert.IsNotNull(testResult);

            testSubject = new CgMember()
            {
                Name     = "MyPropertyName",
                TypeName = "System.String"
            };

            testResult = testSubject.AsInvokeRegexPattern();
            Assert.IsNotNull(testResult);
            Assert.AreNotEqual(string.Empty, testResult);
            Assert.AreNotEqual(".", testResult);
            Console.WriteLine(testResult);
        }
Exemplo n.º 4
0
        public void TestAsInvokeRegexPattern()
        {
            var testSubject = new CgMember()
            {
                Args =
                    new List<CgArg>
                    {
                        new CgArg {ArgName = "param1", ArgType = "int"},
                        new CgArg {ArgName = "param2", ArgType = "string"},
                        new CgArg {ArgName = "param3", ArgType = "bool"}
                    },
                Name = "MyMethodName",
                TypeName = "System.String"
            };
            var testResult = testSubject.AsInvokeRegexPattern();
            Assert.IsNotNull(testResult);
            Assert.AreNotEqual(string.Empty, testResult);
            Assert.AreNotEqual(".",testResult);
            System.Diagnostics.Debug.WriteLine(testResult);
            Assert.IsTrue(System.Text.RegularExpressions.Regex.IsMatch("MyMethodName(11,\"a string literal\",true)",testResult));

            testSubject.IsStatic = true;
            testSubject.MyCgType = new CgType {Namespace = "NoFuture.TestNs", Name = "Something"};
            testSubject.IsGeneric = true;
            testResult = testSubject.AsInvokeRegexPattern();
            System.Diagnostics.Debug.WriteLine(testResult);
            Assert.IsNotNull(testResult);

            testSubject.IsStatic = false;
            testResult = testSubject.AsInvokeRegexPattern("myVar", "myVar.ItsTypes.Types.Type");
            System.Diagnostics.Debug.WriteLine(testResult);
            Assert.IsNotNull(testResult);

            testSubject.MyCgType.IsEnum = true;
            testSubject.IsGeneric = false;
            testSubject.Name = "MyEnum";
            testSubject.MyCgType.EnumValueDictionary.Add("MyType", new[] { "Instance", "NonPublic", "Public", "DeclaredOnly" });
            testResult = testSubject.AsInvokeRegexPattern();
            System.Diagnostics.Debug.WriteLine(testResult);
            Assert.IsNotNull(testResult);

            testSubject = new CgMember()
            {
                Name = "MyPropertyName",
                TypeName = "System.String"
            };

            testResult = testSubject.AsInvokeRegexPattern();
            Assert.IsNotNull(testResult);
            Assert.AreNotEqual(string.Empty, testResult);
            Assert.AreNotEqual(".", testResult);
            System.Diagnostics.Debug.WriteLine(testResult);
        }