某 .net 2.0 C# 类库 Foo.Test 中新建『应用程序配置文件』App.config,内容如下:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  
<appSettings>
    
<add key="testkey" value="abc123"/>
  
</appSettings>
</configuration>

编写单元测试用例:

        [Test]
        
public void AppConfigTest()
        {
            
            
string tester = System.Configuration.ConfigurationManager.AppSettings["testkey"].ToString();
            Console.WriteLine(tester);
        }


TestDriven.NET ... Run Test(s) 输出结果:

------ Test started: Assembly: Foo.Test.dll ------

abc123

1 passed, 0 failed, 0 skipped, took 1.41 seconds.

相关文章:

  • 2021-08-09
  • 2021-10-26
  • 2021-07-30
  • 2022-12-23
  • 2022-12-23
  • 2021-07-01
  • 2021-08-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-04
  • 2022-12-23
  • 2022-01-10
  • 2022-01-30
相关资源
相似解决方案