读取文件时,路径的设置下面3种都可以:
ContractedBlock.gif ExpandedBlockStart.gifView Code protected void ReadUserName()
{
//string path = "c:\\temp/passport.txt";
//string path = "c:/temp/passport.txt";
string path = "c:\\temp\\passport.txt";
int maxNum = 0;
using (StreamReader sr = new StreamReader(path, Encoding.GetEncoding("gb2312")))
{
string uname;
while ((uname = sr.ReadLine()) != null)
{
maxNum++;
uname = uname.Split(',')[1];
}
}
Assert.AreEqual(2, maxNum);
}


使用TestDriven.NET 3 单元测试
1 在安装目录TestDriven.NET 找到Nunit.Framwork.dll,在项目引用中添加
2 测试类文件头添加using NUnit.Framework;
3
4 每一种都有可以测试通过