public async Task GetMembershipInformation_ShouldReturnNull_WhenGroupDoesntExist() { // Arrange _unitOfWork.Setup(x => x.Groups.GetById(It.IsAny <int>())) .ReturnsAsync(() => null); // Act var result = await _sut.GetMembershipInformation(It.IsAny <int>(), It.IsAny <int>()); // Assert Assert.Null(result); }
public async Task <IActionResult> GetMembershipInformation(int userId, int groupId) { if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } var membershipInformation = await _groupsService.GetMembershipInformation(userId, groupId); if (membershipInformation != null) { return(Ok(membershipInformation)); } return(BadRequest()); }