, System.Diagnostic.StopWatch NUnit , .
primes [SetUp] ( ), , generatePrimes, , , 5 . , , , , .
[Test]
public void checkGeneratePrimesUpToTenMillion()
{
System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
timer.Start();
long[] primeArray = primes.generatePrimes(10000000);
timer.Stop();
Assert.AreEqual(664579, primeArray.Length, "Should be 664,579 primes below ten million");
int elapsedSeconds = timer.Elapsed.Seconds;
Console.Write("Time in seconds to generate primes up to ten million: " + elapsedSeconds);
bool ExecutionTimeLessThanFiveSeconds = (elapsedSeconds < 5);
Assert.IsTrue(ExecutionTimeLessThanFiveSeconds, "Should take less than five seconds");
}