public override async Task <ActivityTypes> SearchActivityTypes(SearchActivityTypesRequest req, ServerCallContext context) { try { var searchedActivityTypes = await _activityManager.SearchActivityTypesAsync(req.AgencyId, req.ActivityTypeName); var activityTypes = new ActivityTypes(); activityTypes.ActivityTypes_.AddRange(searchedActivityTypes); return(activityTypes); } catch (Exception ex) { return(null); } }
public async void SearchActivityTypes_ForValidArg_ShouldPassValidArg() { // Arrange var agencyId = 12L; var activityTypeName = "type_name"; var activityTypeDbModel = _mapper.Map <ActivityTypeDbModel>(Mocks.ActivityType); _activityTypeRepoMock.Setup(repo => repo.SearchActivityTypesAsync(It.IsAny <long>(), It.IsAny <string>())) .ReturnsAsync(Enumerable.Repeat(activityTypeDbModel, 4).ToList()); // Act await _target.SearchActivityTypesAsync(agencyId, activityTypeName); // Assert _unitOfWorkMock.Verify(uow => uow.SaveAsync(), Times.Never); _activityTypeRepoMock.Verify(repo => repo.SearchActivityTypesAsync(agencyId, activityTypeName), Times.Once); _activityTypeRepoMock.Verify(repo => repo.SearchActivityTypesAsync(It.IsAny <long>(), It.IsAny <string>()), Times.Once); }