I am trying to write some unit tests around some code that hits Elasticsearch through Nest, specifically with the .Search() call. I'm trying to set up Moq to return an empty search response when .Search() is called like so:
var emptyResponse = new Nest.SearchResponse<MyDoc>()
{
Documents = new List<MyDoc>() // illegal
};
esClient.Setup(x => x.Search<MyDoc>(It.IsAny <Func<SearchDescriptor<MyDoc>, SearchDescriptor<MyDoc>>>())).Returns(emptyResponse);
Unfortunately, I can't do this since Documents is readonly on SearchResponse. What is the suggested approach for writing unit tests around search calls?
Aucun commentaire:
Enregistrer un commentaire