Ejemplo n.º 1
0
        public void Given_2DArrayOfInts_When_WriteToArea_Then_ResultIsAsExpected
            (int[,] data, int[,] dataToWrite, int rowOffset, int columnOffset, int[,] expected)
        {
            IOneBasedArray2D <int> oneBasedData        = new OneBasedArray2DImpl <int>(data);
            IOneBasedArray2D <int> oneBasedDataToWrite = new OneBasedArray2DImpl <int>(dataToWrite);

            oneBasedData.WriteToArea(oneBasedDataToWrite, rowOffset, columnOffset);
            Assert.AreEqual(data, expected,
                            string.Format("Failure for (rowOffset, columnOffset) = ({0}, {1})", rowOffset, columnOffset));
        }
Ejemplo n.º 2
0
        public void Given_2DArrayOfBytes_When_SubArray_Then_ExpectedSubArrayReturned
            (byte[,] data, int startAtRow, int startAtColumn, int stopBeforeRow, int stopBeforeColumn, byte[,] expected)
        {
            IOneBasedArray2D <byte> oneBasedData     = new OneBasedArray2DImpl <byte>(data);
            IOneBasedArray2D <byte> oneBasedExpected = new OneBasedArray2DImpl <byte>(expected);
            IOneBasedArray2D <byte> sub = oneBasedData.SubArray(startAtRow, startAtColumn, stopBeforeRow, stopBeforeColumn);

            Assert.AreEqual(oneBasedExpected.ZeroBasedEquivalent, sub.ZeroBasedEquivalent, string.Format(
                                "Failure for sub array with coordinates ({0}, {1}) --> ({2}, {3}))",
                                startAtRow, startAtColumn, stopBeforeRow, stopBeforeColumn));
        }
Ejemplo n.º 3
0
        public void Given_2DArray_When_SlicedIntoColumns_Then_AllColumnsHaveCorrectLength()
        {
            IOneBasedArray2D <string> array = new OneBasedArray2DImpl <string>(new string[, ] {
                { "1", "2" }, { "a", "b" }, { "5", "6" }
            });

            for (int col = 1; col <= array.GetLength(1); col++)
            {
                IOneBasedArray <string> colSlice = array.SliceColumn(col);
                Assert.AreEqual(3, colSlice.Length, "Sliced column should have correct length");
            }
        }
Ejemplo n.º 4
0
        public void Given_2DArray_When_SlicedIntoRows_Then_AllRowsHaveCorrectLength()
        {
            IOneBasedArray2D <string> array = new OneBasedArray2DImpl <string>(new string[, ] {
                { "1", "2" }, { "a", "b" }, { "5", "6" }
            });

            for (int row = 1; row <= array.GetLength(0); row++)
            {
                IOneBasedArray <string> rowSlice = array.SliceRow(row);
                Assert.AreEqual(2, rowSlice.Length, "Sliced row should have correct length");
            }
        }
Ejemplo n.º 5
0
        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));
            }
        }