public static void EnterNumbers() { long first = 1; long last = 0; Console.Write(" Enter first number: "); first = long.Parse(Console.ReadLine()); Console.Write(" Enter last number: "); last = long.Parse(Console.ReadLine()); Console.WriteLine(); PrimeGenerator primegenerator = new PrimeGenerator(); List <long> primesSequantial = new List <long>(); List <long> primesParallel = new List <long>(); Console.WriteLine("Sequential calculation is running..."); Console.WriteLine("To stop the operation, press Esc"); MessureTime(() => { primesSequantial = primegenerator.GetPrimesSequential(first, last); }); PrintInfo(primesSequantial); Console.WriteLine("Parallel calculation is running..."); Console.WriteLine("To stop the operation, press Esc"); MessureTime(() => { primesParallel = primegenerator.GetPrimesParallel(first, last); }); PrintInfo(primesParallel); Console.WriteLine("Press any key to continue"); Console.ReadKey(); }
public void Can_Return_Values_Comma_Delimited() { var primeGenerator = new PrimeGenerator(new PrimeEvaluationEngine()); string actual = primeGenerator.GeneratePrimesUpTo(10); Assert.AreEqual("2,3,5,7,9", actual); }
private static void Main(string[] args) { var primeGenerator = new PrimeGenerator(new PrimeEvaluationEngine()); var results = new OutputFormatter().Format(primeGenerator.GeneratePrimesUpTo(10000)); results.ForEach(Console.WriteLine); Console.WriteLine("--- hit enter to exit --"); Console.ReadLine(); }
public void Every_Tenth_Line_Contains_Count() { var generatedPrimes = new PrimeGenerator(new PrimeEvaluationEngine()).GeneratePrimesUpTo(2000); var outputFormatter = new OutputFormatter(); IList<string> formattedOutput = outputFormatter.Format(generatedPrimes); for (int i = 10; i < formattedOutput.Count; i += 11) { Assert.IsTrue(formattedOutput[i].Contains("Count:")); } }
public static MathTable CreatePrimeMultiplicationTable(int n) { List <object> primes = new List <object>(); Func <object, object, object> multiplier = (o1, o2) => (int)o1 * (int)o2; Func <object, string> formatter = (o) => o.ToString(); for (int i = 0; i < n; i++) { primes.Add(PrimeGenerator.PrimeNumber(i)); } return(new MultiplicationTable(primes, primes, multiplier, formatter)); }
public void Can_Return_Empty_String() { var primeGenerator = new PrimeGenerator(new PrimeEvaluationEngine()); Assert.AreEqual(string.Empty, primeGenerator.GeneratePrimesUpTo(0)); }
public void _TestFixtureSetUp() { _generatedPrimes = new PrimeGenerator(new PrimeEvaluationEngine()).GeneratePrimesUpTo(20); }
public void Can_Create_Instance() { var generator = new PrimeGenerator(new PrimeEvaluationEngine()); Assert.IsNotNull(generator); }