【发布时间】:2015-03-21 20:17:23
【问题描述】:
服务正在调用存储库函数“GetManyIncluded”,该函数具有如下所述的签名
IQueryable<T> GetManyIncluded(Expression<Func<T, bool>> where, params Expression<Func<T, object>>[] children);
在一个测试方法中,我正在设置它,如下所述
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());
这给了我服务中的参数计数不匹配异常。
请帮忙。
【问题讨论】:
-
我让它工作 mockedWrapper .Setup(x => x.PatientPayer.GetManyIncluded( It.IsAny
>>(), It.IsAny >[]>())) .Returns((Expression > expr, Expression >[] includeProperties) => appliedPatientPayers.Where(expr.Compile( )).ToList().AsQueryable()); -
您实际上应该将您的解决方案发布为答案(如下),而不仅仅是评论。如果你不这样做,我会写它作为答案。
-
由于某种原因我不能这样做。我的帐户被阻止回答。 :(
标签: unit-testing mocking moq repository-pattern