0

I'm trying to write some unit tests for an existing order sending routine: this routine extract an order using entity framework, map the data from the ef classes to the routines exposed by the webservice, and send to the web service.

I would like to Create a shim of a web service, so I can trap the routine that send the order , recover the object sent amnd test it.

How can I create a shim of the proxy class?

thanks luca

Luca Morelli
  • 2,530
  • 3
  • 28
  • 45
  • 1
    This appears to be the general documentation: http://msdn.microsoft.com/en-us/library/hh549176.aspx. Did you have specific questions about that? – Robert Harvey Apr 08 '13 at 17:03

1 Answers1

-1

If i'm not mistaken with your question, you can use here dependency injection for testing proxy classes.

you can do something like this

public class SampleClass
{
   ITestServices _testServices;
   SampleClass(ITestServices testServicesObj)
   {
     _testServices = testServicesObj;
   }
   public string OrderSent()
   {
     return "Orders " + _testServices.OrdersSent().ToString();
   }
}

In your test, pass in the mock object

Jhigs
  • 147
  • 4
  • the problem is that the proxy class is generated by the wizard, and doesn't define and/or implement any interface, and it's regenerated at every update, so it's easy to create this interface. public class OperationsSoapClient : System.ServiceModel.ClientBase Member of Thd.SgMyWs The only thing I can try is to generate manually an interface compatible with the prozy class, add a partial class to the proxy class just to add the interface, but if the wizard doesn't create the proxy class as partial I don't think I can do this. – Luca Morelli Apr 09 '13 at 09:46
  • He is specifically asking about the Microsoft Shims framework. – AlwaysAProgrammer Jul 30 '13 at 00:49