Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
 private static LoginController CreateLoginController()
 {
     var loginController = new LoginController();
     loginController.ControllerContext = new ControllerContext
                                             {
                                                 Controller = loginController,
                                                 RequestContext = new RequestContext(MockHttpContext(), new RouteData())
                                             };
     return loginController;
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
        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));
        }