Example #1
0
        public CourseType Update(CourseType courseType)
        {
            if (!courseType.IsValid())
            {
                return(courseType);
            }

            return(courseTypeRepository.Update(courseType));
        }
Example #2
0
        public void CourseType_SelfValidation_IsValid()
        {
            // Arrange
            var courseType = new CourseType()
            {
                Id             = Guid.NewGuid(),
                Identification = "Programação I",
                Active         = true
            };

            // Act
            var result = courseType.IsValid();

            // Assert
            Assert.IsTrue(result);
        }
Example #3
0
        public CourseType Add(CourseType courseType)
        {
            if (!courseType.IsValid())
            {
                return(courseType);
            }

            courseType.ValidationResult = new CourseTypeIsConsistentValidation().Validate(courseType);

            if (!courseType.ValidationResult.IsValid)
            {
                return(courseType);
            }

            return(courseTypeRepository.Add(courseType));
        }
Example #4
0
        public void CourseType_SelValidation_IsNotValid()
        {
            // Arrange
            var courseType = new CourseType()
            {
                Id             = Guid.NewGuid(),
                Identification = "PI",
                Active         = true
            };

            // Act
            var result = courseType.IsValid();

            // Assert
            Assert.IsFalse(result);
            Assert.IsTrue(courseType.ValidationResult.Erros.Any(ct => ct.Message == "A identificação do Tipo de Curso deve conter no mínimo 3 caracteres."));
        }