예제 #1
0
        static void Main(string[] args)
        {
            try
            {
                // retrieve the limits.
                int lowerLimit = 1;
                int upperLimit = 20;

                RetrieveUpperAndLowerLimit(out lowerLimit, out upperLimit);

                //Instiate the class.
                PrimeNumberUtil prime = new PrimeNumberUtil();

                //Get List of Prime numbers
                string primes = prime.GetListOfPrimeNumbers(lowerLimit, upperLimit);

                //Wriite out to console
                Console.WriteLine("The prime numbers are:");
                Console.WriteLine(primes);

                //Read to line.
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(String.Format("There was an exception while attemption to find the prime numbers.", ex));
            }
        }
예제 #2
0
        public void ListofPrimeNumbersTest_ArgumentException()
        {
            //Initiate class.
            PrimeNumberUtil prime = new PrimeNumberUtil();

            //Throws argument exception when given bad order of limits.
            Assert.ThrowsException <ArgumentException>(() => prime.GetListOfPrimeNumbers(20, 0));
        }
예제 #3
0
        public void ListofPrimeNumbersTest_IsEmpty()
        {
            //Initiate class.
            PrimeNumberUtil prime = new PrimeNumberUtil();

            //Get the string.
            string primeNumbers = prime.GetListOfPrimeNumbers(1, 1);

            //Make sure it is not null.
            Assert.IsTrue(string.IsNullOrEmpty(primeNumbers));
        }
예제 #4
0
        public void ListofPrimeNumbersTest_ReturnList()
        {
            //Initiate class.
            PrimeNumberUtil prime = new PrimeNumberUtil();

            //Get the string.
            string primeNumbers = prime.GetListOfPrimeNumbers(1, 20);

            //Make sure it is not null.
            Assert.IsNotNull(primeNumbers);
        }