Esempio n. 1
0
File: Tests.cs Progetto: serra/CLAP
        public void Validation_RegexMatchesEmail()
        {
            var sample = new ValidationSample_01();

            Parser.Run(new[]
            {
                "regexmatchesemail",
                "/[email protected]",
            }, sample);

            Parser.Run(new[]
            {
                "regexmatchesemail",
                "/[email protected]",
            }, sample);

            Expect(() => Parser.Run(new[]
                                        {
                                            "regexmatchesemail",
                                            "/text=no_email",
                                        }, sample),
                   Throws.InstanceOf<ValidationException>());
        }
Esempio n. 2
0
File: Tests.cs Progetto: serra/CLAP
        public void Execute_HandleError_Registered_ValidationError()
        {
            var sample = new ValidationSample_01();

            var p = new Parser<ValidationSample_01>();
            var handled = false;

            p.Register.ErrorHandler(ex =>
            {
                handled = true;
            });

            p.Run(new[] { "morethan5", "/n=1" }, sample);

            Expect(handled, Is.True);
        }
Esempio n. 3
0
File: Tests.cs Progetto: serra/CLAP
        public void Validation_MoreThan()
        {
            var sample = new ValidationSample_01();
            Parser.Run(new[]
            {
                "morethan5",
                "/n=10",
            }, sample);

            Expect(() => Parser.Run(new[]
                                  {
                                      "morethan5",
                                      "/n=1",
                                  }, sample),
                   Throws.InstanceOf<ValidationException>());
        }
Esempio n. 4
0
File: Tests.cs Progetto: serra/CLAP
        public void Validation_PathExists()
        {
            var sample = new ValidationSample_01();

            Parser.Run(new[] { "pathexists", @"/path=c:\windows\system32" }, sample);
            Parser.Run(new[] { "pathexists", @"/path=%WINDIR%\system32" }, sample);
            Parser.Run(new[] { "pathexists", @"/path=c:\windows\system32\cmd.exe" }, sample);
            Parser.Run(new[] { "pathexists", @"/path=%WINDIR%\system32\cmd.exe" }, sample);

            Parser.Run(new[] { "uripathexists", @"/path=c:\windows\system32\cmd.exe" }, sample);
            Parser.Run(new[] { "uripathexists", @"/path=%WINDIR%\system32\cmd.exe" }, sample);
            Parser.Run(new[] { "uripathexists", @"/path=c:\windows\system32" }, sample);
            Parser.Run(new[] { "uripathexists", @"/path=%WINDIR%\system32" }, sample);

            Expect(() => Parser.Run(new[]
                                        {
                                            "pathexists",
                                            @"/path=y:\{B2C97314-4C55-4EB9-9049-63BB65AC980A}.{6E8698D0-4CFA-4ACB-8AA3-26476F490228}"
                                            ,
                                        }, sample),
                   Throws.InstanceOf<ValidationException>());

            Expect(() => Parser.Run(new[]
                                        {
                                            "uripathexists",
                                            @"/path=y:\{B2C97314-4C55-4EB9-9049-63BB65AC980A}.{6E8698D0-4CFA-4ACB-8AA3-26476F490228}"
                                            ,
                                        }, sample),
                   Throws.InstanceOf<ValidationException>());
        }
Esempio n. 5
0
File: Tests.cs Progetto: serra/CLAP
        public void Validation_LessThan()
        {
            var sample = new ValidationSample_01();

            Parser.Run(new[]
            {
                "lessthan20",
                "/n=10",
            }, sample);

            Expect(() => Parser.Run(new[]
                                        {
                                            "lessthan20",
                                            "/n=20",
                                        }, sample),
                   Throws.InstanceOf<ValidationException>());
        }
Esempio n. 6
0
File: Tests.cs Progetto: serra/CLAP
        public void Validation_MoreOrEqualTo()
        {
            var sample = new ValidationSample_01();

            Parser.Run(new[]
            {
                "moreorequalto10",
                "/n=10",
            }, sample);

            Parser.Run(new[]
            {
                "moreorequalto10",
                "/n=11",
            }, sample);

            Expect(() => Parser.Run(new[]
                                        {
                                            "moreorequalto10",
                                            "/n=9",
                                        }, sample),
                   Throws.InstanceOf<ValidationException>());
        }
Esempio n. 7
0
File: Tests.cs Progetto: kurtaj/CLAP
        public void Validation_RegexMatchesEmail()
        {
            var sample = new ValidationSample_01();

            Parser.Run(new[]
            {
                "regexmatchesemail",
                "/[email protected]",
            }, sample);

            Parser.Run(new[]
            {
                "regexmatchesemail",
                "/[email protected]",
            }, sample);

            try
            {
                Parser.Run(new[]
                {
                    "regexmatchesemail",
                    "/text=no_email",
                }, sample);

                Assert.Fail();
            }
            catch (ValidationException)
            {
            }
        }
