FreeRedis icon indicating copy to clipboard operation
FreeRedis copied to clipboard

Create mock RedisClient for testing purpose.

Open minhdanghuu opened this issue 2 years ago • 5 comments

Since RedisClient does not have a proper interface, so if i want to write a mock RedisClient ( for unit testing), i have to inherit RedisClient class. But it seem be hard since it's method is not abtract or virtual method. Is there anyway to do it ?.

minhdanghuu avatar Apr 20 '22 03:04 minhdanghuu

Because there are so many methods and each method only executes simple commands, there is no interface defined.

You can establish your own interface and call redisclient in the implementation part. It is also convenient to replace components in the future.

2881099 avatar Apr 20 '22 04:04 2881099

That mean I have to add an extra class ( and interface) to wrap RedisClient. Look into the code, I see another way: I could create a new Adapter implementation ( since RedisClient methods is actual calling Adapter.Call). You have it (interface) in your other work ( FreeSQL). It is a nice library. So hope to see it in the future in FreeRedis too 😃.

minhdanghuu avatar Apr 20 '22 05:04 minhdanghuu

I have work done by using Visual studio refactor. If you have time, take a look: #91

dangminhbk avatar Apr 21 '22 09:04 dangminhbk

Thank you for your dedication. The interface method needs to improve the code summary

2881099 avatar Apr 21 '22 12:04 2881099

v0.5.1

2881099 avatar Apr 22 '22 04:04 2881099