StackExchange.Redis icon indicating copy to clipboard operation
StackExchange.Redis copied to clipboard

IConnectionMultiplexer.GetCounters not unit testable

Open lfoust opened this issue 8 years ago • 2 comments

Since the ServerCounters class does not have a public constructor you cannot mock IConnectionMultiplexer.GetCounters() in unit tests. The solution would be to either add a public constructor to this class or to make the IConnectionMultiplexer.GetCounters() return an interface rather than a concrete class so that it could be easily mocked.

I don't mind creating a pull request for this but I wanted to get thoughts or workarounds first.

lfoust avatar Jun 14 '18 21:06 lfoust

@mgravell Any issue with making internal ServerCounters(EndPoint endpoint) public?

NickCraver avatar Jul 02 '18 20:07 NickCraver

This is now exposed in the 2.0 (pipelines) branch as well as the .Multiplexer property on IAsyncRedis and friends being an IConnectionMultiplexer instead of a concrete ConnectionMultiplexer. This should round out being able to mock the primary pieces for testing.

NickCraver avatar Jul 03 '18 13:07 NickCraver