某 .net 2.0 C# 类库 Foo.Test 中新建『应用程序配置文件』App.config,内容如下:
编写单元测试用例:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="testkey" value="abc123"/>
</appSettings>
</configuration>
<configuration>
<appSettings>
<add key="testkey" value="abc123"/>
</appSettings>
</configuration>
编写单元测试用例:
[Test]
public void AppConfigTest()
{
string tester = System.Configuration.ConfigurationManager.AppSettings["testkey"].ToString();
Console.WriteLine(tester);
}
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.