Example #1
0
        public void IsValid_WhenPurpose_IsNotInvalid(EmailVerificationPurpose purpose)
        {
            var command = new FakeMustBeValidVerifyEmailPurposeCommand {
                Purpose = purpose
            };
            var validator = new FakeMustBeValidVerifyEmailPurposeValidator();

            var result = validator.Validate(command);

            result.IsValid.ShouldBeTrue();
            validator.ShouldNotHaveValidationErrorFor(x => x.Purpose, command.Purpose);
        }
Example #2
0
        public void IsInvalid_WhenPurpose_IsInvalid()
        {
            var command = new FakeMustBeValidVerifyEmailPurposeCommand {
                Purpose = EmailVerificationPurpose.Invalid
            };
            var validator = new FakeMustBeValidVerifyEmailPurposeValidator();

            var result = validator.Validate(command);

            result.IsValid.ShouldBeFalse();
            Func <ValidationFailure, bool> expectedError = x => x.PropertyName == command.PropertyName(y => y.Purpose);

            result.Errors.Count(expectedError).ShouldEqual(1);
            result.Errors.Single(expectedError).ErrorMessage.ShouldEqual(Resources
                                                                         .Validation_EmailVerificationPurpose_IsEmpty
                                                                         .Replace("{PropertyName}", EmailVerification.Constraints.Label.ToLower())
                                                                         );
            validator.ShouldHaveValidationErrorFor(x => x.Purpose, command.Purpose);
        }