title: How to overrride HttpContext in mocked RewriteContex?
body: <p>I have mocked <code>RewriteContext</code>:</p>
  
  <pre><code> Mock&lt;RewriteContext&gt; rewriteContextMock = new Mock&lt;RewriteContext&gt;();
  </code></pre>
  
  <p>Then I try to override its <code>HttpContext</code> with a mock:</p>
  
  <pre><code>rewriteContextMock.Setup(x =&gt; x.HttpContext.Request).Returns(requestMock.Object);
  </code></pre>
  
  <p>unfortunately that causes</p>
  
  <blockquote>
    <p>Unsupported expression: x => x.HttpContext
        Non-overridable members (here: RewriteContext.get_HttpContext) may not be used in setup / verification expressions.'</p>
  </blockquote>
  
  <p>So what I did was</p>
  
  <pre><code> Mock&lt;HttpContext&gt; httpContextMock = new Mock&lt;HttpContext&gt;();      
   rewriteContextMock.Object.HttpContext = httpContextMock.Object;
  </code></pre>
  
  <p>But the the question raises: Is there any point in using <code>Setup()</code>, <code>Return()</code> chain when setting up the properites? Have I solved the problem correctly or I should use different approach?</p>