Following this answer I've tried to something similar and mock an interface of:
public interface IGetRepository<TEntity>
{
IEnumerable<TEntity> Get(
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null);
}
This is my unit test method:
IEnumerable<EventModel> expectedList = return new List<MyModel>()
{
new MyModel()
{
Id = 0
}
}
using (var _mock = AutoMock.GetLoose())
{
var repositoryMock = _mock.Mock<IGenericRepository<EventModel>>();
repositoryMock
.Setup(items => items.Get(It.IsAny<Expression<Func<EventModel, bool>>>))
.Returns(() => expectedList);
}
But the It.IsAny<Expression<Func<EventModel, bool>>>
create an error message of:
cannot convert from 'method group' to 'Expression>'
Already read these similar questions: 1,2,3 , so I guess the my issue is different signature, if so how do I convert this signature to be applicable with It.IsAny
of moq
?