Doing any automated testing on code which touches the EventStoreClient class is really annoying because you can’t (among other things) stub the methods you’re using for your tests.
Is there a specific reason why there is no interface for this class?
Our client is similar to HttpClient
, which doesn’t have an interface. Testing with a fake client doesn’t really tell you if things are going to work. In general, it is considered an anti-pattern to mock dependencies on infrastructure.
It is not hard to create tests using the actual database running. You can use something like Testcontainers, which also have an ESDB package.
Here’s an example how I set up tests for ESDB in Eventuous.
1 Like