title: Easy way to mock a WCF service?
body: <p>I've got an app which is using a WCF service. Now I'd like to add unit tests to the app.</p>
  
  <p>For some cases I need to mock the WCF service, since getting the desired behaviour from the service sometimes is tough (e.g. service throws special exceptions).</p>
  
  <p>I could add yet another interface to the wcf client, but this seems a bit silly, since the client calls already are using an interface.</p>
  
  <p>Is there an easy way to mock a WCF service? Easier than creating another interface layer and redirecting every single WCF call inside it?</p>
  
  <p>Edit: Most of the answers seem not to know much about WCF service using, so some clarification:<br>
  To use a WCF service from a ViewModel, I have to manage the connection something like this:</p>
  
  <pre><code>ChannelFactory&lt;IMyWcfService&gt; channelFactory = new ChannelFactory&lt;IMyWcfService&gt;("");
  IMyWcfService proxy = channelFactory.CreateChannel();
  proxy.CallMyStuff();
  proxy.Close();
  </code></pre>
  
  <p>I can't just pass the ViewModel the proxy to the WCF, since the connection needs to be opened and closed for every transaction. For this reason using RhinoMock/NMock would not work, since they need a ViewModel which gets the proxy as a parameter, which can't be done like this if you use WCF.</p>