public void Init()
		{
			Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

			// Integer validation
			validatorIntLow = new RangeValidator(0, int.MaxValue);
			validatorIntLow.Initialize(new CachedValidationRegistry(), typeof(TestTargetInt).GetProperty("TargetField"));

			validatorIntHigh = new RangeValidator(int.MinValue, 0);
			validatorIntHigh.Initialize(new CachedValidationRegistry(), typeof(TestTargetInt).GetProperty("TargetField"));

			validatorIntLowOrHigh = new RangeValidator(RangeValidationType.Integer, "-1", "1");
			validatorIntLowOrHigh.Initialize(new CachedValidationRegistry(), typeof(TestTargetInt).GetProperty("TargetField"));

			intTarget = new TestTargetInt();

			// decimal validation
			validatorDecimalLow = new RangeValidator(0, decimal.MaxValue);
			validatorDecimalLow.Initialize(new CachedValidationRegistry(), typeof(TestTargetInt).GetProperty("TargetField"));

			validatorDecimalHigh = new RangeValidator(decimal.MinValue, 0);
			validatorDecimalHigh.Initialize(new CachedValidationRegistry(), typeof(TestTargetInt).GetProperty("TargetField"));

			validatorDecimalLowOrHigh = new RangeValidator(RangeValidationType.Decimal, "-1", "1");
			validatorDecimalLowOrHigh.Initialize(new CachedValidationRegistry(), typeof(TestTargetInt).GetProperty("TargetField"));

			decimalTarget = new TestTargetDecimal();

			// DateTime validation
			validatorDateTimeLow = new RangeValidator(DateTime.Now, DateTime.MaxValue);
			validatorDateTimeLow.Initialize(new CachedValidationRegistry(), typeof(TestTargetDateTime).GetProperty("TargetField"));

			validatorDateTimeHigh = new RangeValidator(DateTime.MinValue, DateTime.Now);
			validatorDateTimeHigh.Initialize(new CachedValidationRegistry(), typeof(TestTargetDateTime).GetProperty("TargetField"));

			validatorDateTimeLowOrHigh = new RangeValidator(RangeValidationType.DateTime, "2000-01-01", "2099-12-31");
			validatorDateTimeLowOrHigh.Initialize(new CachedValidationRegistry(), typeof(TestTargetDateTime).GetProperty("TargetField"));

			dateTimeTarget = new TestTargetDateTime();

			// String validation
			validatorStringLow = new RangeValidator("bbb", String.Empty);
			validatorStringLow.Initialize(new CachedValidationRegistry(), typeof(TestTargetString).GetProperty("TargetField"));

			validatorStringHigh = new RangeValidator(String.Empty, "yyy");
			validatorStringHigh.Initialize(new CachedValidationRegistry(), typeof(TestTargetString).GetProperty("TargetField"));

			validatorStringLowOrHigh = new RangeValidator(RangeValidationType.String, 'b'.ToString(), 'y'.ToString());
			validatorStringLowOrHigh.Initialize(new CachedValidationRegistry(), typeof(TestTargetString).GetProperty("TargetField"));

			stringTarget = new TestTargetString();
		}
Ejemplo n.º 2
0
        public void Init()
        {
            Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

            // Integer validation
            validatorIntLow = new RangeValidator(0, int.MaxValue);
            validatorIntLow.Initialize(new CachedValidationRegistry(), typeof(TestTargetInt).GetProperty("TargetField"));

            validatorIntHigh = new RangeValidator(int.MinValue, 0);
            validatorIntHigh.Initialize(new CachedValidationRegistry(), typeof(TestTargetInt).GetProperty("TargetField"));

            validatorIntLowOrHigh = new RangeValidator(RangeValidationType.Integer, "-1", "1");
            validatorIntLowOrHigh.Initialize(new CachedValidationRegistry(), typeof(TestTargetInt).GetProperty("TargetField"));

            intTarget = new TestTargetInt();

            // Long validation
            validatorLongLow = new RangeValidator(0, long.MaxValue);
            validatorLongLow.Initialize(new CachedValidationRegistry(), typeof(TestTargetLong).GetProperty("TargetField"));

            validatorLongHigh = new RangeValidator(long.MinValue, 0);
            validatorLongHigh.Initialize(new CachedValidationRegistry(), typeof(TestTargetLong).GetProperty("TargetField"));

            validatorLongLowOrHigh = new RangeValidator(RangeValidationType.Long, "-1", "1");
            validatorLongLowOrHigh.Initialize(new CachedValidationRegistry(), typeof(TestTargetLong).GetProperty("TargetField"));

            longTarget = new TestTargetLong();

            // decimal validation
            validatorDecimalLow = new RangeValidator(0, decimal.MaxValue);
            validatorDecimalLow.Initialize(new CachedValidationRegistry(), typeof(TestTargetInt).GetProperty("TargetField"));

            validatorDecimalHigh = new RangeValidator(decimal.MinValue, 0);
            validatorDecimalHigh.Initialize(new CachedValidationRegistry(), typeof(TestTargetInt).GetProperty("TargetField"));

            validatorDecimalLowOrHigh = new RangeValidator(RangeValidationType.Decimal, "-1", "1");
            validatorDecimalLowOrHigh.Initialize(new CachedValidationRegistry(), typeof(TestTargetInt).GetProperty("TargetField"));

            decimalTarget = new TestTargetDecimal();

            // DateTime validation
            validatorDateTimeLow = new RangeValidator(DateTime.Now, DateTime.MaxValue);
            validatorDateTimeLow.Initialize(new CachedValidationRegistry(), typeof(TestTargetDateTime).GetProperty("TargetField"));

            validatorDateTimeHigh = new RangeValidator(DateTime.MinValue, DateTime.Now);
            validatorDateTimeHigh.Initialize(new CachedValidationRegistry(), typeof(TestTargetDateTime).GetProperty("TargetField"));

            validatorDateTimeLowOrHigh = new RangeValidator(RangeValidationType.DateTime, "2000-01-01", "2099-12-31");
            validatorDateTimeLowOrHigh.Initialize(new CachedValidationRegistry(), typeof(TestTargetDateTime).GetProperty("TargetField"));

            dateTimeTarget = new TestTargetDateTime();

            // String validation
            validatorStringLow = new RangeValidator("bbb", String.Empty);
            validatorStringLow.Initialize(new CachedValidationRegistry(), typeof(TestTargetString).GetProperty("TargetField"));

            validatorStringHigh = new RangeValidator(String.Empty, "yyy");
            validatorStringHigh.Initialize(new CachedValidationRegistry(), typeof(TestTargetString).GetProperty("TargetField"));

            validatorStringLowOrHigh = new RangeValidator(RangeValidationType.String, 'b'.ToString(), 'y'.ToString());
            validatorStringLowOrHigh.Initialize(new CachedValidationRegistry(), typeof(TestTargetString).GetProperty("TargetField"));

            stringTarget = new TestTargetString();

            // Message validation
            validatorIntMessage = new RangeValidator(0, 1)
            {
                ErrorMessage = CustomErrorMessage
            };
            validatorIntMessage.Initialize(new CachedValidationRegistry(), typeof(TestTargetInt).GetProperty("TargetField"));
        }