public void CanUpdateUserAuthorizationInformation()
        {
            // test setup;
            UserInformation userInformation = new UserInformation("1234", "*****@*****.**", true, "ana", "valencia", "ana valencia", "buildmotion.com", string.Empty);
            AuthorizationInformation authorization = new AuthorizationInformation("abc", DateTime.Now.ToUniversalTime().AddHours(1), DateTime.Now.ToUniversalTime(), "xyz");
            authorization.Email = userInformation.Email; //remove this to fail the test;
            userInformation.Id = Guid.NewGuid();

            this.repositoryMock.Setup(r => r.RetrieveUserInformation(It.IsAny<string>())).Returns(userInformation);
            this.repositoryMock.Setup(u => u.UpdateUserInformation(It.IsAny<UserInformation>())).Returns(userInformation);
            this.repositoryMock.Setup(a => a.UpdateAuthorizationInformation(It.IsAny<AuthorizationInformation>())).Returns(true);

            // test;
            var action = new CreateUpdateAuthorizationUserInfoAction(authorization, userInformation, this.providerMock.Object);
            action.Execute();
            UserInformation user = action.UserInformation;

            // Assertions;
            WriteValidationContextRuleResults(action.ValidationContext);
            Assert.IsTrue(action.ValidationContext.IsValid);
            Assert.IsNotNull(user);
            Assert.AreNotEqual(Guid.Empty, user.Id);
            Assert.IsNotNullOrEmpty(user.Email);
        }
        public void AttemptCreateUpdateAuthorizationUserInfoWithInvalidEmailAddress()
        {
            // test setup;
            UserInformation userInformation = new UserInformation("1234", "*****@*****.**", true, "ana", "valencia", "ana valencia", "buildmotion.com", string.Empty);
            AuthorizationInformation authorization = new AuthorizationInformation("abc", DateTime.Now.ToUniversalTime().AddHours(1), DateTime.Now.ToUniversalTime(), "xyz");
            authorization.Email = string.Empty; //remove this to fail the test;
            userInformation.Email = string.Empty;

            this.repositoryMock.Setup(r => r.RetrieveUserInformation(It.IsAny<string>()));
            this.repositoryMock.Setup(r => r.CreateUserInformation(It.IsAny<UserInformation>())).Returns(userInformation);
            this.repositoryMock.Setup(c => c.CreateAuthorizationInformation(It.IsAny<AuthorizationInformation>())).Returns(true);

            // test;
            var action = new CreateUpdateAuthorizationUserInfoAction(authorization, userInformation, this.providerMock.Object);
            action.Execute();
            UserInformation user = action.UserInformation;

            // Assertions;
            WriteValidationContextRuleResults(action.ValidationContext);
            Assert.IsFalse(action.ValidationContext.IsValid);
            Assert.IsNull(user);
        }
        /// <summary>
        ///     Creates the update authorization user info.
        /// </summary>
        /// <param name="authorization">The authorization.</param>
        /// <param name="userInfo">The user info.</param>
        /// <returns></returns>
        public override UserInformation CreateUpdateAuthorizationUserInfo(AuthorizationInformation authorization,
		                                                                  UserInformation userInfo)
        {
            UserInformation userInformation = null;
            CreateUpdateAuthorizationUserInfoAction action = new CreateUpdateAuthorizationUserInfoAction(authorization, userInfo,
                                                                                                         this);
            action.Execute();
            if (action.Result == ActionResult.Success)
            {
                userInformation = action.UserInformation;
            }
            return userInformation;
        }