0
我試圖對彈性客戶端調用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>()
);