コード例 #1
0
        public void CustomValidatorAttribute_Ctor()
        {
            CustomPropertyValidatorAttribute attrib = new CustomPropertyValidatorAttribute(typeof(TestConfigurationValidator));

            Assert.Same(typeof(TestConfigurationValidator), attrib.ValidatorType);
            Assert.IsType <TestConfigurationValidator>(attrib.Validator);
        }
コード例 #2
0
        public void CustomPropertyValidatorAttribute_Ctor_ParameterlessCtor()
        {
            CustomPropertyValidatorAttribute attrib = new CustomPropertyValidatorAttribute(typeof(CustomValidator));

            Assert.Equal(typeof(CustomValidator), attrib.ValidatorType);
            Assert.IsType <CustomValidator>(attrib.Validator);
            Assert.Empty(attrib.ValidatorConstructorArguments);
        }
コード例 #3
0
        public void CustomPropertyValidatorAttribute_Ctor_ParameterizedCtor()
        {
            CustomPropertyValidatorAttribute attrib =
                new CustomPropertyValidatorAttribute(typeof(CustomValidator2), 1, "test");

            Assert.Equal(typeof(CustomValidator2), attrib.ValidatorType);
            Assert.IsType <CustomValidator2>(attrib.Validator);
            Assert.Equal(new object[] { 1, "test" }, attrib.ValidatorConstructorArguments);
        }
コード例 #4
0
        public void CustomPropertyValidatorAttribute_Validator_ExceptionOnValidatorCtor()
        {
            CustomPropertyValidatorAttribute attrib = new CustomPropertyValidatorAttribute(typeof(CustomValidator3));

            Assert.Throws <FormatException>(() => { object x = attrib.Validator; });
        }