unit tests using StackExchange.Redis

15 views Asked by At

I am using StackExchange.Redis in .NETCore project.

Now, I am supposed to add ConnectionMultiplexer object as singleton. But then I am not able to write the unit tests.

In the documentation it recommends to spin up a redis docker container, but is it possible to have something like a in-memory db. And then I can write my redis UT's.

This is also stopping me to do open telemetry istrumentation of Redis.

services.AddSingleton<IConnectionMultiplexer>(ConnectionMultiplexer.Connect("<redisConnectionString>"));

I am expecting that when it builds, it should be able to run unit tests with in-memory db instead of using a docker container.

Anyways if you've done it with docker container, any reference to your code will also help.

0

There are 0 answers