Some notes about the tests:
The first the method has a smell: Conditional Test Logic. I'd extract out the
do-while
loop to anenumeratePrimesBelow(ulong upperLimit)
method. It would improve readability a lot.-
Assert.IsFalse(Primes.IsPrime(1));
I'd create a custom assertion method for that:
public void AssertIsNotPrime(ulong value) {
Assert.IsFalse(Primes.IsPrime(value));
}
It would make the tests easier to read.
_1IsNotPrimeTest
,_2IsPrimeTest
,_3IsPrimeTest
,_42IsNotPrimeTest
etc. should be a parametrizedparameterized test. I don't know whether C# unit testing frameworks supports it or not.