예제 #1
0
        static void Main(string[] args)
        {
            int number = 0;

            while (true)
            {
                Console.Write("Enter size of Prime Numbers Multiplication Table: ");
                if (Int32.TryParse(Console.ReadLine(), out number))
                {
                    if (number >= 1)
                    {
                        break;
                    }
                    else
                    {
                        InvalidNumberError();
                    }
                }
                else
                {
                    InvalidNumberError();
                }
            }
            ;
            IPrimeService myPrimeCalculator = new PrimeService();
            IPrint        consoleDisplay    = new ConsolePrint();
            var           primeNumbers      = myPrimeCalculator.GetPrimeNumbers(number).ToArray();
            var           primeArray        = myPrimeCalculator.GetPrimeMultiplcationTable(primeNumbers);

            consoleDisplay.Print(primeArray);
            Console.ReadKey();
        }
예제 #2
0
        public void Given_InputArray_Null_Then_PrintArray()
        {
            int[,] input = null;
            var output = new StringWriter();

            Console.SetOut(output);

            IPrint printConsole = new ConsolePrint();

            printConsole.Print(input);
            var actualOutput = output.ToString();

            Assert.Equal("Input Array is empty.\r\n", actualOutput);
        }
예제 #3
0
        public void Given_ValidInputArray_Then_PrintArray()
        {
            int[,] input = new int[, ] {
                { 0, 2 }, { 2, 4 }
            };
            var output = new StringWriter();

            Console.SetOut(output);
            IPrint printConsole = new ConsolePrint();

            printConsole.Print(input);
            var actualOutput = output.ToString();

            Assert.Contains("4", actualOutput);
        }