title: Mocking WebResponse's from a WebRequest
body: <p>I have finally started messing around with creating some apps that work with RESTful web interfaces, however, I am concerned that I am hammering their servers every time I hit F5 to run a series of tests..</p>
  <p>Basically, I need to get a series of web responses so I can test I am parsing the varying responses correctly, rather than hit their servers every time, I thought I could do this once, save the XML and then work locally.</p>
  <p>However, I don't see how I can &quot;mock&quot; a WebResponse, since (AFAIK) they can only be instantiated by <strong>WebRequest.GetResponse</strong></p>
  <p>How do you guys go about mocking this sort of thing? Do you? I just really don't like the fact I am hammering their servers :S I dont want to change the code <em>too</em> much, but I expect there is a elegant way of doing this..</p>
  <h2>Update Following Accept</h2>
  <p>Will's answer was the slap in the face I needed, I knew I was missing a fundamental point!</p>
  <ul>
  <li>Create an Interface that will return a proxy object which represents the XML.</li>
  <li>Implement the interface twice, one that uses WebRequest, the other that returns static &quot;responses&quot;.</li>
  <li>The interface implmentation then either instantiates the return type based on the response, or the static XML.</li>
  <li>You can then pass the required class when testing or at production to the service layer.</li>
  </ul>
  <p>Once I have the code knocked up, I'll paste some samples.</p>