????????е???ò?????
???????????? ???????[ 2011/9/7 11:23:20 ] ????????
??????????????????????Щ??????????????????????Щ????????????е??????C#?????????????????????????????????????
???? 1?????????У?????(Arrange?? Act?? Assert)????????????????????????????????е??????????????????£?
????1???????????????????????
????2????б????????
????3??????????????н??
????????????β????????????????????????????????????????????д?????????????????????
[TestMethod()]
public void CapitalizeTest()
{
//???????
string input = "hello world!";
string expected = "HelloWorld_";
//??в???
string actual;
actual = TextHelper.Capitalize(input);
//??????
Assert.AreEqual(expected?? actual);
}
????2????????????????????????????Щ???????????в????????????????????????????????????????????????????????????????仯????????????????????????????????á????????????£?
????1????????????
????2??????????????????
????3??????????????н??
????????????δ????????????????飬??????????飬?????????????С????б仯??
[TestMethod]
public void TestInvariant()
{
//??????????
int capacity = 5;
int[] intArray = new int[capacity];
//???е???
for (int i = 0; i < intArray.Length; i++)
{
intArray.SetValue(i?? i);
}
//??????
Assert.AreEqual(capacity?? intArray.Length);
}
????3?????????(Roundtrip)??????????????????????????淽???????????á??????????????f-1(f(x)) = x
????????????????????
[TestMethod]
public void RoundTripTest()
{
string str = "10";
//???????????????????????????????
int i = Int32.Parse(str);
string finalString = i.ToString();
// ??????
Assert.AreEqual(str?? finalString);
}
??????
???·???
??????????????????
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