コード例 #1
0
        public void AndPasswordIsEmpty()
        {
            // Arrange
            var user = new User { Email = "*****@*****.**", Password = string.Empty, ConfirmPassword = "******" };

            // Action
            var result = CreateNewUserValidator.Validate(user);

            // Arrange
            StringAssert.IsMatch("Password is EMPTY.", result.First());
        }
コード例 #2
0
        public void AndPasswordAndConfirmPasswordDoesNotMatch()
        {
            // Arrange
            var user = new User { Email = "*****@*****.**", Password = "******", ConfirmPassword = "******" };

            // Action
            var result = CreateNewUserValidator.Validate(user);

            // Arrange
            StringAssert.IsMatch("Password and Confirm Password does not match.", result.First());
        }
コード例 #3
0
ファイル: UserService.cs プロジェクト: Ri3gs/OMoney
        public void Create(User user)
        {
            using (var transaction = new TransactionScope())
            {
                var validationErrors = Validate(user, new CreateNewUserValidator()).ToList();
                if (validationErrors.Any()) throw new DomainEntityValidationException { ValidationErrors = validationErrors };

                _userRepository.Create(user);
                _notificationService.SendEmail(BuildNewUserNotificationMessage(user));

                transaction.Complete();
            }
        }
コード例 #4
0
        public void AndUserIsValid()
        {
            // Arrange
            var user = new User {Email = "*****@*****.**", Password = "******", ConfirmPassword = "******"};

            // Action
            var result = CreateNewUserValidator.Validate(user);

            // Assert
            Assert.IsEmpty(result);
        }
コード例 #5
0
ファイル: UserService.cs プロジェクト: Ri3gs/OMoney
 private IEnumerable<string> Validate(User user, IDomainEntityValidator<User> validator)
 {
     return validator.Validate(user);
 }
コード例 #6
0
ファイル: UserService.cs プロジェクト: Ri3gs/OMoney
 private string GenerateActivationLink(User user)
 {
     return string.Format("http://omoney.com.ua/activate/{0}", user.Email);
 }
コード例 #7
0
ファイル: UserService.cs プロジェクト: Ri3gs/OMoney
 private EmailNotificationMessage BuildNewUserNotificationMessage(User user)
 {
     return new EmailNotificationMessage {Subject = "Wellcome to OMoney!", Body = string.Format("Please follow this link: <a href='{0}'>link</a>", GenerateActivationLink(user))};
 }
コード例 #8
0
ファイル: UserService.cs プロジェクト: Ri3gs/OMoney
 public void Update(User user)
 {
     throw new System.NotImplementedException();
 }
コード例 #9
0
ファイル: UserService.cs プロジェクト: Ri3gs/OMoney
 public void Activate(User user)
 {
     throw new NotImplementedException();
 }