Is there a way to get a System.Configuration.Configuration instance based on arbitrary xml?

前端 未结 3 1911
清酒与你
清酒与你 2020-12-06 05:42

I\'m trying to unit test a custom ConfigurationSection I\'ve written, and I\'d like to load some arbitrary configuration XML into a System.Configuration.Configuration for ea

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-06 06:01

    I think what you're looking for is ConfigurationManager.OpenMappedExeConfiguration

    It allows you to open a configuration file that you specify with a file path (wrapped inside a ExeConfigurationFileMap)

    If what the other poster said is true, and you don't wish to create a whole new XML file for testing, then I'd recommend you put your Configuration edits in the Test method itself, then run your tests against the freshly changed configuration data.

提交回复
热议问题