public void TranslateWithAttributesTest2() { RectMatrix <int, int> matrix = new RectMatrix <int, int>(); matrix.EnsureSize(3, 2); matrix[0, 0] = 2; matrix[0, 1] = 7; matrix[1, 0] = 3; matrix[1, 1] = 5; matrix[2, 0] = 8; matrix[2, 1] = 0; matrix.RowAttributes[0] = 1; matrix.RowAttributes[1] = 2; matrix.RowAttributes[2] = 3; matrix.ColumnAttributes[0] = 4; matrix.ColumnAttributes[1] = 10; List <int> rowIndexList1 = new List <int>(); List <int> rowIndexList2 = new List <int>(); List <int> columnIndexList1 = new List <int>(); List <int> columnIndexList2 = new List <int>(); matrix.Translate((row, column, rowAttribute, columnAttribute, x) => { rowIndexList1.Add(row); columnIndexList1.Add(column); return(rowAttribute > 1); }, (row, column, x) => { rowIndexList2.Add(row); columnIndexList2.Add(column); return(x); }); CollectionAssert.AreEqual(new int[] { 0, 0, 1, 1, 2, 2 }, rowIndexList1); CollectionAssert.AreEqual(new int[] { 1, 1, 2, 2 }, rowIndexList2); CollectionAssert.AreEqual(new int[] { 0, 1, 0, 1, 0, 1 }, columnIndexList1); CollectionAssert.AreEqual(new int[] { 0, 1, 0, 1 }, columnIndexList2); }
public void TranslateWithAttributesGuardCase2Test() { RectMatrix <string, int> matrix = new RectMatrix <string, int>(); matrix.EnsureSize(1, 1); matrix[0, 0] = "1"; matrix.Translate((row, column, rowAttribute, columnAttribute, x) => true, null); }
public void TranslateWithAttributesGuardCase1Test() { RectMatrix <string, int> matrix = new RectMatrix <string, int>(); matrix.EnsureSize(1, 1); matrix[0, 0] = "1"; matrix.Translate(null, (row, column, x) => x); }
public void TranslateTObjTest() { RectMatrix <string> matrix = new RectMatrix <string>(1, 1); matrix.EnsureSize(1, 1); object dataObj = new object(); object result = null; matrix.Translate((row, column, obj, x) => { result = obj; return(x); }, dataObj); Assert.AreSame(dataObj, result); }
public void TranslateGuardTest() { RectMatrix <int> matrix = new RectMatrix <int>(2, 3); matrix.EnsureSize(2, 3); matrix[0, 0] = 1; matrix[0, 1] = 2; matrix[0, 2] = 3; matrix[1, 0] = 4; matrix[1, 1] = 5; matrix[1, 2] = 6; matrix.Translate(null); }
public void TranslateWithAttributesTest1() { RectMatrix <string, int> matrix = new RectMatrix <string, int>(); matrix.EnsureSize(4, 3); matrix[0, 0] = "a"; matrix[0, 1] = "b"; matrix[0, 2] = "c"; matrix[1, 0] = "d"; matrix[1, 1] = "e"; matrix[1, 2] = "f"; matrix[2, 0] = "g"; matrix[2, 1] = "h"; matrix[2, 2] = "i"; matrix[3, 0] = "j"; matrix[3, 1] = "k"; matrix[3, 2] = "l"; matrix.RowAttributes[0] = 2; matrix.RowAttributes[1] = 4; matrix.RowAttributes[2] = 6; matrix.RowAttributes[3] = 8; matrix.ColumnAttributes[0] = 12; matrix.ColumnAttributes[1] = 8; matrix.ColumnAttributes[2] = 4; matrix.Translate((row, column, rowAttribute, columnAttribute, x) => rowAttribute > 3 && rowAttribute < 7 && columnAttribute < 9, (row, column, x) => "-" + x + "-"); Assert.AreEqual("a", matrix[0, 0]); Assert.AreEqual("b", matrix[0, 1]); Assert.AreEqual("c", matrix[0, 2]); Assert.AreEqual("d", matrix[1, 0]); Assert.AreEqual("-e-", matrix[1, 1]); Assert.AreEqual("-f-", matrix[1, 2]); Assert.AreEqual("g", matrix[2, 0]); Assert.AreEqual("-h-", matrix[2, 1]); Assert.AreEqual("-i-", matrix[2, 2]); Assert.AreEqual("j", matrix[3, 0]); Assert.AreEqual("k", matrix[3, 1]); Assert.AreEqual("l", matrix[3, 2]); }
public void TranslateTest2() { RectMatrix <string> matrix = new RectMatrix <string>(3, 2); matrix.EnsureSize(3, 2); matrix[0, 0] = "2"; matrix[0, 1] = "3"; matrix[1, 0] = "11"; matrix[1, 1] = "9"; matrix[2, 0] = "2"; matrix[2, 1] = "A"; List <int> rowIndexList = new List <int>(); List <int> columnIndexList = new List <int>(); matrix.Translate((row, column, x) => { rowIndexList.Add(row); columnIndexList.Add(column); return(x + "X"); }); Assert.AreEqual("2X", matrix[0, 0]); Assert.AreEqual("3X", matrix[0, 1]); Assert.AreEqual("11X", matrix[1, 0]); Assert.AreEqual("9X", matrix[1, 1]); Assert.AreEqual("2X", matrix[2, 0]); Assert.AreEqual("AX", matrix[2, 1]); CollectionAssert.AreEqual(new int[] { 0, 0, 1, 1, 2, 2 }, rowIndexList); CollectionAssert.AreEqual(new int[] { 0, 1, 0, 1, 0, 1 }, columnIndexList); }
public void TranslateTest1() { RectMatrix <int> matrix = new RectMatrix <int>(2, 3); matrix.EnsureSize(2, 3); matrix[0, 0] = 7; matrix[0, 1] = 2; matrix[0, 2] = 3; matrix[1, 0] = 2; matrix[1, 1] = 5; matrix[1, 2] = 6; List <int> rowIndexList = new List <int>(); List <int> columnIndexList = new List <int>(); matrix.Translate((row, column, x) => { rowIndexList.Add(row); columnIndexList.Add(column); return(x + 1); }); Assert.AreEqual(8, matrix[0, 0]); Assert.AreEqual(3, matrix[0, 1]); Assert.AreEqual(4, matrix[0, 2]); Assert.AreEqual(3, matrix[1, 0]); Assert.AreEqual(6, matrix[1, 1]); Assert.AreEqual(7, matrix[1, 2]); CollectionAssert.AreEqual(new int[] { 0, 0, 0, 1, 1, 1 }, rowIndexList); CollectionAssert.AreEqual(new int[] { 0, 1, 2, 0, 1, 2 }, columnIndexList); }