Unit Testing for isPrime function
Methods in C# are written in PascalCase, so let's change isPrime to IsPrime.

You can use LINQ to make the code a bit clearer. Instead of


for (var i = 0; i &lt; numbers.Length; i++)
{
    Assert.IsTrue(Numbers.isPrime(numbers[i]));
}



You can write

Assert.IsTrue(numbers.All(Numbers.IsPrime));


Instead of


for (var i = 0; i &lt; numbers.Length; i++)
{
    Assert.IsFalse(Numbers.isPrime(numbers[i]));
}



You can write

Assert.IsFalse(numbers.Any(Numbers.IsPrime));


or

Assert.IsTrue(numbers.All(n =&gt; !IsPrime(n)));


whichever you find easier to read (I prefer the former).

In fact, I would be a bit lazy and copy a big list of prime numbers from somewhere and then write

var primes = Enumerable.Range(0, 1000000).Where(Numbers.IsPrime);
Assert.IsTrue(primes.SequenceEqual(PrimesLessThanOneMillion));




If you take @mleyfman's suggestion to test with randomly generated primes, be sure to seed the random number generator. Unit tests must be reproducible.

That is, never do this

var random = new Random();


but do this

var random = new Random(42);


One of the benefits of unit tests is that if they fail, you know it is due to a change in the code, and can then git bisect (or similar) to find the breaking commit. If a unit test fails due to something that is not a change to the code (e.g. a different RNG seed) you have lost this important benefit.

Edit: as @svick pointed out, using the same seed may not generate the same sequence between different versions or implementations of .NET. See these answers on StackOverflow. If all dev machines (including the build server) are running the same version of .NET, you should be fine.