Ejemplo n.º 1
0
        public void TestMatrixTraversalWithIncorrectInputSixTimesShouldResultErrorMessage()
        {
            using (StringReader sr = new StringReader("b\nb\nb\nb\nb\nb\nb\nb\nb\nb\nb\nb\n"))
                using (StringWriter sw = new StringWriter())
                {
                    Console.SetIn(sr);
                    Console.SetOut(sw);

                    RotatingMatrixTraversal.Main();

                    string expected = "Attempts limit reached! Maximal number of input attempts is";
                    Assert.IsTrue(sw.ToString().Contains(expected));
                }
        }
Ejemplo n.º 2
0
        public void TestMatrixTraversalWithInputTwo()
        {
            using (StringReader sr = new StringReader("2"))
                using (StringWriter sw = new StringWriter())
                {
                    Console.SetIn(sr);
                    Console.SetOut(sw);

                    RotatingMatrixTraversal.Main();

                    string expected = InputMessage + " 1 4\r\n 3 2\r\n";
                    Assert.AreEqual(expected, sw.ToString());
                }
        }
Ejemplo n.º 3
0
        public void TestMatrixTraversalWithInputSix()
        {
            using (StringReader sr = new StringReader("6"))
                using (StringWriter sw = new StringWriter())
                {
                    Console.SetIn(sr);
                    Console.SetOut(sw);

                    RotatingMatrixTraversal.Main();

                    string expected = InputMessage + "  1 16 17 18 19 20\r\n" +
                                      " 15  2 27 28 29 21\r\n" +
                                      " 14 31  3 26 30 22\r\n" +
                                      " 13 36 32  4 25 23\r\n" +
                                      " 12 35 34 33  5 24\r\n" +
                                      " 11 10  9  8  7  6\r\n";
                    Assert.AreEqual(expected, sw.ToString());
                }
        }