예제 #1
0
        public static void Validation_valid_country_iso(string iso)
        {
            //Countries.Initialize();
            var attribute = new ValidateCountryIsoAttribute
            {
                AllowEmptyStrings = true
            };

            attribute.Validate(iso, s_testValidationContext);
        }
예제 #2
0
        public static void Validation_throws_ValidationException_for_inavlid_country_iso(string iso)
        {
            //Countries.Initialize();
            var attribute = new ValidateCountryIsoAttribute
            {
                AllowEmptyStrings = true
            };

            Assert.Throws <ValidationException>(() => attribute.Validate(iso, s_testValidationContext));
        }
예제 #3
0
        public static void Validation_throws_ValidationException_for_empty_string_if_AllowEmptyStrings_is_false()
        {
            //Countries.Initialize();
            var attribute = new ValidateCountryIsoAttribute
            {
                AllowEmptyStrings = false
            };

            Assert.Throws <ValidationException>(() => attribute.Validate(string.Empty, s_testValidationContext));
        }
예제 #4
0
        public static void Validation_ErrorMessage()
        {
            //Countries.Initialize();
            var attribute = new ValidateCountryIsoAttribute();

            Assert.False(attribute.IsValid("INVALID"));
            var t = attribute.FormatErrorMessage("ISO");

            Assert.NotEmpty(t);
        }
예제 #5
0
        public static void IsValid(string iso, bool result)
        {
            //Countries.Initialize();
            var attribute = new ValidateCountryIsoAttribute
            {
                AllowEmptyStrings = true
            };

            Assert.Equal(result, attribute.IsValid(iso));
        }
예제 #6
0
        public static void Can_get_and_set_AllowEmptyStrings()
        {
            var attribute = new ValidateCountryIsoAttribute();

            Assert.False(attribute.AllowEmptyStrings);
            attribute.AllowEmptyStrings = true;
            Assert.True(attribute.AllowEmptyStrings);
            attribute.AllowEmptyStrings = false;
            Assert.False(attribute.AllowEmptyStrings);
        }
예제 #7
0
        public static void Validation_valid_for_empty_string_if_AllowEmptyStrings_is_true()
        {
            //Countries.Initialize();
            var attribute = new ValidateCountryIsoAttribute
            {
                AllowEmptyStrings = true
            };

            attribute.Validate(string.Empty, s_testValidationContext);
        }
예제 #8
0
        public static void Validation_throws_ValidationException_for_null_value()
        {
            var attribute = new ValidateCountryIsoAttribute();

            Assert.Throws <ValidationException>(() => attribute.Validate(null, s_testValidationContext));
        }