title: RhinoMock help: Mocking WCF service
body: <p>I'm trying to use RhinoMock for mocking out a wcf service.</p>
  
  <p>Say I have the following service:</p>
  
  <pre><code>    [OperationContract]
      List&lt;User&gt; SearchUsers(UserSearchFilter filter);
  </code></pre>
  
  <p>Adding this service with Visual Studio will generate a proxy, and that proxy has a Interface like:</p>
  
  <pre><code> public interface ResourceService {
  
      System.IAsyncResult BeginSearchUsers(UserSearchFilter filter, System.AsyncCallback callback, object asyncState);
  
      ObservableCollection&lt;User&gt; EndSearchUsers(System.IAsyncResult result);
  }
  </code></pre>
  
  <p>Then I create a ViewModel that uses this service, like this:</p>
  
  <pre><code>        private ResourceService service;
      public ViewModelBase(ResourceService serv)
      {
          service = serv;
          var filter = new UserSearchFilter();
          service.BeginSearchUsers(filter, a =&gt;
          {
              this.Users = service.EndSearchUsers(a); 
          }, null);
      }
  </code></pre>
  
  <p>Then comes the question. How do I mock this service using RhinoMock? </p>
  
  <pre><code>       [TestMethod]
      public void UserGetsPopulatedOnCreationOfViewModel()
      {
          // Is stub the right thing to use?
          ResourceService serv = MockRepository.GenerateStub&lt;ResourceService&gt;();
  
          // Do some setup... Don't know how?
          var vm = new ViewModel(serv);
  
          Assert.IsTrue(vm.Users.Count &gt; 0);
      }
  </code></pre>
  
  <p>I be really happy if someone could help me with the correct usage of RhinoMock</p>
  
  <p>(Note: I'm using Silverlight, but I don't think that would change the way RhinoMock is used)</p>
  
  <p>Thanks a lot!</p>