Esempio n. 1
0
        public void Validate_Inclusive()
        {
            TimeSpanValidator v = new TimeSpanValidator(new TimeSpan(5000), new TimeSpan(10000), false);

            v.Validate(new TimeSpan(5000));
            v.Validate(new TimeSpan(10000));
        }
Esempio n. 2
0
        public void Validate_Exclusive()
        {
            TimeSpanValidator v = new TimeSpanValidator(new TimeSpan(5000), new TimeSpan(10000), true);

            v.Validate(new TimeSpan(1000));
            v.Validate(new TimeSpan(15000));
        }
        static void Main(string[] args)
        {
            // Display title.
            Console.WriteLine("ASP.NET Validators");
            Console.WriteLine();

            // Create TimeSpan and Validator.
            TimeSpan          testTimeSpan        = new TimeSpan(0, 1, 05);
            TimeSpan          minTimeSpan         = new TimeSpan(0, 1, 0);
            TimeSpan          maxTimeSpan         = new TimeSpan(0, 1, 10);
            TimeSpanValidator myTimeSpanValidator = new TimeSpanValidator(minTimeSpan, maxTimeSpan, false, 65);

            // Determine if the object to validate can be validated.
            Console.WriteLine("CanValidate: {0}",
                              myTimeSpanValidator.CanValidate(testTimeSpan.GetType()));

            try
            {
                // Attempt validation.
                myTimeSpanValidator.Validate(testTimeSpan);
                Console.WriteLine("Validated.");
            }
            catch (ArgumentException e)
            {
                // Validation failed.
                Console.WriteLine("Error: {0}", e.Message.ToString());
            }

            // Display and wait
            Console.ReadLine();
        }
Esempio n. 4
0
        public void Validate_Resolution()
        {
            TimeSpanValidator v = new TimeSpanValidator(new TimeSpan(20000),
                                                        new TimeSpan(50000),
                                                        false,
                                                        2);

            AssertExtensions.Throws <ArgumentException>(null, () => v.Validate(TimeSpan.FromTicks(40000)));
        }
Esempio n. 5
0
        public void Validate_Resolution()
        {
            TimeSpanValidator v = new TimeSpanValidator(new TimeSpan(20000),
                                                        new TimeSpan(50000),
                                                        false,
                                                        2);

            v.Validate(TimeSpan.FromTicks(40000));
        }
Esempio n. 6
0
        public void Validate_Exclusive_fail3()
        {
            TimeSpanValidator v = new TimeSpanValidator(new TimeSpan(5000), new TimeSpan(10000), true);

            AssertExtensions.Throws <ArgumentException>(null, () => v.Validate(new TimeSpan(7000)));
        }
Esempio n. 7
0
        public void Validate_inRange()
        {
            TimeSpanValidator v = new TimeSpanValidator(new TimeSpan(5000), new TimeSpan(10000));

            v.Validate(new TimeSpan(7000));
        }
Esempio n. 8
0
        public void Validate_Exclusive_fail2()
        {
            TimeSpanValidator v = new TimeSpanValidator(new TimeSpan(5000), new TimeSpan(10000), true);

            Assert.Throws <ArgumentException>(() => v.Validate(new TimeSpan(10000)));
        }