Ich versuche Moq
Aufruf an elastischen Client, aber es funktioniert nicht.Mock elastischen Client Anruf
Ich habe diesen Anruf innerhalb von Generika repo.Update(T doc)
:
var response = await _client.UpdateAsync(DocumentPath<T>.Id(doc),
d => d
.Upsert(doc)
.Script(.....)
);
In meinem Test ich überprüfen möchten, ob UpdateAsync
mit diesen spezifischen Eingaben aufgerufen wurde.
ich folgendes versucht, die nicht funktioniert hat:
_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>()
);