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()); }
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" }); }
public void CreateWithNegativeInput_ThrowsArgumentException() { try { var spiral = new Spiral(-1); Assert.Fail("ArgumentException was not thrown"); } catch (ArgumentException) { // expected } }
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 " }); }
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" }); }
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" }); }
public void StringWithSingleValueInLastRow() { var spiral = new Spiral(12); TestCase(spiral, new[] { " 6 7 8 9", " 5 0 1 10", " 4 3 2 11", " 12" }); }
public void StringWithOneInput_SingleLine() { var spiral = new Spiral(1); TestCase(spiral, "0 1"); }
private void TestCase(Spiral spiral, string expected) { var actual = spiral.ToString(); Assert.AreEqual(expected, actual); }
private void TestCase(Spiral spiral, string[] expected) { TestCase(spiral, String.Join(Environment.NewLine, expected)); }
public void StringWithZeroInput_SingleCharacter() { var spiral = new Spiral(0); TestCase(spiral, "0"); }
public void StringWithTwoInput_TwoLines() { var spiral = new Spiral(2); TestCase(spiral, new[] { "0 1", " 2" }); }