How do I test a class that utilizes proxy clients generated by a Web Service Reference?
I would like to mock the client, but the generated client interface doesn't contain the close method, which is required to properly terminate the proxy. If I don't use the interface, but instead a concrete reference, I get access to the close method but loose the ability to mock the proxy.
I'm trying to test a class similar to this:
public class ServiceAdapter : IServiceAdapter, IDisposable
{
// ILoggingServiceClient is generated via a Web Service reference
private readonly ILoggingServiceClient _loggingServiceClient;
public ServiceAdapter() : this(new LoggingServiceClient()) {}
internal ServiceAdapter(ILoggingServiceClient loggingServiceClient)
{
_loggingServiceClient = loggingServiceClient;
}
public void LogSomething(string msg)
{
_loggingServiceClient.LogSomething(msg);
}
public void Dispose()
{
// this doesn't compile, because ILoggingServiceClient doesn't contain Close(),
// yet Close is required to properly terminate the WCF client
_loggingServiceClient.Close();
}
}