Пример #1
0
        private static void Main(string[] args)
        {
            var consoleReader = new ConsoleReader();
              var input = consoleReader.ReadInt(min: 0);
              var spiral = new Spiral(input);

              Console.WriteLine("Output:");
              Console.WriteLine();
              Console.WriteLine(spiral.ToString());
        }
Пример #2
0
        public void StringWithSingleValueInFirstColumn()
        {
            var spiral = new Spiral(16);

              TestCase(spiral, new[]
              {
            "    6  7  8  9",
            "    5  0  1 10",
            "    4  3  2 11",
            "16 15 14 13 12"
              });
        }
Пример #3
0
 public void CreateWithNegativeInput_ThrowsArgumentException()
 {
     try
       {
     var spiral = new Spiral(-1);
     Assert.Fail("ArgumentException was not thrown");
       }
       catch (ArgumentException)
       {
     // expected
       }
 }
Пример #4
0
        public void StringWithSingleValueInLastColumn()
        {
            var spiral = new Spiral(25);

              TestCase(spiral, new[]
              {
            "20 21 22 23 24 25",
            "19  6  7  8  9   ",
            "18  5  0  1 10   ",
            "17  4  3  2 11   ",
            "16 15 14 13 12   "
              });
        }
Пример #5
0
        public void StringWithSingleValueInFirstRow()
        {
            var spiral = new Spiral(20);

              TestCase(spiral, new[]
              {
            "20            ",
            "19  6  7  8  9",
            "18  5  0  1 10",
            "17  4  3  2 11",
            "16 15 14 13 12"
              });
        }
Пример #6
0
        public void StringWithPerfectSquare_NoEmptySpaces()
        {
            var spiral = new Spiral(24);

              TestCase(spiral, new[]
              {
            "20 21 22 23 24",
            "19  6  7  8  9",
            "18  5  0  1 10",
            "17  4  3  2 11",
            "16 15 14 13 12"
              });
        }
Пример #7
0
        public void StringWithSingleValueInLastRow()
        {
            var spiral = new Spiral(12);

              TestCase(spiral, new[]
              {
            " 6  7  8  9",
            " 5  0  1 10",
            " 4  3  2 11",
            "         12"
              });
        }
Пример #8
0
        public void StringWithOneInput_SingleLine()
        {
            var spiral = new Spiral(1);

              TestCase(spiral, "0 1");
        }
Пример #9
0
 private void TestCase(Spiral spiral, string expected)
 {
     var actual = spiral.ToString();
       Assert.AreEqual(expected, actual);
 }
Пример #10
0
 private void TestCase(Spiral spiral, string[] expected)
 {
     TestCase(spiral, String.Join(Environment.NewLine, expected));
 }
Пример #11
0
        public void StringWithZeroInput_SingleCharacter()
        {
            var spiral = new Spiral(0);

              TestCase(spiral, "0");
        }
Пример #12
0
        public void StringWithTwoInput_TwoLines()
        {
            var spiral = new Spiral(2);

              TestCase(spiral, new[] {
            "0 1",
            "  2"
              });
        }