Beispiel #1
0
        public static void GetDataTypeName_and_IsValid_on_empty_custom_DataTypeAttribute_throws_exception()
        {
            var attribute = new DataTypeAttribute(string.Empty);

            Assert.Equal(DataType.Custom, attribute.DataType); // Only throw when call GetDataTypeName() or Validate()
            AssertEx.Empty(attribute.CustomDataType);          // Only throw when call GetDataTypeName() or Validate()
            Assert.Throws <InvalidOperationException>(() => attribute.GetDataTypeName());
            Assert.Throws <InvalidOperationException>(() => attribute.Validate(new object(), s_testValidationContext));
        }
        public static void Validation_throws_InvalidOperationException_for_null_or_empty_pattern()
        {
            var attribute = new RegularExpressionAttribute(null);

            Assert.Null(attribute.Pattern);
            Assert.Throws <InvalidOperationException>(
                () => attribute.Validate("Does not matter - Pattern is null", s_testValidationContext));

            attribute = new RegularExpressionAttribute(string.Empty);
            AssertEx.Empty(attribute.Pattern);
            Assert.Throws <InvalidOperationException>(
                () => attribute.Validate("Does not matter - Pattern is empty", s_testValidationContext));
        }
Beispiel #3
0
        public static void MemberNames_can_be_set_through_two_args_constructor()
        {
            var validationResult = new ValidationResult("SomeErrorMessage", null);

            AssertEx.Empty(validationResult.MemberNames);

            var memberNames = new List <string>()
            {
                "firstMember", "secondMember"
            };

            validationResult = new ValidationResult("SomeErrorMessage", memberNames);
            Assert.True(memberNames.SequenceEqual(validationResult.MemberNames));
        }
Beispiel #4
0
        public static void MemberNames_are_empty_for_one_arg_constructor()
        {
            var validationResult = new ValidationResult("SomeErrorMessage");

            AssertEx.Empty(validationResult.MemberNames);
        }