public void CheckLargePrimes() { foreach (var prime in _largePrimes) { Assert.True(PrimeChecker.IsPrime(prime)); } }
public void CheckSmallPrimes() { foreach (var prime in _smallPrimes) { Assert.True(PrimeChecker.IsPrime(prime)); } }
public void CheckMediumPrimes() { foreach (var prime in _mediumPrimes) { Assert.True(PrimeChecker.IsPrime(prime)); } }
// A button that takes the user inputed number and checks if it is prime by passing it through the PrimeChecker class when it is clicked private void btnCheck_Click(object sender, EventArgs e) { // Convert number so it can be passed through the IsPrime method, which uses BigInteger if (PrimeChecker.IsPrime(Convert.ToInt64(nudUserInput.Value)) == true) { // Displays label for that shows the number is prime lblPrime.Show(); lblNotPrime.Hide(); // Changes background color to green for prime numbers this.BackColor = Color.Green; // A happy cat is displayed :) picHappyCat.Show(); picSadCat.Hide(); } else { // Displays label for that shows the number is not prime lblNotPrime.Show(); lblPrime.Hide(); // Changes background color to red for non-prime numbers this.BackColor = Color.Red; // A sad cat is displayed :( picSadCat.Show(); picHappyCat.Hide(); } }
public void PrimeTests(int x, bool expected) { PrimeChecker prime = new PrimeChecker(); bool result = prime.IsPrime(x); Assert.AreEqual(expected, result); }
private void Calculate() { _factors = FactorFinder.FindFactorList(_target); _factors.Add(_target); _isPrime = PrimeChecker.IsPrime(_target); _isPerfect = PerfectChecker.IsPerfect(_target); }
public void RunFactorFinder() { ConsoleOutput.DisplayTitle(); int input = ConsoleInput.GetUserInput(); FactorFinder findFactors = new FactorFinder(); int[] factors = findFactors.FactorArray(input); PrimeChecker checkPrime = new PrimeChecker(); bool isPrime = checkPrime.IsPrime(input); PerfectChecker checkPerfect = new PerfectChecker(); bool isPerfect = checkPerfect.IsPerfect(input); ConsoleOutput.DisplayResults(input, factors, isPrime, isPerfect); }
public void _2_Should_Be_Prime() { Assert.True(PrimeChecker.IsPrime(2)); }
public void Should_Return_True_For_All_Primes_Less_Than_10(int n) { Assert.True(PrimeChecker.IsPrime(n)); }
public void Even_Numbers_Should_Not_Be_Prime(int n) { Assert.False(PrimeChecker.IsPrime(n)); }
public void GeneratedPrimeIsPrime() { var prime = PrimeGenerator.GetPrime1(); Assert.True(PrimeChecker.IsPrime(prime)); }
public void PrimeTest(int target, bool primeResult) { bool isPrime = PrimeChecker.IsPrime(target); Assert.AreEqual(isPrime, primeResult); }