Exemple #1
0
        public void TestSubjectFieldOfCode_ForeignFieldOfStudyExceedsMaxLength()
        {
            string subjectFieldCode          = "00.0000";
            string remarks                   = "remarks";
            string degreeLevel               = "level";
            string foreignFieldOfStudy       = "foreign";
            Func <SubjectField> createEntity = () =>
            {
                return(new SubjectField(subjectFieldCode: subjectFieldCode, foreignDegreeLevel: degreeLevel, foreignFieldOfStudy: foreignFieldOfStudy, remarks: remarks));
            };
            var instance = createEntity();

            Assert.IsFalse(String.IsNullOrWhiteSpace(degreeLevel));
            var validator = new SubjectFieldValidator();
            var results   = validator.Validate(instance);

            Assert.IsTrue(results.IsValid);

            foreignFieldOfStudy = new string('c', SubjectFieldValidator.FOREIGN_FIELD_MAX_LENGTH + 1);
            instance            = createEntity();
            results             = validator.Validate(instance);
            Assert.IsFalse(results.IsValid);
            Assert.AreEqual(1, results.Errors.Count);
            Assert.AreEqual(SubjectFieldValidator.SUBJECT_FIELD_OF_STUDY_MAX_LENGTH_ERROR_MESSAGE, results.Errors.First().ErrorMessage);
            Assert.IsInstanceOfType(results.Errors.First().CustomState, typeof(FieldOfStudyErrorPath));
        }
Exemple #2
0
        public void TestSubjectFieldOfCode_MissingDecimal()
        {
            string subjectFieldCode          = "00.0000";
            string remarks                   = "remarks";
            string degreeLevel               = "level";
            string foreignFieldOfStudy       = "foreign";
            Func <SubjectField> createEntity = () =>
            {
                return(new SubjectField(subjectFieldCode: subjectFieldCode, foreignDegreeLevel: degreeLevel, foreignFieldOfStudy: foreignFieldOfStudy, remarks: remarks));
            };

            var instance  = createEntity();
            var validator = new SubjectFieldValidator();
            var results   = validator.Validate(instance);

            Assert.IsTrue(results.IsValid);

            subjectFieldCode = "000000";
            instance         = createEntity();
            results          = validator.Validate(instance);
            Assert.IsFalse(results.IsValid);
            Assert.AreEqual(1, results.Errors.Count);
            Assert.AreEqual(SubjectFieldValidator.SUBJECT_FIELD_CODE_OF_STUDY_ERROR_MESSAGE, results.Errors.First().ErrorMessage);
            Assert.IsInstanceOfType(results.Errors.First().CustomState, typeof(FieldOfStudyErrorPath));
        }
Exemple #3
0
        public void TestSubjectFieldOfCode_ForeignFieldOfStudyIsWhitesppace()
        {
            string subjectFieldCode          = "00.0000";
            string remarks                   = "remarks";
            string degreeLevel               = "level";
            string foreignFieldOfStudy       = "foreign";
            Func <SubjectField> createEntity = () =>
            {
                return(new SubjectField(subjectFieldCode: subjectFieldCode, foreignDegreeLevel: degreeLevel, foreignFieldOfStudy: foreignFieldOfStudy, remarks: remarks));
            };
            var instance = createEntity();

            Assert.IsFalse(String.IsNullOrWhiteSpace(foreignFieldOfStudy));
            var validator = new SubjectFieldValidator();
            var results   = validator.Validate(instance);

            Assert.IsTrue(results.IsValid);

            foreignFieldOfStudy = " ";
            instance            = createEntity();
            results             = validator.Validate(instance);
            Assert.IsTrue(results.IsValid);
        }