public void TestInvalidJsonLogin()
        {
            string testUserName = "******";
            string testPassword = "******";
            bool testRememberMe = false;
            string testReturnUrl = "TestReturnUrl";

            var loginModel = new LoginModel
            {
                UserName = testUserName,
                Password = testPassword,
                RememberMe = testRememberMe
            };

            var accountController = new AccountController();
            JsonResult jsonResult;
            //Scope the detours we're creating
            using (ShimsContext.Create())
            {
                //Sets up a detour for Membership.ValidateUser to our mocked implementation
                ShimMembership.ValidateUserStringString = (userName, password) => false;
                jsonResult = accountController.JsonLogin(loginModel, testReturnUrl);
            }

            var errors = (IEnumerable<string>)(new PrivateObject(jsonResult.Data, "errors")).Target;
            Assert.AreEqual("The user name or password provided is incorrect.", errors.First());
        }
        public void TestJsonLogin()
        {
            string testUserName = "******";
            string testPassword = "******";
            bool testRememberMe = false;
            string testReturnUrl = "TestReturnUrl";

            var loginModel = new LoginModel
            {
                UserName = testUserName,
                Password = testPassword,
                RememberMe = testRememberMe
            };

            var accountController = new AccountController();
            JsonResult jsonResult;
            //Scope the detours we're creating
            using (ShimsContext.Create())
            {
                //Sets up a detour for Membership.ValidateUser to our mocked implementation
                ShimMembership.ValidateUserStringString = (userName, password) =>
                {
                    Assert.AreEqual(testUserName, userName);
                    Assert.AreEqual(testPassword, password);
                    return true;
                };

                //Sets up a detour for FormsAuthentication.SetAuthCookie to our mocked implementation
                ShimFormsAuthentication.SetAuthCookieStringBoolean = (userName, rememberMe) =>
                {
                    Assert.AreEqual(testUserName, userName);
                    Assert.AreEqual(testRememberMe, rememberMe);
                };

                jsonResult = accountController.JsonLogin(loginModel, testReturnUrl);
            }

            var success = (bool)(new PrivateObject(jsonResult.Data, "success")).Target;
            var redirect = (string)(new PrivateObject(jsonResult.Data, "redirect")).Target;

            Assert.AreEqual(true, success);
            Assert.AreEqual(testReturnUrl, redirect);
        }