public async Task SearchIssuesTest() { //Arrange var issues = new List <Issue>() { new Issue { Id = 1 }, new Issue { Id = 2 } }; int totalIssues = 2; var service = new SearchBy(issueRepository.Object); issueRepository.Setup(x => x.GetIssues(It.IsAny <Func <Issue, bool> >(), It.IsAny <int>(), It.IsAny <int>())) .Returns(Task.FromResult(issues)); issueRepository.Setup(x => x.CountIssues(It.IsAny <Func <Issue, bool> >())).Returns(Task.FromResult(totalIssues)); //Act var action = await service.SearchIssues(x => x.Id != 0, x => x.Status != Status.Close, searchSpecification); //Assert Assert.Equal(totalIssues, action.Issues.Count); Assert.Equal(totalIssues, action.Count.FilteredIssue); }