Inheritance: ConfigurationValidatorBase
示例#1
0
		public void CanValidate ()
		{
			IntegerValidator v = new IntegerValidator (1, 1);

			Assert.IsFalse (v.CanValidate (typeof (TimeSpan)), "A1");
			Assert.IsTrue (v.CanValidate (typeof (int)), "A2");
			Assert.IsFalse (v.CanValidate (typeof (long)), "A3");
		}
示例#2
0
		static BufferModeSettings ()
		{
			IntegerValidator iv = new IntegerValidator (1, Int32.MaxValue);
			
			maxBufferSizeProp = new ConfigurationProperty ("maxBufferSize", typeof (int), Int32.MaxValue,
								       PropertyHelper.InfiniteIntConverter, iv,
								       ConfigurationPropertyOptions.IsRequired);
			maxBufferThreadsProp = new ConfigurationProperty ("maxBufferThreads", typeof (int), 1,
									  PropertyHelper.InfiniteIntConverter, iv,
									  ConfigurationPropertyOptions.None);
			maxFlushSizeProp = new ConfigurationProperty ("maxFlushSize", typeof (int), Int32.MaxValue,
								      PropertyHelper.InfiniteIntConverter, iv,
								      ConfigurationPropertyOptions.IsRequired);
			nameProp = new ConfigurationProperty ("name", typeof (string), "",
							      TypeDescriptor.GetConverter (typeof (string)), PropertyHelper.NonEmptyStringValidator,
							      ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
			regularFlushIntervalProp = new ConfigurationProperty ("regularFlushInterval", typeof (TimeSpan), TimeSpan.FromSeconds (1),
									      PropertyHelper.InfiniteTimeSpanConverter,
									      PropertyHelper.PositiveTimeSpanValidator,
									      ConfigurationPropertyOptions.IsRequired);
			urgentFlushIntervalProp = new ConfigurationProperty ("urgentFlushInterval", typeof (TimeSpan), TimeSpan.FromSeconds (0),
									     PropertyHelper.InfiniteTimeSpanConverter, null,
									     ConfigurationPropertyOptions.IsRequired);
			urgentFlushThresholdProp = new ConfigurationProperty ("urgentFlushThreshold", typeof (int), Int32.MaxValue,
									      PropertyHelper.InfiniteIntConverter, iv,
									      ConfigurationPropertyOptions.IsRequired);
			properties = new ConfigurationPropertyCollection ();

			properties.Add (nameProp);
			properties.Add (maxBufferSizeProp);
			properties.Add (maxBufferThreadsProp);
			properties.Add (maxFlushSizeProp);
			properties.Add (regularFlushIntervalProp);
			properties.Add (urgentFlushIntervalProp);
			properties.Add (urgentFlushThresholdProp);

			elementProperty = new ConfigurationElementProperty (new CallbackValidator (typeof (BufferModeSettings), ValidateElement));
		}
示例#3
0
		public void Validate_Exclusive_fail3 ()
		{
			IntegerValidator v = new IntegerValidator (5000, 10000, true);
			v.Validate (7000);
		}
示例#4
0
		public void Validate_Inclusive ()
		{
			IntegerValidator v = new IntegerValidator (5000, 10000, false);
			v.Validate (5000);
			v.Validate (10000);
		}
示例#5
0
		public void Validate_inRange ()
		{
			IntegerValidator v = new IntegerValidator (5000, 10000);
			v.Validate (7000);
		}
示例#6
0
		public void Validate_Resolution ()
		{
			IntegerValidator v = new IntegerValidator (20000,
								   50000,
								   false,
								   3000);

			v.Validate (40000);
		}