title: Mocking HttpPostedFileBase and InputStream for unit-test
body: <p>I want to test the following line of code:</p>
  
  <pre><code>...
  Bitmap uploadedPicture = Bitmap.FromStream(model.Picture.InputStream) as Bitmap;
  ...
  </code></pre>
  
  <p>Picture is a property in my model type HttpPostedFileBase.
  So I would like to mock a HttpPostedFileBase property for unit-testing:</p>
  
  <pre><code>model.Picture = new Mock&lt;HttpPostedFileBase&gt;().Object;
  </code></pre>
  
  <p>No problem at all.</p>
  
  <p>Now I have to mock the InputStream, otherwise it's null:</p>
  
  <pre><code>model.Picture.InputStream = new Mock&lt;Stream&gt;().Object;
  </code></pre>
  
  <p>This isn't working as the InputStream is read-only (hasn't a setter method):</p>
  
  <pre><code>public virtual Stream InputStream { get; }
  </code></pre>
  
  <p>Is there a good and clean way to handle this problem?
  One solution would be to override HttpPostedFileBase in a derived class for my unit-test.
  Any other idea?</p>