Ejemplo n.º 1
0
        public void DriverExperienceValidation_NegativeNumbers_ExpectedFail(int testValue)
        {
            // Arrange
            bool result = true;

            // Act
            result = DriverValidation.DriverExperienceValidation(testValue);

            // Assert
            Assert.False(result);
        }
Ejemplo n.º 2
0
        public void DriverExperienceValidation_ValidYearsOfExperience_ExpectedSuccess(int testValue)
        {
            // Arrange
            bool result = true;

            // Act
            result = DriverValidation.DriverExperienceValidation(testValue);

            // Assert
            Assert.True(result);
        }
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (Experience.HasValue)
            {
                var validExperience = DriverValidation.DriverExperienceValidation(Experience.Value);

                if (validExperience == false)
                {
                    yield return(new ValidationResult("Invalid years of experience",
                                                      new[] { nameof(Experience) }));
                }
            }

            yield return(ValidationResult.Success);
        }