Esempio n. 8
0
File: Tests.cs Progetto: serra/CLAP
        public void Validation_LessOrEqualTo()
        {
            var sample = new ValidationSample_01();

            Parser.Run(new[]
            {
                "lessorequalto30",
                "/n=10",
            }, sample);

            Parser.Run(new[]
            {
                "lessorequalto30",
                "/n=30",
            }, sample);

            Expect(() => Parser.Run(new[]
                                        {
                                            "lessorequalto30",
                                            "/n=40",
                                        }, sample),
                   Throws.InstanceOf<ValidationException>());
        }
Esempio n. 9
0
File: Tests.cs Progetto: kurtaj/CLAP
        public void Validation_PathExists()
        {
            var sample = new ValidationSample_01();

            Parser.Run(new[] { "pathexists", @"/path=c:\windows\system32" }, sample);
            Parser.Run(new[] { "pathexists", @"/path=%WINDIR%\system32" }, sample);
            Parser.Run(new[] { "pathexists", @"/path=c:\windows\system32\cmd.exe" }, sample);
            Parser.Run(new[] { "pathexists", @"/path=%WINDIR%\system32\cmd.exe" }, sample);

            Parser.Run(new[] { "uripathexists", @"/path=c:\windows\system32\cmd.exe" }, sample);
            Parser.Run(new[] { "uripathexists", @"/path=%WINDIR%\system32\cmd.exe" }, sample);
            Parser.Run(new[] { "uripathexists", @"/path=c:\windows\system32" }, sample);
            Parser.Run(new[] { "uripathexists", @"/path=%WINDIR%\system32" }, sample);

            try
            {
                Parser.Run(new[]
                {
                    "pathexists",
                    @"/path=y:\{B2C97314-4C55-4EB9-9049-63BB65AC980A}.{6E8698D0-4CFA-4ACB-8AA3-26476F490228}",
                }, sample);

                Assert.Fail();
            }
            catch (ValidationException)
            {
            }

            try
            {
                Parser.Run(new[]
                {
                    "uripathexists",
                    @"/path=y:\{B2C97314-4C55-4EB9-9049-63BB65AC980A}.{6E8698D0-4CFA-4ACB-8AA3-26476F490228}",
                }, sample);

                Assert.Fail();
            }
            catch (ValidationException)
            {
            }
        }
Esempio n. 10
0
File: Tests.cs Progetto: kurtaj/CLAP
        public void Validation_MoreThan()
        {
            var sample = new ValidationSample_01();
            Parser.Run(new[]
            {
                "morethan5",
                "/n=10",
            }, sample);

            try
            {
                Parser.Run(new[]
                {
                    "morethan5",
                    "/n=1",
                }, sample);

                Assert.Fail();
            }
            catch (ValidationException)
            {
            }
        }
Esempio n. 11
0
File: Tests.cs Progetto: kurtaj/CLAP
        public void Validation_MoreOrEqualTo()
        {
            var sample = new ValidationSample_01();

            Parser.Run(new[]
            {
                "moreorequalto10",
                "/n=10",
            }, sample);

            Parser.Run(new[]
            {
                "moreorequalto10",
                "/n=11",
            }, sample);

            try
            {
                Parser.Run(new[]
                {
                    "moreorequalto10",
                    "/n=9",
                }, sample);

                Assert.Fail();
            }
            catch (ValidationException)
            {
            }
        }
Esempio n. 12
0
File: Tests.cs Progetto: kurtaj/CLAP
        public void Validation_LessThan()
        {
            var sample = new ValidationSample_01();

            Parser.Run(new[]
            {
                "lessthan20",
                "/n=10",
            }, sample);

            try
            {
                Parser.Run(new[]
                {
                    "lessthan20",
                    "/n=20",
                }, sample);

                Assert.Fail();
            }
            catch (ValidationException)
            {
            }
        }
Esempio n. 13
0
File: Tests.cs Progetto: kurtaj/CLAP
        public void Validation_LessOrEqualTo()
        {
            var sample = new ValidationSample_01();

            Parser.Run(new[]
            {
                "lessorequalto30",
                "/n=10",
            }, sample);

            Parser.Run(new[]
            {
                "lessorequalto30",
                "/n=30",
            }, sample);

            try
            {
                Parser.Run(new[]
                {
                    "lessorequalto30",
                    "/n=40",
                }, sample);

                Assert.Fail();
            }
            catch (ValidationException)
            {
            }
        }