public void Smoke()
        {
            // arrange
            var service = new Mock<IAuthenticationService>();
            var redirect = new RedirectService();
            var controller = new LoginController(service.Object, redirect);

            //act/post
            Assert.That(controller, Is.Not.Null);
        }
        public void Login_Index_View()
        {
            // arrange
            var service = new Mock<IAuthenticationService>();
            var redirect = new RedirectService();
            var controller = new LoginController(service.Object, redirect);

            //act
            var result = controller.Index();

            //assert
            Assert.That(result, Is.Not.Null);
        }
        public void Login_Post_Success_With_ReturnUrl()
        {
            // arrange
            var service = new Mock<IAuthenticationService>();
            var redirect = new RedirectService();
            var controller = new LoginController(service.Object, redirect);
            var model = new LoginModel() { Email = "*****@*****.**", Password = "******" };

            service.Setup(s => s.Authenticate("*****@*****.**", "xxx")).Returns(true);

            //act
            var result = controller.Login(model, "somewhere") as RedirectResult;

            //assert
            Assert.That(result.Url, Is.EqualTo("somewhere"));
        }
        public void Login_Post_Success()
        {
            // arrange
            var service = new Mock<IAuthenticationService>();
            var redirect = new RedirectService();
            var controller = new LoginController(service.Object, redirect);
            var model = new LoginModel() { Email = "*****@*****.**", Password = "******" };

            service.Setup(s => s.Authenticate("*****@*****.**", "xxx")).Returns(true);
            
            //act
            var result = controller.Login(model, null) as RedirectResult;

            //assert
            result.Url.Should().Be("~/user/[email protected]");
        }
        public void Login_Post_Fail()
        {
            // arrange
            var service = new Mock<IAuthenticationService>();
            var redirect = new RedirectService();
            var controller = new LoginController(service.Object, redirect);
            var model = new LoginModel() { Email = "*****@*****.**", Password = "******" };

            service.Setup(s => s.Authenticate("*****@*****.**", "xxx")).Returns(false);

            //act
            var result = controller.Login(model, "somewhere") as ViewResult;

            //assert
            Assert.That(controller.ModelState[""].Errors[0].ErrorMessage, Is.EqualTo("The user name or password provided is incorrect."));
        }