public async Task GetAllAsync_Null() { //Arrange List <Role> roles = null; _roleRepositoryMock.Setup(m => m.GetAllAsync()).Returns(() => Task.FromResult(roles)); RoleBusiness roleBusiness = new RoleBusiness(_roleRepositoryMock.Object); //Act var result = await roleBusiness.GetAllAsync(); //Assert result.Should().BeNull(); }
public async Task <ActionResult> GetAll() { try { List <Role> roles = await _roleBusiness.GetAllAsync(); if (roles == null) { return(NotFound()); } List <RoleDto> rolesDto = _mapper.Map <List <RoleDto> >(roles); return(Ok(rolesDto)); } catch (Exception ex) { _logger.LogError(ex, "Ocorreu um erro ao buscar a role"); return(StatusCode(500, "Ocorreu um erro ao buscar a role")); } }