Ejemplo n.º 1
0
        public void ContinueQReg()
        {
            UserService target       = CreateNewUserService();
            User        insertedUser = (User)target.RegisterQuickFromDoctor(new UserRegisterQuickFromDoctorSP()
            {
                FirstName      = TestUtils.RandomUtils.RandomString(100),
                LastName       = TestUtils.RandomUtils.RandomString(100),
                PhoneNumber    = TestUtils.RandomUtils.RandomPhoneNumber(),
                ReferrerUserID = (long)TestEnums.User.constDoctorID
            });

            string password = TestUtils.RandomUtils.RandomString(64);

            UserContinueQRegSP p = new UserContinueQRegSP()
            {
                UserName              = TestUtils.RandomUtils.RandomUserName(),
                FirstName             = TestUtils.RandomUtils.RandomString(100),
                LastName              = TestUtils.RandomUtils.RandomString(100),
                PhoneNumber           = insertedUser.PhoneNumber,
                PhoneVerificationCode = insertedUser.PhoneVerificationCode,
                Password              = password,
                ConfirmPassword       = password,
                Email = TestUtils.RandomUtils.RandomEmail()
            };

            target.ContinueQReg(p);

            var u = target.GetByIDV(insertedUser.UserID);

            Assert.AreEqual(p.UserName.ToLower(), u.UserName, "UserName not updated");
            Assert.AreEqual(p.FirstName, u.FirstName, "FirstName not updated");
            Assert.AreEqual(p.LastName, u.LastName, "LastName not updated");
            Assert.AreEqual(p.PhoneNumber, u.PhoneNumber, "PhoneNumber not updated");
            Assert.AreEqual(p.Email.ToLower(), u.Email, "Email not updated");

            target.ValidateUserNamePassword(new UserValidateUserNamePasswordSP()
            {
                ThrowIfError = true,
                Password     = password,
                UserName     = p.UserName
            });

            // cascade problems TODO: Fix delete cascade problems
            //target.Delete(insertedUser);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Check business rules for continuing quick registration
        /// </summary>
        /// <param name="p"></param>
        public void ContinueQReg(UserContinueQRegSP p)
        {
            BusinessRuleErrorList errors = new BusinessRuleErrorList();

            if (p.Password != p.ConfirmPassword)
            {
                errors.Add(vUser.ColumnNames.PasswordHash, BusinessErrorStrings.User.PasswordAndConfirmPasswordDoesntMatch);
            }

            CheckUtils.CheckStringShouldNotBeNullOrEmpty(vUser.ColumnNames.Email, p.Email, errors);
            CheckUtils.CheckStringShouldNotBeNullOrEmpty(vUser.ColumnNames.UserName, p.UserName, errors);
            CheckUtils.CheckStringShouldNotBeNullOrEmpty(vUser.ColumnNames.PasswordHash, p.Password, errors);
            CheckUtils.CheckStringShouldNotBeNullOrEmpty(vUser.ColumnNames.PhoneNumber, p.PhoneNumber, errors);

            if (errors.Count > 0)
            {
                throw new BRException(errors);
            }
        }