예제 #1
0
        static void Main(string[] args)
        {
            ConsoleAdapter console    = new ConsoleImplementation();
            bool           shouldExit = false;

            while (!shouldExit)
            {
                try
                {
                    console.RequestNumber();
                    string userInput = console.GetInput();
                    if (userInput == null)
                    {
                        continue;
                    }
                    uint numberToSieve = console.GetNumberFromInput(userInput);
                    var  sieve         = new SieveOfEratosthenesImplementation(numberToSieve);
                    var  primes        = sieve.FindPrimeNumbers();
                    console.DisplayPrimesFound(primes);
                }
                catch
                {
                    shouldExit = true;
                }
            }
        }
        public void CantFindPrimesWithoutAskingForANumber()
        {
            Sieve sieve = new SieveOfEratosthenesImplementation();

            Assert.Throws <SieveNotInitialized>(() => { sieve.FindPrimeNumbers(); });
        }
        public void ExecuteSieveNotExpectingResults()
        {
            Sieve sieve = new SieveOfEratosthenesImplementation(120);

            uint[] primes = sieve.FindPrimeNumbers();
        }