Closed sirdawidd closed 2 months ago
Hi @sirdawidd, From your comment, it seems like you're attempting Unit Testing with a Mocking library (e.g., Moq), and the absence of interfaces for DocuSignClient and possibly other classes is causing an issue.
Please correct me if I'm mistaken. If I'm understanding correctly, I'd recommend considering the Adapter pattern to test the DocuSignClient. You can find an example in this post which may help you achieve this.
The Gist is that: To test the concrete class using the Adapter pattern, create an adapter that implements the interface expected by the test, and use it to adapt the concrete class for testing. This allows you to isolate the class under test from its dependencies.
Thank You.
Hello, adapter pattern would not work and it’s a pain when you need to update the package, to redefine adapter. By not having interfaces in this repo is a SOLID pattern violation.
Hi @sirdawidd. Could you provide your specific use case? Is the pain point limited to the DocusignClient, or are there other classes that currently require interfaces?
Additionally, could you explain why the Adapter pattern wouldn't work in this scenario?
Thank You.
Hello, imagine that you have Docu sign package version 1 class Class DS{ Int someMethod(int p1,int p2){} } I wrote for that adapter. Then updated package to version 1.2
Class DS{ Int someMethod(sting p1,int[] p2){} }
Then what I need is to update my code to adjust package, then adapter, tests for adapter, and tests to my code. If I don’t have this beautiful idea of adapter and this package delivered interfaces as it should I needed adjust my code and test, do you see the difference now? Not mention that I can’t use DI for static classes, and here I have only static methods where each time I need to initialise parameters which will never change like client id. Best
Hi @sirdawidd, Following an internal discussion, we've decided not to include the interface for the DocusignClient at this time. Here are a few reasons for this decision:
We can certainly revisit this topic in the future if there is increased demand from multiple developers. Thank you for your understanding.
Hello, would be great if someone could add interfaces to that repo, as it’s really hard to use it if we need to rely on concrete classes ( not possible to test, or Di).