Ejemplo n.º 1
0
        public void WhenTheEmailIsRequiredButAnswerIsEmpty__ThenCorrectErrorMessageIsReturned(string email)
        {
            // arrange
            var answerItem = AnswerBuilder.Build.WithDefaultValue(email).AnAnswer();
            var properties = new EmailValidationProperties();

            TestService      = new EmailValidation(properties);
            InFlightQuestion = new InFlightQuestion
            {
                Answer = answerItem
            };

            // act
            var result = Act();

            // assert
            Assert.False(result.IsValid);
            Assert.Equal(properties.MissingEmailValidationMessage, result.Errors.First().ErrorMessage);
        }
Ejemplo n.º 2
0
        public void WhenTheEmailIsLongerThanTheMaxLimit__ThenCorrectErrorMessageIsReturned()
        {
            // arrange
            var maxLength  = 100;
            var properties = new EmailValidationProperties
            {
                MaxLength = maxLength
            };

            var answerItem = AnswerBuilder.Build.WithDefaultValue(new string('a', maxLength + 1) + "@example.com").AnAnswer();

            TestService      = new EmailValidation(properties);
            InFlightQuestion = new InFlightQuestion
            {
                Answer = answerItem
            };

            // act
            var result = Act();

            // assert
            Assert.False(result.IsValid);
            Assert.Equal($"Email must be {maxLength} characters or fewer", result.Errors.First().ErrorMessage);
        }