???????NUnit?Assertion???
???????????? ???????[ 2012/11/16 13:22:17 ] ????????
????5???????ж?
????IsInstanceOfType/ IsNotInstanceOfType????/?????????????????2.5??????????
???????磺
publicclassPerson
{
publicstringname {set;get;}
}
Person p = newPerson();
p.name = "a";
Assert.IsInstanceOf(typeof(Person)?? p);//????ж?
Assert.IsInstanceOf(typeof(System.String)?? p);//????????ж?
????6?????ж?
????Throws????????????????
????DoesNotThrow??????????????????
????7??????????????
????Pass??????ò??????
????Fail??????ò??????
????Ignore??????ò??????
????Inconclusive??δ????ò???
????????StringAssert??
????StringAssert????String?????????ж??
????StringAssert.Contains???????????
????StringAssert.StartsWith??????????????
????StringAssert.EndsWith?????????????β
????StringAssert.AreEqualIgnoringCase??????????????????????Сд????
????StringAssert.IsMatch????????(??????????????????????)
?????????
strings1 = "abc";
??StringAssert.Contains("b"?? s1);
??StringAssert.StartsWith("a"?? s1);
StringAssert.EndsWith("c"?? s1);
strings2 = "aBc";
StringAssert.AreEqualIgnoringCase(s1?? s2);
StringAssert.IsMatch("[a|book]"?? "123");
????????CollectionAssert??
????AllItemsAreInstancesOfType???????е???????????????????
????AllItemsAreNotNull:?????е??????????
????AllItemsAreUnique???????е????
????AreEqual?????????????
????AreEquivalent????????????
????AreNotEqual??????????????
????AreNotEquivalent?????????????
????DoesNotContain???????в??????????
????IsSubsetOf:????????????????????????
????IsNotSubsetOf:?????????????????????????
????IsEmpty?????????
????IsNotEmpty??????????
????IsOrdered?????????????????
?????????
List
List
CollectionAssert.IsEmpty(a);
for(inti = 1;i <= 10;i++)
{
a.Add(i);
b.Add(i);
}
CollectionAssert.AreEqual(a?? b);
CollectionAssert.IsOrdered(a);
b.Remove(1);
CollectionAssert.IsSubsetOf(b?? a);
CollectionAssert.AreEqual(a?? b);
????????????NUnit????????????Щ???????????????????????.Net????????????????NUnit????????????????????????NUnit????????????????????
??????
???·???
??????????????????
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