In a current (C#) project we have a 3rd party assembly that contains a non-interfaced connection object. Using IoC, etc we can inject this concrete instance into our code, but it is proving a nightmare to unit test, etc. We are using MoQ as our mocking framework so ideally could do with an interface to work off and we don't want to go down the route of using something like Moles because we would like to minimise technologies.
If we create a interface to mimic desired functionality of the 3rd party connection object and then create an implementor of that interface containing an instance of the 3rd party object then this will allow our code to work off the interface and both our IoC and unit tests will be happy. However in a discussion we've gone around in circles as to which design pattern it really is!
So the question is, "Is the situation described above and illustrated in code below a:"
- Adapter as we are providing a wrapper to existing functionality.
- Proxy as we are provding an interface to something else.
- Facade because as part of the process we will be providing 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();
}
}
}