I am using Moq and trying to setup the GetPagedList
mock for IRepository<TEntity>
below is the interface i am trying to mock
IPagedList GetPagedList(Expression> predicate = null, Func, IOrderedQueryable> orderBy = null, Func, IIncludableQueryable> include = null, int pageIndex = 0, int pageSize = 20, bool = true);
My service
public class StudentService
{
private readonly IRepository<Student> _repo;
public StudentService( IUnitOfWork unitOfWork )
{
_repo = unitOfWork.GetRepository<Student>();
_unitOfWork = unitOfWork;
}
public IPagedList<Student> Get(int id)
{
return _repo.GetPagedList(predicate: a => a.id == id);
}
}
My Unit Test
[Fact]
public void StudentService_GetStudentClasses_ReturnListOfClasses()
{
int studentId = 100;
_mockStudentRepo.Setup(x => x.GetPagedList(It.IsAny <
Expression<Func<Student, bool>>,
Func<IQueryable<Student>, IOrderedQueryable<Student>>,
Func<IQueryable<Student>, IIncludableQueryable<Student, object>>,
int, int, bool > ())).Returns(MockStudentList.Where(a => a.id == studentId ()).ToPagedList(0, 20));
}
Getting this error
Using the generic method
It.IsAny<TValue>()
requires 1 type arguments.
Any ideas on how to fix this would be greatly appreciated.