How To Read UnitTest Project's App.Config From Test With HostType(“Moles”)

后端 未结 6 1444
夕颜
夕颜 2021-02-13 23:02

I have the folowing tests:

[TestClass]
public class GeneralTest
{
    [TestMethod]
    public void VerifyAppDomainHasConfigurationSettings()
    {
        string         


        
6条回答
  •  感动是毒
    2021-02-13 23:40

    I ran across this issue at work and didn't like any of these answers. I also have the problem that the configuration file is being read in a static constructor which means I can't Mole ConfigurationManager before the static constructor is executed.

    I tried this on my home computer and found that the configuration file was being read correctly. It turns out I was using Pex 0.94.51006.1 at home. This is slightly older than the current one. I was able to find a download for the older academic version: http://research.microsoft.com/en-us/downloads/d2279651-851f-4d7a-bf05-16fd7eb26559/default.aspx

    I installed this on my work computer and everything is working perfectly. At this point, I'm downgrading to the older version until a newer working version is released.

提交回复
热议问题