title: How to MapPath in a unit test in C#
body: <p>I want to load an external XML file in a unit test to test some processing code on that XML.  How do I get the path of the file?</p>
  
  <p>Usually in a web app I would do:</p>
  
  <pre><code>XDocument.Load(Server.MapPath("/myFile.xml"));
  </code></pre>
  
  <p>But obviously in my unit test I have no reference to Server or HttpContext so how can I map a path so that I don't have to specify the full path?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I just want to make it clear that the code I'm actually testing is for an XML parser class, something like:</p>
  
  <pre><code>public static class CustomerXmlParser {
    public static Customer ParseXml(XDocument xdoc) {
      //...
    }
  }
  </code></pre>
  
  <p>So to test this I need to parse a valid XDocument.  The method being tested does not access the file system itself. I could create the XDocument from a String directly in the test code but I thought it would be easier to just load it from a file.</p>