In the current (C #) project, we have a third-party assembly that contains a non-integrated connection object. Using IoC, etc., we can inject this particular instance into our code, but it proves the nightmare unit test, etc. We use MoQ , because our mocking structure is ideal for interacting with the interface, and we donโt want to go the way of using something like Moles , because we would like to minimize technology.
If we create an interface to simulate the desired functionality of a third-party connection object, and then create an implementer of this interface containing an instance of a third-party object, then this will allow our code to work with the interface, and both our IoC and unit tests will be happy. However, in the discussion, we revolved around what design template it really is!
So the question is: "Is the situation described above and illustrated in the code below:"
- Adapter , because we provide a wrapper for existing functions.
- Proxy as we prove the interface for something else.
- Facade , because as part of the process, we will provide a simplified interface to a larger object.
namespace ExampleCode { public interface IConnector { void Open(); } public class ConnectorWrapper : IConnector { ThirdPartyConnector _instance; public ConnectorWrapper(ThirdPartyConnector instance) { _instance = instance; } void Open() { _instance.Open(); } } }
oop design-patterns
Paul haddfield
source share