我想忽略在同一个案例测试中我要调用的其他调用之间的一个调用。如果我使用ignoreothercalls,我还不清楚是否会调用其余的调用。在被忽略的电话之后,我需要休息。或者至少,在测试用例结束之前找到停止ignoreothercalls效果的方法。
public virtual List<TEntity> Get(Expression<Func<TEntity, bool>> criteria)
{
IQueryable<TEntity> recordsToReturn = _dbSet.Where(criteria);
if (OrderBy != null)
{
var orderedRecordsToReturn = recordsToReturn.OrderByDescending(OrderBy);
recordsToReturn = orderedRecordsToReturn;
// You can only call ThenBy() on an IOrderedQueryable
if (ThenOrderBy != null)
{
recordsToReturn = orderedRecordsToReturn.ThenBy(ThenOrderBy);
}
}
return recordsToReturn.ToList();
}
我想在没有经过测试的情况下离开此调用,并将其从de测试用例中移除,而不会出现因为它需要调用错误的问题: 模拟()的 xxxCall (&#34; HAL_AS393x_ReadRegisters&#34)。 // - 其中 xxxCall =用于此的未知关键字 -
答案 0 :(得分:0)
你必须检查两者之间的期望:
mock().expect...
do_something_that_call_mocks();
mock().checkExpectations();
/* Start all over again */
使用checkExpectations()重置mock()here
的完整示例