Exemplo n.º 1
0
        public string CanLogin()
        {
            var userLogin = new UserLoginDto
            {
                UserName    = User,
                Password    = Password,
                Environment = Environment
            };

            try
            {
                MyTestInitialize();
                EnvironmentServices.SetEnvironment(Environment);
                UserServices.ConfigureSystemUser();
                LoginServices.Login(userLogin);
                var result = LoginServices.IsLoggedIn(userLogin.UserName).ToString(CultureInfo.InvariantCulture);
                MyTestCleanup();

                return(result);
            }
            catch (System.Exception)
            {
                return("False");
            }
        }
Exemplo n.º 2
0
        public ActionResult SetEnvironment(String environment)
        {
            if (HttpContext.Session != null)
            {
                HttpContext.Session.Add(EnvironmentSetting, environment);
                EnvironmentServices.SetHttpSessionCache(HttpContext.Session);
                EnvironmentServices.SetEnvironment(environment);
            }

            return(this.Direct(new { success = SessionStateManager.GetEnvironment(HttpContext.Session) == environment }));
        }
Exemplo n.º 3
0
        public static void Login(UserLoginDto dto)
        {
            EnvironmentServices.SetEnvironment(dto.Environment);

            var criteria = new LoginCriteria
            {
                UserName = dto.UserName,
                Password = dto.Password
            };

            GenFormPrincipal.Login(criteria);
        }
Exemplo n.º 4
0
 public void FirstSetTheEnvironmentWhenLogginIn()
 {
     try
     {
         LoginServices.Login(_dto);
         var env = _dto.Environment;
         Isolate.Verify.WasCalledWithAnyArguments(() => EnvironmentServices.SetEnvironment(env));
     }
     catch (Exception e)
     {
         Assert.Fail(e.ToString());
     }
 }
Exemplo n.º 5
0
        public void Init()
        {
            _principal = Isolate.Fake.Instance <GenFormPrincipal>();
            _identity  = Isolate.Fake.Instance <IGenFormIdentity>();
            Isolate.WhenCalled(() => _principal.Identity).WillReturn(_identity);

            Isolate.WhenCalled(() => GenFormPrincipal.GetPrincipal()).WillReturn(_principal);
            Isolate.WhenCalled(() => GenFormPrincipal.Login(_criteria)).IgnoreCall();

            Isolate.WhenCalled(() => EnvironmentServices.SetEnvironment(string.Empty)).IgnoreCall();

            _dto = GetAdminUserDto();
        }
        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);
        }