public void CanLoginWithValidCredentials()
        {
            Mock<IAuthProvider> mock = new Mock<IAuthProvider>();
            mock.Setup(m => m.Authenticate("admin", "123456")).Returns(true);
            LoginViewModel model = new LoginViewModel
            {
                Name = "admin",
                Password = "******"
            };

            AccountController target = new AccountController(mock.Object);

            ActionResult result = target.Login(model, "/MyUrl");

            Assert.IsInstanceOfType(result, typeof(RedirectResult));
            Assert.AreEqual("/MyUrl", ((RedirectResult)result).Url);
        }
 public void CanNotLoginWithInvalidCredentials()
 {
     Mock<IAuthProvider> mock = new Mock<IAuthProvider>();
     mock.Setup(m => m.Authenticate("badUser", "badPass")).Returns(false);
     
     LoginViewModel model = new LoginViewModel
     {
         Name = "badUser",
         Password = "******"
     };
     
     AccountController target = new AccountController(mock.Object);
     
     ActionResult result = target.Login(model, "/MyURL");
     
     Assert.IsInstanceOfType(result, typeof(ViewResult));
     Assert.IsFalse(((ViewResult)result).ViewData.ModelState.IsValid);
 }