public void Traverse_NullArray() { int[,] A = null; TraverseArraySpirally T = new TraverseArraySpirally(); List <int> R = T.TraverseArraySprirally(arrayToTraverse: A); Assert.IsTrue(condition: R.Count == 0, message: "Expecting an empty List<int>"); }
public void Traverse1x1Array() { int[,] A = { { 10 }, { 1000 } }; List <int> expectedResultList = new List <int>(); expectedResultList.AddRange(collection: new int[] { 10, 1000 }); TraverseArraySpirally T = new TraverseArraySpirally(); List <int> actualResultList = T.TraverseArraySprirally(arrayToTraverse: A); Assert.IsTrue(condition: this.CompareTwoListStartToEnd(expectedList: expectedResultList, actualList: actualResultList), message: "Actual list differs from expected list", parameters: new List <int>[] { actualResultList, expectedResultList }); }
public void Traverse6x6Array() { // 6x6 array int[,] A = { { 1, 2, 3, 4, 5, 6 }, { 20, 21, 22, 23, 24, 7 }, { 19, 32, 33, 34, 25, 8 }, { 18, 31, 36, 35, 26, 9 }, { 17, 30, 29, 28, 27, 10 }, { 16, 15, 14, 13, 12, 11 } }; List <int> expectedResultList = new List <int>(); int loopCount = A.GetLength(0) * A.GetLength(1); for (int i = 1; i <= loopCount; i++) { expectedResultList.Add(item: i); } TraverseArraySpirally T = new TraverseArraySpirally(); List <int> actualResultList = T.TraverseArraySprirally(arrayToTraverse: A); Assert.IsTrue(condition: this.CompareTwoListStartToEnd(expectedList: expectedResultList, actualList: actualResultList), message: "Actual list differs from expected list", parameters: new List <int>[] { actualResultList, expectedResultList }); }