For unit testing, I'm running an in-memory server using the System.Web.Http.HttpServer
class. It chokes when attempting to instantiate Enterprise Library objects, because Enterprise Library (v5.0.414.0) is configured in the XML configuration file App.config
, which isn't being read.
Is it possible to read in the .config
file, or am I forced to start a local server (e.g. WcfSvcHost.exe
)?
UPDATE:
I'm able to load the configuration thusly (from How to OpenWebConfiguration with physical path?):
var wcfm = new System.Web.Configuration.WebConfigurationFileMap();
var vdm = new System.Web.Configuration.VirtualDirectoryMapping( @"C:\MyPath\", true, "App.config" );
wcfm.VirtualDirectories.Add( "/", vdm );
var cfg = System.Web.Configuration.WebConfigurationManager.OpenMappedWebConfiguration( wcfm, "/" );
However, I don't know of any straightforward way to pass that data to the HttpServer
object (cfg
is a Configuration
type, apparently of no relation to the HttpConfiguration
type found in HttpServer
constructors).
I wanted to avoid implementing an IISExpress solution, but it looks as though I'm forced to go that route in order to support Enterprise Library 5 lameness.