title: Testing Approach for XDocument.Load() and XDocument.Save()
body: <p>I am working with XDocument within an MVC4 Web API application in Visual Studio 2010 and am unsure about the testing strategy.</p>
  
  <p>Most of my unit tests make use of an in memory XDocument, which works well for controller, service, repository tests.</p>
  
  <p>However, I have the <code>XDocument.Load(filename)</code> and XDocument.Save(filename) scenarios, which I would like to test (either with unit or integration tests).</p>
  
  <p>I have been looking at the following question\answer on <a href="https://stackoverflow.com/questions/1261729/c-sharp-unit-testing-testing-a-method-that-uses-mappath">SO here</a> but I'm not sure how to proceed.</p>
  
  <pre><code>public class PathProvider
  {
     public virtual string GetPath()
     {
        return HttpContext.Current.Server.MapPath("App_Data/policies.xml")
     }
  }
  
  PathProvider pathProvider = new PathProvider();
  XDocument xdoc = XDocument.Load(pathProvider.GetPath());
  </code></pre>
  
  <p>So, I get that I can now mock calls to whatever calls XDocument.Load(pathProvider.GetPath()).</p>
  
  <p>Should I then be trying to test that PathProvider works?  If, so, How would I approach this?</p>
  
  <p>Thanks</p>
  
  <p>Davy</p>