Mocking SearchResponse in New .NET client

Hi @imhoffdavid,

Just a few words related to this style of testing in general:

IMO you are mocking on the wrong abtraction level. Currently, you are trying to mimic the Elasticsearch client/server behavior - which in the end does not really verify anything meaningful.

Do you have some kind of repository pattern in your application? If yes, then this would be the place where I could imagine using mocks; otherwise, you probably want an integration test instead.

As for the concrete problem:

Documents is not a true property of the response, but is a manually added convenience property (computed property).

You need to stub out the actual response, providing the hits:

var temp = new SearchResponse<GlobalWorkstationWorkflowInfo>()
{
	HitsMetadata = new()
	{
		Hits = [new Hit<GlobalWorkstationWorkflowInfo>() { Source = new GlobalWorkstationWorkflowInfo() }]
	}
};

var searchResponse = TestableResponseFactory.CreateSuccessfulResponse(temp, 200);
var docs = searchResponse.Documents;