Exemple #1
0
        private UserLoginLog MedicareLoginTask(User user, string sessionId, string browserName, Role role, OrganizationRoleUserModel availableRole)
        {
            var newLoginlog = _loginService.SaveLoginInfo(user.Id, user.UserLogin.UserName, sessionId, browserName, Request.UserHostAddress, Request.UrlReferrer ?? new Uri("https://hip.healthfair.com/Login/MedicareLogin"));

            _sessionContext.UserSession.UserLoginLogId = newLoginlog.Id;
            _sessionContext.UserSession = _loginService.SwitchOrganizationRole(_sessionContext.UserSession, role.Id, availableRole.OrganizationId);

            return(newLoginlog);
        }
        public void SwitchRole_ReturnsCorrectCurrentRole()
        {
            // It should be in the Unit Test
            //Set Up data
            var currentSession = new UserSessionModel
            {
                CurrentOrganizationRole = new OrganizationRoleUserModel
                {
                    OrganizationId         = 6,
                    OrganizationName       = "ABC Corporation6",
                    OrganizationRoleUserId = 66,
                    RoleAlias       = "Aliase7",
                    RoleDisplayName = "Display6",
                    RoleId          = 6
                },
                FirstName = "John",
                LastName  = "Doe",
                UserId    = 11,
                UserName  = "******",
                AvailableOrganizationRoles = new OrganizationRoleUserModel[5]
            };



            for (var fillOrg = 0; fillOrg < 5; fillOrg++)
            {
                currentSession.AvailableOrganizationRoles[fillOrg] = new OrganizationRoleUserModel
                {
                    OrganizationId         = fillOrg,
                    OrganizationName       = "ABC Corporation" + fillOrg,
                    OrganizationRoleUserId = fillOrg + fillOrg,
                    RoleAlias       = "Aliase" + fillOrg,
                    RoleDisplayName = "Display" + fillOrg,
                    RoleId          = fillOrg
                };
                ;
            }



            currentSession = _userLoginService.SwitchOrganizationRole(currentSession, SWITCH_TO_ROLE, SWITCH_TO_ORG);

            //Test
            Assert.AreEqual(currentSession.CurrentOrganizationRole.RoleId, SWITCH_TO_ROLE);
        }