コード例 #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"
              });
        }