public void RoleManagementLogic_AddRole_Unauthorized_ThrowsUnauthorizedAccessException() { SecurityRole securityRole = new SecurityRole(); ClaimsPrincipal user = new ClaimsPrincipal(); Mock <IAuthorizationLogic> authorizationLogic = new Mock <IAuthorizationLogic>(); authorizationLogic.Setup(x => x.IsAuthorizedThrowsException(AuthorizationScopes.ManageRoles, user, It.IsAny <ILoggableEntity>(), It.IsAny <EventCategory>())).Throws(new UnauthorizedAccessException()); Mock <IConfigurationRepository> configurationRepository = new Mock <IConfigurationRepository>(); RoleManagementLogic roleManagementLogic = new RoleManagementLogic(configurationRepository.Object, authorizationLogic.Object); roleManagementLogic.AddRole(securityRole, user); }
public JsonResult AddRole(SecurityRole entity) { return(http.RespondSuccess(roleManagement.AddRole(entity, User))); }