title: using WebConfigurationManager in unit tests
body: <p>I'm trying to write some unit tests that test code which alter web.config runtime. To load Web.config, WebConfigurationManager.OpenWebConfiguration is used. This does not work well in Unit tests.</p>
  
  <p>What options do I have? I've tried:</p>
  
  <ol>
  <li><p>Configure the test as an ASP.NET-test with method attributes. This seems brittle because you need to hard code the port on which the development server runs with [UrlToTest("http://localhost:25153/WebSite1")] . I need the test to run on multiple computers configured differently. Also I feel it's overkill to launch an IIS server just to be able to load a text file in a unit test.</p></li>
  <li><p>Load the config from disk using other methods. I've tried configurationManager.OpenExeConfiguration(), and I get a Configuration object back, but this doesn't seem to have been parsed correctly. Specifcially the sessionState section under system.web, which is a web-specific setting so that is not very surprising.</p></li>
  </ol>
  
  <p>Where do I go from here?</p>