1
我正在嘲笑一個通用的知識庫,並剛剛向我的Retrieve方法添加了第二個參數,允許我傳遞包含對象屬性的字符串,我有點卡在如何模擬這一點,並得到一個TargetParameterCountException
。Moq通用知識庫 - TARGETPARAMETERCOUNTEXCEPTION
如果有人能讓我朝正確的方向發展,那會很棒。
接口:
IQueryable<T> Retrieve(Expression<Func<T, bool>> predicate);
IQueryable<T> Retrieve(Expression<Func<T, bool>> predicate, IEnumerable<string> includes);
起訂量:
var mActionRepository = new Mock<IRepository<ContainerAction>>();
mActionRepository.Setup(m => m.Retrieve(It.IsAny<Expression<Func<ContainerAction, bool>>>()))
.Returns<Expression<Func<ContainerAction, bool>>>(queryable.Where);
mActionRepository.Setup(m => m.Retrieve(It.IsAny<Expression<Func<ContainerAction, bool>>>(), It.IsAny<IEnumerable<string>>()))
.Returns<Expression<Func<ContainerAction, bool>>>(queryable.Where);
第一起訂量的工作,第二個沒有。
爲十分感謝 –