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

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

I have the folowing tests:

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


        
6条回答
  •  执念已碎
    2021-02-13 23:29

    Assuming you are trying to access values in appSettings, how about just adding the configuration at the beginning of your test. Something like:

    ConfigurationManager.AppSettings["Key"] = "Value";
    

    Then when your test tries to read the AppSettings "Key", "Value" will be returned.

提交回复
热议问题