public override async Task <Activities> GetActivities(GetActivitiesRequest req, ServerCallContext context) { try { var allActivities = await _activityManager.GetActivitiesAsync(req.AgencyId); var activities = new Activities(); activities.Activities_.AddRange(allActivities); return(activities); } catch (Exception ex) { return(null); } }
public async void GetActivities_ForValidArg_ShouldPassValidArg() { // Arrange var agencyId = 12L; var activityDbModel = _mapper.Map <ActivityDbModel>(Mocks.Activity); _activityRepoMock.Setup(repo => repo.GetAllActivitiesAsync(It.IsAny <long>())) .ReturnsAsync(Enumerable.Repeat(activityDbModel, 4).ToList()); // Act await _target.GetActivitiesAsync(agencyId); // Assert _unitOfWorkMock.Verify(uow => uow.SaveAsync(), Times.Never); _activityRepoMock.Verify(repo => repo.GetAllActivitiesAsync(agencyId), Times.Once); _activityRepoMock.Verify(repo => repo.GetAllActivitiesAsync(It.IsAny <long>()), Times.Once); }