# Getting null in response (InMemoryConnection) in mock testing

**URL:** <https://discuss.elastic.co/t/getting-null-in-response-inmemoryconnection-in-mock-testing/199355>\
**Category:** Elasticsearch\
**Created:** [September 13, 2019, 4:14am UTC](https://discuss.elastic.co/t/getting-null-in-response-inmemoryconnection-in-mock-testing/199355 "2019-09-13T04:14:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kamleshjoshi](https://avatars.discourse-cdn.com/v4/letter/k/f14d63/32.png) [@kamleshjoshi](https://discuss.elastic.co/u/kamleshjoshi)\
**Post date:** [September 13, 2019, 4:14am UTC](https://discuss.elastic.co/t/getting-null-in-response-inmemoryconnection-in-mock-testing/199355/1 "2019-09-13T04:14:20Z")

</div>

I am trying to mock elasticsearch using NEST library in C#. In the response I am getting null. This is the code:

```
var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
            var settings = new ConnectionSettings(connectionPool, new InMemoryConnection());
            settings.DisableDirectStreaming();
            settings.DefaultIndex("person");

            var c = new ElasticClient(settings);

            var person = new Person
            {
                Id = 1,
                FirstName = "test",
                LastName = "user"
            };
            
            var indexResponse = c.IndexDocument(person);

            var searchResponse = c.Search<Person>(s => s.Index("person")
            .AllIndices()
            .AllTypes()
            .From(0)
            .Size(10)
            .Query(q => q
                 .Match(m => m
                    .Field(f => f.FirstName)
                    .Query("test")
                 )
            )
        );
            var people = searchResponse.Documents;

```

In the above code, I am getting zero in searchResponse.Documents.  
searchResponse value is :  
Valid NEST response built from a successful low level call on POST: /default/\_search  
Audit trail of this API call:

- [1] HealthyResponse: Node: [http://localhost:9200/](http://localhost:9200/) Took: 00:00:00.0079783  
Request:  
{"from":0,"size":10,"query":{"match":{"field":"FirstName","query":"test"}}}  
Response:

Any help will be highly appreciated.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 11, 2019, 4:14am UTC](https://discuss.elastic.co/t/getting-null-in-response-inmemoryconnection-in-mock-testing/199355/2 "2019-10-11T04:14:29Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
