0

I have a method that I want to test for generic repository:

public virtual async Task<IEnumerable<TEntity>> GetAllAsync<TEntity>(
            Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null,
            string includeProperties = null,
            int? skip = null,
            int? take = null)
            where TEntity : class, IEntity
        {
            return await GetQueryable<TEntity>(null, orderBy, includeProperties, skip, take).ToListAsync();
        }

I am clueless how to mock this with moq.

sensei
  • 7,044
  • 10
  • 57
  • 125
  • What did you try so far? Are there any errors that you are getting? – Huske Jun 16 '17 at 21:22
  • Have a look at this question https://stackoverflow.com/questions/39416561/moq-a-function-with-anonymous-type – Huske Jun 16 '17 at 21:23
  • _repositoryMock.Setup(x => x.GetAllAsync(null, null, null, null)).Returns() i am not sure what to return. – sensei Jun 16 '17 at 21:35
  • _repositoryMock.Setup(x => x.GetAllAsync(It.IsAny>>(), null, null, null)).ReturnsAsync(). This is what the response to the question that I posted suggests. – Huske Jun 16 '17 at 21:50
  • 2
    ok got it like this: _repositoryMock.Setup(x => x.GetAllAsync(It.IsAny, IOrderedQueryable>>()‌, null, null, null)).ReturnsAsync(new List()); – sensei Jun 16 '17 at 21:52

0 Answers0