コード例 #1
0
        public void TestPrintMatrixSize4()
        {
            MatrixEngine engine = new MatrixEngine();

            int n = 4;
            int[,] expectedMatrix =
            {
                {1, 10, 11, 12},
                {9,  2, 15, 13},
                {8, 16,  3, 14},
                {7,  6,  5,  4}
            };

            string expected = MatrixAsString(expectedMatrix);
            int[,] actualMatrix = engine.GenerateRotatingWalkMatirx(n);
            string actual = MatrixAsString(actualMatrix);
            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Console.Write("Enter a positive number: ");
            string input = Console.ReadLine();
            int number = 0;
            while (!int.TryParse(input, out number) || number < 0 || number > 100)
            {
                Console.WriteLine("You haven't entered a correct positive number");
                input = Console.ReadLine();
            }

            int matrixDimension = number;

            MatrixEngine engine = new MatrixEngine();
            int[,] matrix = engine.GenerateRotatingWalkMatirx(matrixDimension);

            PrintMatrix(matrix);
        }
コード例 #3
0
        public void TestInvalidOutputMatrixSize7()
        {
            MatrixEngine engine = new MatrixEngine();

            int n = 7;
            int[,] expectedMatrix =
            {
                { 1, 19, 20, 21, 22, 23, 24},
                {18,  2, 33, 34, 35, 36, 25},
                {17, 39,  3, 32, 39, 37, 26},
                {16, 48, 41,  4, 31, 38, 27},
                {15, 47, 49, 42,  5, 30, 28},
                {14, 46, 45, 44, 43,  6, 29},
                {13, 12, 11, 10,  9,  8,  7}
            };

            string expected = MatrixAsString(expectedMatrix);
            int[,] actualMatrix = engine.GenerateRotatingWalkMatirx(n);
            string actual = MatrixAsString(actualMatrix);
            Assert.AreNotEqual(expected, actual);
        }
コード例 #4
0
 public static void Main(string[] args)
 {
     IEngine engine = new MatrixEngine();
     engine.Run();
 }