InMemoryConnection for unit testing Elasticsearch projects

Is it good to use a class InMemoryConnection

for unit testing our Elasticsearch projects?

This class is used in the actual source code for unit testing. But the reason I am asking is because it comes from HttpConnection

. I'm not really sure if it opens any HTTP connection. Our unit tests go to the build server, so I would like to avoid that. Thanks for the help.

+3


source to share


2 answers


Yes.



If you look at the implementation InMemoryConnection

, you can see that it overrides DoSynchronousRequest and DoAsyncRequest (the methods HttpConnection

that are responsible for making the HTTP request) and just returns a fake one ElasticsearchResponse

. HTTP connections are not open and no requests are made, so you can use them in your unit tests.

+2


source


However, there is a NuGet package for real C # integration tests: https://www.nuget.org/packages/elasticsearch-inside/



(I am the author)

0


source







All Articles