public void ShouldBeAbleToRequestConfirmationEmail()
        {
            UserManager mgr = UserTestTools.CreateTestUserManager("Stickerize");

            mgr.HttpContext         = A.Fake <IHttpContext>();
            mgr.HttpContext.Request = new TestRequest();
            UserTestTools.SignUp("monkey", "*****@*****.**");
            SendEmailResponse result = mgr.RequestConfirmationEmail("*****@*****.**");

            Expect.IsTrue(result.Success, result.Message);
        }
        public void ForgotPasswordShouldCreatePasswordResetEntry()
        {
            string userName = MethodBase.GetCurrentMethod().Name;
            string email    = "*****@*****.**";

            UserTestTools.SignUp(userName, email);
            User user = User.GetByEmail(email);

            Expect.AreEqual(0, user.PasswordResetsByUserId.Count);

            UserManager userMgr = UserTestTools.CreateTestUserManager("Stickerize");

            userMgr.HttpContext         = A.Fake <IHttpContext>();
            userMgr.HttpContext.Request = new TestRequest();

            userMgr.ForgotPassword(email);

            user.PasswordResetsByUserId.Reload();
            Expect.AreEqual(1, user.PasswordResetsByUserId.Count);
        }
        public void ForgotPasswordShouldSucceed()
        {
            UserTestTools.ClearAllUserInfo();
            string userName = MethodBase.GetCurrentMethod().Name;
            string email    = "*****@*****.**";

            UserTestTools.SignUp(userName, email);
            User user = User.GetByEmail(email);

            Expect.AreEqual(0, user.PasswordResetsByUserId.Count);

            UserManager userMgr = UserTestTools.CreateTestUserManager("Stickerize");

            userMgr.HttpContext         = A.Fake <IHttpContext>();
            userMgr.HttpContext.Request = new TestRequest();

            ForgotPasswordResponse response = userMgr.ForgotPassword(email);

            Expect.IsTrue(response.Success);
        }
        public void ResetPasswordShouldBeLoginnable()
        {
            string userName = MethodBase.GetCurrentMethod().Name;
            string email    = "*****@*****.**";

            UserTestTools.SignUp(userName, email);
            User user = User.GetByEmail(email);

            Expect.AreEqual(0, user.PasswordResetsByUserId.Count);

            UserManager userMgr = UserTestTools.CreateTestUserManager("Stickerize");

            userMgr.HttpContext         = A.Fake <IHttpContext>();
            userMgr.HttpContext.Request = new TestRequest();

            string password = ServiceProxySystem.GenerateId();
            ForgotPasswordResponse forgot = userMgr.ForgotPassword(email);
            PasswordResetResponse  reset  = userMgr.ResetPassword(password.Sha1(), (string)forgot.Data);
            LoginResponse          login  = userMgr.Login(user.UserName, password.Sha1());

            Expect.IsTrue(login.Success, "Login failed");
        }