????????
????????????д????????????????????????????????е?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[] {});
}
}
}