So I have a Application that currrently uses the EAGetMail nuget package for scraping EmailServers. I am attempting to refactor my project and interface individual pieces for mocking in Unit Tests. My current issue is the classes in the package don’t seem to be interfaced and I am not sure if interfacing them indirectly would work. Could just be a lack of understanding or a different way tenter image description hereo mock the data is needed. Anything would help!
>Solution :
As the classes are also sealed, there are no options to create mocks directly. If you are refactoring your codebase anyway, your best option would be to put all the email related stuff in wrapper classes and create an interface for these wrappers.
Mocking those interfaces is easy, plus you have the code that depends on the component assembled in one place. If you decide to move on to another package later on, your changes are better that you only need to change the wrapper classes and not several spots in your codebase.
As regards unit testing the wrapper classes, those should be as thin as possible. The package publisher should unit test its components, so there would not be anything left to test in the wrappers.