【发布时间】:2017-02-26 20:50:04
【问题描述】:
我正在尝试Moq 调用弹性客户端,但它不起作用。
我在内部通过通用 repo.Update(T doc) 调用:
var response = await _client.UpdateAsync(DocumentPath<T>.Id(doc),
d => d
.Upsert(doc)
.Script(.....)
);
在我的测试中,我想验证是否使用这些特定输入调用了 UpdateAsync。
我尝试了以下方法,但没有成功:
_mock = new Mock<IElasticClient>();
Func<UpdateDescriptor<Document,Document>,
IUpdateRequest<Document,Document>> sel = d => d.Upsert(doc).Script(....);
await repo.Update(document)
_mock.Verify(c => c.UpdateAsync<Document>(
It.Is<DocumentPath<Document>(
docPath => docPath == DocumentPath<Document>.Id(document),
It.Is<Func<...>(s => s == sel),
it.IsAny<CancellationToken>()
);
【问题讨论】: