??.Net????????д???????
???????????? ???????[ 2015/5/29 11:12:24 ] ???????????????
????????
????????????д????????????????????????????????е?bug??Just do it??
?????????????????????
????Win7 OS
????Visual Studio 2012 IDE
????.Net Framework 4.5
????Resharper ??username:ronle ?? key:ZoJzmeVBoAv9Sskw76emgksMMFiLn4NM??
????NUnit Framework(Installed by NuGet package manage tool)
????Windows Console Application Project in C# Programming (Just an project example??you could use Unit Testing in other project such as Mvc??WCF??Web Service )
???????????
????????????????????????????list?е?????
????1.???????
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UnitTestDemo
{
public class Cmp
{
public static int Largest(int[] list)
{
int max = Int32.MinValue;
if (list.Length == 0)
{
throw new AggregateException("Empty list");
}
for (int index=0; index < list.Length; index++)
{
if (list[index] > max)
{
max = list[index];
}
}
return max;
}
}
}
????2.??????????д????????
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using UnitTestDemo;
namespace UnitTestDemo.Test
{
[TestFixture]
public class TestCmp
{
[Test]
public void LargestOfNegative()
{
Assert.AreEqual(-7??Cmp.Largest(new int[]{-9??-7??-8}));
}
[Test??ExpectedException(typeof(AggregateException))]
public void LargestOfEmpty()
{
Cmp.Largest(new int[] {});
}
}
}
??????
???·???
??????????????????
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