public void Print(PrimeTable table)
        {
            if (table == null || table.AxisX == null)
                return;

            PrintHeader(table);
            for (var i = 0; i < table.AxisX.Length; i++)
            {
                PrintRow(table, i);
            }
        }
        public void Should_Not_Print_Empty_Prime_Table()
        {
            //given
            var expectedOutput = String.Empty;
            PrimeTable table = new PrimeTable(null);

            //when
            _tablePrinter.Print(table);

            //then
            var consoleOutput = _consoleOutWriter.ToString();
            Assert.AreEqual(expectedOutput, consoleOutput);
        }
        public void Should_Create_Prime_Table_Rank_3()
        {
            //given
            const int rank = 3;
            var tableAxis = new[] { 2, 3, 5 };
            var expectedTable = new PrimeTable(tableAxis);

            //when
            var table = _primeTableFactory.Create(rank);

            //then
            Assert.AreEqual(expectedTable.AxisX, table.AxisX);
            Assert.AreEqual(expectedTable.AxisY, table.AxisY);
        }
        public void Should_Print_Prime_Table_Rank_3()
        {
            //given
            var expectedOutput = GetExpectedOutputForRank3Table();

            var tableAxis = new[] { 2, 3, 5 };
            var table = new PrimeTable(tableAxis);

            //when
            _tablePrinter.Print(table);

            //then
            var consoleOutput = _consoleOutWriter.ToString();
            Assert.AreEqual(expectedOutput, consoleOutput);
        }
        private void PrintHeader(PrimeTable table)
        {
            var builder = new StringBuilder();
            builder.Append(Tab);

            for (var i = 0; i < table.AxisX.Length; i++)
            {
                builder.Append(table.AxisX[i]);

                if ((i + 1) < table.AxisX.Length)
                    builder.Append(Tab);
            }

            var output = builder.ToString();
            Console.WriteLine(output);
        }
        private void PrintRow(PrimeTable table, int index)
        {
            var builder = new StringBuilder();
            builder.Append(table.AxisY[index]);
            builder.Append(Tab);

            for (var i = 0; i < table.AxisX.Length; i++)
            {
                var cellValue = table.GetCellValue(index, i);
                builder.Append(cellValue);

                if ((i + 1) < table.AxisX.Length)
                    builder.Append(Tab);
            }

            var output = builder.ToString();
            Console.WriteLine(output);
        }