public void ReturnFalseForInvalidUserLogin()
        {
            var controller = new LoginController();
            var user = GetUser();
            IsolateLoginController(user);
            Isolate.Fake.StaticMethods(typeof(LoginServices));
            Isolate.WhenCalled(() => LoginServices.Login(user)).IgnoreCall();

            var response = controller.Login(InvalidUser, InvalidPassword);

            Assert.IsFalse(GetSuccessValueFromActionResult(response));
        }
 private static LoginController CreateLoginController()
 {
     var loginController = new LoginController();
     loginController.ControllerContext = new ControllerContext
                                             {
                                                 Controller = loginController,
                                                 RequestContext = new RequestContext(MockHttpContext(), new RouteData())
                                             };
     return loginController;
 }
        public void MyTestInitialize()
        {
            _sessionState = Isolate.Fake.Instance<HttpSessionStateBase>();
            ObjectFactory.Configure(x => x.For<HttpSessionStateBase>().Use(_sessionState));
            _controller = ObjectFactory.GetInstance<LoginController>();

            Isolate.WhenCalled(() => EnvironmentServices.SetEnvironment("Test")).IgnoreCall();
            Isolate.WhenCalled(() => SessionStateManager.InitializeDatabase(_sessionState)).IgnoreCall();

            _user = new UserLoginDto
            {
                UserName = "******",
                Password = "******",
                Environment = Testgenform
            };
            Isolate.WhenCalled(() => LoginServices.Login(_user)).IgnoreCall();

            _response = Isolate.Fake.Instance<HttpResponseBase>();
            Isolate.WhenCalled(() =>_controller.Response).WillReturn(_response);

            _context = Isolate.Fake.Instance<HttpContextBase>();
            Isolate.WhenCalled(() => _controller.HttpContext).WillReturn(_context);
            Isolate.WhenCalled(() => _context.Session).WillReturn(_sessionState);
        }
        public void ReturnLoginPresentationForValidUserWithLoginButtonEnabled()
        {
            var controller = new LoginController();
            Isolate.Fake.StaticMethods(typeof(LoginForm));

            var result = controller.GetLoginPresentation("Admin", "Admin");

            Isolate.Verify.WasCalledWithAnyArguments(() => LoginForm.NewLoginForm("", ""));

            Assert.IsNotNull(result);
            Assert.IsFalse(GetLoginInButtonEnabledValue(result));
        }
        public void ReturnSuccessValueIsTrueWhenValidUserLogin()
        {
            // Setup
            var user = GetUser();
            IsolateLoginController(user);

            Isolate.WhenCalled(() => LoginServices.Login(user)).IgnoreCall();
            Isolate.WhenCalled(() => LoginServices.IsLoggedIn(user)).WillReturn(true);
            var controller = new LoginController();
            Isolate.NonPublic.WhenCalled(controller, "SetLoginCookie").IgnoreCall();

            var response = controller.Login(ValidUser, ValidPassword);

            Assert.IsTrue(GetSuccessValueFromActionResult(response));
        }