public void Given_1dArray_When_ConvertedTo2dArrayAcrossColumns_Then_New2dArrayHasCorrectNumberOfRowsAndColumns() { IOneBasedArray <string> oneDimArray = new OneBasedArrayImpl <string>(new string[] { "a", "b", "c", "d" }); IOneBasedArray2D <string> twoDimArray = oneDimArray.To2DArray(ArrayOrientation.COLUMN); Assert.AreEqual(1, twoDimArray.GetLength(0), "New 2D array should have 1 row"); Assert.AreEqual(4, twoDimArray.GetLength(1), "New 2D array should have 4 columns"); }
public void Given_2DArrayOfInts_When_Write1DArrayToColumn_Then_ResultIsAsExpected (int[,] data, int[] dataToWrite, int column, int offset, int[] expected) { OneBasedArray2DImpl <int> oneBasedData = new OneBasedArray2DImpl <int>(data); OneBasedArrayImpl <int> oneBasedDataToWrite = new OneBasedArrayImpl <int>(dataToWrite); IOneBasedArray <int> oneBasedExpected = new OneBasedArrayImpl <int>(expected); oneBasedData.WriteToColumn(oneBasedDataToWrite, column, offset); for (int i = 1; i <= oneBasedExpected.Length; i++) { Assert.AreEqual(oneBasedExpected[i], oneBasedData[i, column], string.Format("Mismatch at row {0} column {1} for offset {2}", i, column, offset)); } }