Sto riscontrando problemi nella creazione di Test unità per la ricerca utilizzando ElasticSearch con Nest.Test unità Nest ElasticSearch 2.0 con MOQ
Unit Test
var mockSearchResponse = new Mock<ISearchResponse<Person>>();
mockSearchResponse.Setup(x => x.Documents).Returns(_people);
var mockElasticClient = new Mock<IElasticClient>();
mockElasticClient.Setup(x => x.Search(It.IsAny<Func<SearchDescriptor<Person>, SearchRequest<Person>>>())).Returns(mockSearchResponse.Object);
var service = new PersonService(mockElasticClient.Object);
var result = service.Search(string.Empty, string.Empty);
Assert.AreEqual(2,result.Count());
codice di lavoro
results = ConnectionClient.Search<Person>(s => s.Index("person_index").Query(q => q.Term(t => t.Id, searchValue))).Documents;
Il risultato è sempre nullo, anche se faccio la seguente
var temp = ConnectionClient.Search<Person>(s => s.Index("person_index").Query(q => q.Term(t => t.Id, searchValue)));
Qualsiasi aiuto sarebbe apprezzato.
Grazie, questo è un buon inizio –