public void ValidatePhoneFormatIsValid()
        {
            // Valid Format: 083 4785849
            var     phone  = "083 4874269";
            Boolean result = TeacherValidationHelper.IsValidPhoneFormat(phone);

            Assert.IsTrue(result);
        }
        public void ValidatePhoneFormatIsInvalid()
        {
            // Valid Format: 083 4759867
            var     phone  = "066 78222456";
            Boolean result = TeacherValidationHelper.IsValidPhoneFormat(phone);

            Assert.IsFalse(result);
        }
Example #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);
            }
        }