title: Mocking and HttpContextBase.get_User()
body: <p>I want to mock the User property of an HttpContext.
  I'm using Scott Hanselmans MVCHelper class and RhinoMocks.</p>
  
  <p>I have a unit test that contains code, like this:</p>
  
  <p>...</p>
  
  <pre><code>MockIdentity fakeId = new MockIdentity("TEST_USER", "Windows", true);
  MockPrincipal fakeUser = new MockPrincipal(null, fakeId);
  
  using (mocks.Record())
  {
      Expect.Call(fakeHttpContext.User).Return(fakeUser);
  }
  </code></pre>
  
  <p>...</p>
  
  <p>My MockIdentity and MockPrincipal classes are mocks conforming to IIdentity and IPrincipal, respectively.</p>
  
  <p>I get an error when running the unit test that reports:</p>
  
  <blockquote>
    <p>System.NotImplementedException : The
    method or operation is not
    implemented. at System.Web.HttpContextBase.get_User()</p>
  </blockquote>
  
  <p>This is happening when I'm trying to set the expectation for the User property.</p>
  
  <p>I understand that the httpContextBase has a getter and setter that aren't implemented but I thought that Rhino would handle this when mocking. </p>
  
  <p>Does this mean that I have to derive from the HttpContextbase and override the property for my mock object. It seems odd.</p>
  
  <p>Other users have had this issue and it's reported here:
  <a href="http://www.mail-archive.com/rhinomocks@googlegroups.com/msg00546.html" rel="nofollow noreferrer">http://www.mail-archive.com/rhinomocks@googlegroups.com/msg00546.html</a></p>