public void ValidateTeacherSurnameIsInvalid()
        {
            var     surname = "John O'@";
            Boolean result  = TeacherValidationHelper.IsValidNameFormat(surname);

            Assert.IsFalse(result);
        }
        public void ValidateTeacherForenameInvalid()
        {
            var     forename = "O- Sullivan";
            Boolean result   = TeacherValidationHelper.IsValidNameFormat(forename);

            Assert.IsFalse(result);
        }
示例#3
0
        public override void ValidateProperty(string propertyName)
        {
            string error = "";

            switch (propertyName)
            {
            case "Surname":
                if (!TeacherValidationHelper.IsValidNameFormat(Surname))
                {
                    error = TeacherValidationHelper.ERROR_SURNAME_FORMAT;
                }
                break;

            case "Forename":
                if (!TeacherValidationHelper.IsValidNameFormat(Forename))
                {
                    error = TeacherValidationHelper.ERROR_FORNAME_FORMAT;
                }
                break;

            case "DOB":
                if (DOB == DateTime.Today)
                {
                    error = TeacherValidationHelper.ERROR_EMPTY_STRING;
                }
                else if (DOB > DateTime.Today)
                {
                    error = TeacherValidationHelper.ERROR_AGE_NOTFUTURE;
                }
                else if (!TeacherValidationHelper.IsOverAgeTwentyOne(DOB))
                {
                    error = TeacherValidationHelper.ERROR_AGE_NOTOVERAGE;
                }
                break;

            case "Phone":
                if (!TeacherValidationHelper.IsValidPhoneFormat(Phone))
                {
                    error = TeacherValidationHelper.ERROR_PHONE_FORMAT;
                }
                break;

            case "Type":
                if (Type == ' ')
                {
                    error = TeacherValidationHelper.ERROR_EMPTY_STRING;
                }
                break;

            case "Subjects":
                if (String.IsNullOrEmpty(Subjects))
                {
                    error = TeacherValidationHelper.ERROR_EMPTY_STRING;
                }
                break;
            }

            if (error != "")
            {
                AddErrors(propertyName, error);
            }
            else
            {
                RemoveErrors(propertyName);
            }
        }