title: Rhino Mocks: How do I mock a method call within a method call?
body: <p>I have a really simple class with two methods; One that will be called and the other that it will call.  The idea is to call the OuterMockMethod method BUT mock the InnerMockMethod.  Right now I can only seem to mock the OuterMockMethod method.</p>
  
  <pre><code>public class MockClass : IMockInterface
  {         
      public virtual MockClass InnerMockMethod()
      {
        MockClass returnValue;
  
        returnValue = new MockClass();
        returnValue.SomeMessage = "Not mocked";
  
        return returnValue;
      }
  
      public virtual MockClass OuterMockMethod()
      {
        MockClass mock;
  
        mock = new MockClass();
  
        return mock.MockedMethod();
      }
  }
  </code></pre>
  
  <p>Now this works, but it isn't the method I want to mock:</p>
  
  <pre><code> public void MockTest_Internal()
   {
       MockClass returnedClass;
       MockClass mockProvider;
  
       mockProvider = repository.StrictMock&lt;MockClass&gt;();
       mockProvider.Expect(item =&gt; item.OuterMockMethod())
         .Return(new MockClass { SomeMessage = "Mocked" });
       repository.Replay(mockProvider);
  
       returnedClass = mockProvider.OuterMockMethod();
  
       Assert.IsTrue(returnedClass.SomeMessage == "Mocked");
   }
  </code></pre>
  
  <p>As you can see, it calls the OuterMockMethod which it likes but I don't want that.  I want to mock the InnerMockMethod so that when it's called by the OuterMockMethod it will return what I want it to.</p>
  
  <pre><code> public void MockTest_Internal()
   {
       MockClass returnedClass;
       MockClass mockProvider;
  
       mockProvider = repository.StrictMock&lt;MockClass&gt;();
       mockProvider.Expect(item =&gt; item.InnerMockMethod())
         .Return(new MockClass { SomeMessage = "Mocked" });
       repository.Replay(mockProvider);
  
       returnedClass = mockProvider.OuterMockMethod();  //Boom angry Rhino
  
       Assert.IsTrue(returnedClass.SomeMessage == "Mocked");
   }
  </code></pre>