???????NUnit?Assertion???
???????????? ???????[ 2012/11/16 13:22:17 ] ????????
???????????????????NUnit?????£?????????????????????д???????PPT????????????????????????????????????????н????
????1??Assert??
????2??NUnit?Attribue???
????3??NUnit???
????????1??2???????????????NUnit???????????ο??????????NUnit???????????????????????????
????NUnit?Assertion???
????NUnit??.Net???????????????.Net?????????????????С?
?????κ?xUnit?????????????????????ж??NUnit??????????????????xUnit????Junit??phpUnit??pythonUnit??????????????????Generic??Attribute????????????NUnit?????????楨????????????????????????????
????Nunit????????????????????Assert??StringAssert??FileAssert??DirectoryAssert?????????NUnit.Framework???????????Assert?????????????????????????????????????????壬????????????????????????????????????????????Assert???????????????????ж??????????????????ú???????????????????????????????????????????????
???????Assert??
??????????????????????????Assert???е??????????????????д????????????Assert. AreEqual()???????????????AreEqual??NUnit?????????????????????????????
????1?????/??????ж?
????AreEqual???ж?????????
????AreNotEqual???ж???????????
?????????
Int a=1
Assert.AreEqual(a??1);//????ж?
Assert.AreEqual(a??2);//????????ж?
???????????AreEqual/ AreNotEqual?????漸?????е?????????????????????????????????????????????????Assert .AreEqual(int a??int b)?????????????????????
??Assert.AreEqual(inta??intb??stringmessage);
?????? Assert.XXX(inta??intb??stringmessage);
???????е?????????????????????????????????????????λ
????????double??decimal???????????????????????????????
???????????′???
doublea = 1.1;
doubleb = 1.11;
doublec = 0.1;
Assert.AreEqual(a?? b?? c);//????ж?
c=0.01;
Assert.AreEqual(a?? b?? c);//????????ж?
????2??????ж?
????AreSame???ж????????????
????AreNotSame???ж????????????
????Contains???ж????????????
?????????
List
list.Add("a");
list.Add("b");
Assert.Contains("a"?? list); //????ж?
Assert.Contains("aa"?? list); //????????ж?
????3???????ж?
????IsTrue???ж????????
????True?????
????IsFalse???ж????????
????False?????
????IsNull???ж???????
????Null?????
????IsNotNull???ж??????
????NotNull?????
????IsNaN???ж??????Nan
????IsEmpty/IsNotEmpty???ж????????????/?????
????IsEmpty/IsNotEmpty???ж??????????/?????
?????????
??inta=100;
??Assert. IsTrue(a==100);//????ж?
??Assert. True(a==100);//????ж?
????4??????ж?
????Greater??????
????GreaterOrEqual?????????
????Less??С??
????LessOrEqual??С?????
?????????
inta = 100;
Assert.Greater(a?? 99);
Assert.GreaterOrEqual(a?? 100);
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11