public async Task GetAllCreatedGroups_ShouldReturnNull_WhenUserIsNotPowerUser() { // Arrange _unitOfWork.Setup(x => x.Users.GetUserByIdWithAdditionalInformation(It.IsAny <int>())) .ReturnsAsync(new CommonUser()); // Act var result = await _sut.GetAllCreatedGroups(It.IsAny <int>()); // Assert Assert.Null(result); }
public async Task <IActionResult> GetAllCreatedGroups(int userId) { if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } var groups = await _groupsService.GetAllCreatedGroups(userId); if (groups != null) { return(Ok(groups)); } return(Unauthorized()); }