Closed sparten11740 closed 3 years ago
Hello,
I wrote this library as a necessity for other projects so I was more worried with functionality than anything else :)
I'm not very familiar with testing methodologies so I would appreciate some help. Is this just a matter of extracting the interfaces? I've pushed the simplest change i could to try and resolve this. Please tell me if I understood the request.
Hi @diogotr7, yes it just a matter of extracting interfaces (so the commit solves that issue). The thing with classes without interfaces that have only non virtual methods is that there is no convenient way of mocking them, so mocking libraries such as Moq cannot be used on them. Here you can see an example of the kind of behaviour that I mocked in my application to test my classes in isolation. Due to the class not having an interface, I used Unmockable
which wraps the class to be mocked in a wrapper. You basically get a IUnmockable<OpenRGBClient>
. This same type has then to be used for the dependency in the constructor of the actualy application code. With an interface IOpenRGBClient
the class is mockable out of the box and I can simply use the interface IOpenRGBClient
as my constructor dependency. Moq then creates a mock that implements that interface and this mock is then provided as a dependency in the test code.
Tldr; what you did is the solution to this issue, thanks for the effort :)
I've just submitted version 1.5.0 to Nuget. If you have any more requests / suggestions feel free to make another issue!
Hi there,
I think it might be a good idea to extract an interface at least from the client itself (maybe even for the models since the setters are private). I am using your library but it gave me a hard time to unit test my own project since it is not properly mockable. Had to fallback to using https://github.com/riezebosch/Unmockable to get around the mockability issues. What's your opinion on that? Would also be happy to lend a hand if that helps ;)