jeudi 22 janvier 2015

how to setup mock object for dynamic linq

A service is calling a repository function "GetManyIncluded" which has a signature like mentioned below



IQueryable<T> GetManyIncluded(Expression<Func<T, bool>> where, params Expression<Func<T, object>>[] children);


and in a test method i am setting it up like mentioned below



mockedWrapper.Setup(x => x.DomainObject.GetManyIncluded(It.IsAny<Expression<Func<DomainObject, bool>>>(), It.IsAny<Expression<Func<DomainObject, object>>[]>())).Returns<Expression<Func<DomainObject, bool>>>(expr => listOFObjects.Where(expr.Compile()).ToList().AsQueryable());


this gives me parameter count mismatch exception in the service.


please help.


Aucun commentaire:

Enregistrer un commentaire