public void CanLoginWithValidCredentials()
        {
            var mock = new Mock<IAuthProvider>();
            mock.Setup(m => m.Authenticate("admin", "12345"))
                .Returns(true);

            var model = new LoginViewModel()
            {
                UserName = "******",
                Password = "******"
            };

            var target = new AccountController(mock.Object);

            const string returnUrl = "/MyUrl";
            var result = target.Login(model, returnUrl);

            Assert.IsInstanceOfType(result, typeof(RedirectResult));
            Assert.AreEqual(returnUrl, ((RedirectResult)result).Url);
        }
        public void CannotLoginWithInvalidCredentials()
        {
            var mock = new Mock<IAuthProvider>();
            mock.Setup(m => m.Authenticate("badUser", "badPass"))
                .Returns(false);

            var model = new LoginViewModel()
            {
                UserName = "******",
                Password = "******"
            };

            var target = new AccountController(mock.Object);

            const string returnUrl = "/MyUrl";
            var result = target.Login(model, returnUrl);

            Assert.IsInstanceOfType(result, typeof(ViewResult));
            Assert.IsFalse(((ViewResult)result).ViewData.ModelState.IsValid);
        }