Use adapter pattern for coupled classes

Posted by kaiseroskilo on Programmers See other posts from Programmers or by kaiseroskilo
Published on 2014-05-09T14:13:26Z Indexed on 2014/06/06 21:50 UTC
Read the original article Hit count: 310

Filed under:
|

I need (for unit testing purposes) to create adapters for external library classes.ExchangeService and ContactsFolder are Microsoft's implementations in its' EWS library. So I created my adapters that implement my interfaces, but it seems that contactsFolder has a dependency for ExchangeService in its' constructor. The problem is that I cannot instantiate ContactsFolderAdapter without somehow accessing the actual ExchangeService instance (I see only ExchangeServiceAdapter in scope).

Is there a better pattern for this that retains the adapter classes? Or should I "infect" ExchangeServiceAdapter with some kind of GetActualObject method?

enter image description here

© Programmers or respective owner

Related posts about c#

Related posts about design-patterns