单元测试必须了解一下

System.IO.FileInfo file  = null;测试

System.IO.FileInfo file1  = file;对象

System.IO.DirectoryInfo dir  = null;string

string tempTrue = "T";file

string tempFalse = "F";di

 

Assert.AreEqual(tempTrue, tempFalse); //两个对象不相同,测试失败sse

Assert.AreNotSame(file1, tempTrue); //两个引入的对象是同一个,测试失败"co

Assert.AreSame(file1, file);  //两个引入的对象是不相同的

 

Assert.Fail();          //不论是什么,直接宣布测试失败

Assert.Inconclusive();  //同Fail差很少,但不是失败,只是测试不能经过

Assert.IsFalse(true);  //若是是真,表示测试失败

Assert.IsTrue(false);  //若是为假,请示测试失败

 

Assert.IsInstanceOfType(true,tempTrue.GetType());  //类型不相同,测试失败

Assert.IsNull(tempFalse);    //不是空因此测试失败  

相关文章
相关标签/搜索