Mocking IndicesNamespace?
See original GitHub issueHow do I mock IElasticClient.Indices
, in other words, the IndicesNamespace
?
Can we instead have it so that IElasticClient.Indices
refers to an interface (for instance IIndicesNamespace
instead)?
Right now, I can’t mock indices using NSubstitute
:
var fakeIndicesNamespace = Substitute.For<IndicesNamespace>(); //crashes with message: System.NotSupportedException : Parent does not have a default constructor. The default constructor must be explicitly defined.
var fakeElasticClient = Substitute.For<IElasticClient>();
fakeElasticClient.Indices.Returns(fakeIndicesNamespace);
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Elasticsearch Nest unit tests with Moq : fail to mock ...
I need to mock some methods and properties in Nest.IElasticClient interface that is used in my repo. As example I need to stub...
Read more >Use CompositeExpectation.shouldReceive in Mockery with ...
Use the shouldReceive method in your next Mockery project with LambdaTest ... m::mock(IndicesNamespace::class);30 $indicesNamespace-> shouldReceive ...
Read more >Release notes | Elasticsearch-PHP [8.9]
Added a ClientInterface to simplify the mock of the Client, ... Reintroduced Elasticsearch\Namespaces\IndicesNamespace::getAliases() as proxy to ...
Read more >patch
... +### Docs +- [Docs] Updating readme with mock testing instructions (#591) ... Elasticsearch\Namespaces\IndicesNamespace + + + +Class IndicesNamespace + ...
Read more >es-php (956ecc5d) · Commits · wallet / token
include::Elasticsearch/Namespaces/IndicesNamespace.asciidoc[] ... \IndicesNamespace";s:40:"45eb11f7e963d832b6cf9a07559b38ae199d010a" ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Why make it so hard? Why can’t we just turn IndicesNamespace into an interface? That way, everyone can mock like they are used to in virtually every single other NuGet package out there, using their own mocking framework?
I have some concerns with the suggestions raised in #4076
At the end of the day, use of interfaces and mockability is considered good practices. It would be amazing if your library accepted those. Thanks!