Most of the time when we use Rhino mocks it works well, but we have problems mocking objects created using the using statements.
We have a WCF proxy that is implemented as follows:
public class MyProxy : System.ServiceModel<IMyProxy>, IMyProxy
{
public Response DoWork(Request request)
{
return base.Channel.DoWork(request);
}
}
Normally in our business layer we would have a property:
IProxy MyProxy;
Which we could set as being the mocked interface.
But when we use a using statement, our business layer looks like this:
using (MyProxy proxy = new MyProxy())
{
}
Which instanciates the concrete implementation of the class.
How do we get the business layer to use the mock created with Rhino mocks?
Edit
It turned out that you should not use using statements with wcf proxies http://msdn.microsoft.com/en-us/library/aa355056.aspx