Beispiel #1
0
        public void Should_have_validation_error_when_email_is_not_valid()
        {
            var command = Fixture.Build <CreateUser>().With(x => x.Email, "email").Create();

            var userRules = new Mock <IUserRules>();

            var sut = new CreateUserValidator(userRules.Object);

            sut.ShouldHaveValidationErrorFor(x => x.Email, command);
        }
Beispiel #2
0
        public void Should_have_validation_error_when_user_id_is_empty()
        {
            var command = Fixture.Build <CreateUser>().With(x => x.IdentityUserId, string.Empty).Create();

            var userRules = new Mock <IUserRules>();

            var sut = new CreateUserValidator(userRules.Object);

            sut.ShouldHaveValidationErrorFor(x => x.IdentityUserId, command);
        }
        public void Should_have_error_when_user_email_is_empty()
        {
            var command = new CreateUser
            {
                Id       = Guid.NewGuid(),
                Email    = "",
                UserName = "******"
            };

            var userRules = new Mock <IUserRules>();
            var validator = new CreateUserValidator(userRules.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Email, command);
        }
        public void Should_have_error_when_user_email_already_exists()
        {
            var command = new CreateUser
            {
                Id       = Guid.NewGuid(),
                Email    = "*****@*****.**",
                UserName = "******"
            };

            var userRules = new Mock <IUserRules>();

            userRules.Setup(x => x.IsUserEmailUnique(command.Email, new Guid())).Returns(false);

            var validator = new CreateUserValidator(userRules.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Email, command);
        }
        public void Should_have_error_when_user_email_is_too_long()
        {
            var email = "";

            for (int i = 0; i < 251; i++)
            {
                email += i;
            }

            var command = new CreateUser
            {
                Id       = Guid.NewGuid(),
                Email    = email,
                UserName = "******"
            };

            var userRules = new Mock <IUserRules>();
            var validator = new CreateUserValidator(userRules.Object);

            validator.ShouldHaveValidationErrorFor(x => x.Email, command);
        }
        public void ShouldHaveValidationErrorWithNullEmail(string email)
        {
            CreateUserRequestModel requestModel = new CreateUserRequestModel()
            {
                Email = email
            };

            _validator.ShouldHaveValidationErrorFor(r => r.Email, requestModel).WithErrorMessage("email cannot be null.");
        }
Beispiel #7
0
 public void Should_Error_When_Username_Is_Null()
 {
     validator.ShouldHaveValidationErrorFor(x => x.Username, null as string);
 }