I’m using Moq with a MVC3 project and EF (code first). I currently have a Mock setup like so
(In Repository)
IQueryable<T> FindAll();
IQueryable<T> FindWhere(Expression<Func<T, bool>> predicate);
(In Mock tests)
_providerRepository.Setup(mr => mr.FindById(
It.IsAny<int>())).Returns((int i) => _providerData.Where(
x => x.Id == i).Single());
which works fine, my question is what would a sample Mock for FindWhere(.. look like?
thanks
Your code sample is incomplete, but I’m assuming that
_providerRepositoryis of typeIRepository<Provider>. I think this should work (basically the same way as your other example):You may or may not need the
AsQueryable.