【发布时间】:2020-09-29 15:31:24
【问题描述】:
我有一个类似的界面 -
public interface ILedgerStoreRepository
{
void AddInvoiceDetailsToBatchWriteObj(ref BatchWrite<InvoiceDetailsDAO> batchWriteDetails,
ref InvoiceDetailsDAO invoiceDetails);
}
我想模拟这个函数,我只想验证 invoiceDetails 值作为我的验证。目前我正在尝试 -
var repoMock = new Mock<ILedgerStoreRepository>();
repoMock.Setup(m =>
m.AddInvoiceDetailsToBatchWriteObj(ref batchWriteObj1,
ref It.Ref<InvoiceDetailsDAO>.IsAny)).Callback<BatchWrite<InvoiceDetailsDAO>, InvoiceDetailsDAO>(
(write, dao) =>
{
Assert.Equal(LedgerStoreTestConstants.TestInvoiceDetailsMappingDao, dao);
}).Verifiable();
但它向我抛出了以下错误 -
System.ArgumentException 无效的回调。设置带参数的方法(参考 BatchWrite、参考 InvoiceDetailsDAO)无法调用带参数的回调(BatchWrite、InvoiceDetailsDAO)。
谁能帮我解决这个问题?
【问题讨论】:
-
您需要使用自定义委托类型来实现这一点。检查这个link