单元测试必须了解一下

System.IO.FileInfo file  = null;

System.IO.FileInfo file1  = file;

System.IO.DirectoryInfo dir  = null;

string tempTrue = "T";

string tempFalse = "F";

 

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

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

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

 

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

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

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

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

 

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

Assert.IsNull(tempFalse);    //不是空所以测试失败  

原文地址:https://www.cnblogs.com/shen119/p/4766611.html