public void LogOn_doesnt_Log_in_client_in_with_invalid_parameters()
        {
            const string email = "InvalidEmail";
            const string password = "******";
            _authenticationService.User.ShoppingCart = null;

            var viewModel = new AccountLogOnViewModel
                                {
                                    Email = email,
                                    Password = password,
                                    RememberMe = false
                                };

            Assert.AreEqual(false, _authenticationService.Authenticated);

            _accountController.LogOn(viewModel, "");

            Assert.AreEqual(false, _authenticationService.Authenticated);
        }
        public ActionResult LogOn(AccountLogOnViewModel model, string returnUrl)
        {
            if (ModelState.IsValid) {
                if (_authenticationService.Authenticate(model.Email, model.Password)) {
                    var shoppingCart = GetShoppingCart();
                    if (shoppingCart != null) {
                        _shoppingCartService.MigrateShoppingCart(model.Email, shoppingCart);

                        HttpContext.Session.Remove(ShoppingCartService.CartSessionKey);
                    }

                    _authenticationService.SignIn(model.Email, model.RememberMe);

                    if (Url.IsLocalUrl(returnUrl)) {
                        return Redirect(returnUrl);
                    }

                    return RedirectToAction("List", "Movies");
                }

                ModelState.AddModelError("", "The user name or password provided is incorrect.");
            }

            return View(model);
        }
        public void LogOn_Logs_a_cliet_in_when_provided_with_correct_parameters()
        {
            var email = _authenticationService.User.Email;
            var password = _authenticationService.User.Password;
            _authenticationService.User.ShoppingCart = null;

            var viewModel = new AccountLogOnViewModel
                                {
                                    Email = email,
                                    Password = password,
                                    RememberMe = false
                                };

            Assert.AreEqual(false, _authenticationService.Authenticated);

            _accountController.LogOn(viewModel, "");

            Assert.AreEqual(true, _authenticationService.Authenticated);
        }